package net.serverpeon.twitcharchiver.twitch;

import com.google.common.collect.Lists;
import com.google.common.base.MoreObjects;
import org.joda.time.DateTime;

import java.util.List;
import java.util.concurrent.TimeUnit;

public class BroadcastInformation {
    public final String title;
    public final int views;
    public final String broadcastId;
    private final int length;
    private final List<VideoSource> sourceList = Lists.newArrayList();
    private final net.serverpeon.twitcharchiver.downloader.VideoSource source;
    private final DateTime recordedAt;

    BroadcastInformation(final String title, final int views, final int length,
                         final String broadcastId, final net.serverpeon.twitcharchiver.downloader.VideoSource source,
                         final DateTime recordedAt
    ) {
        this.title = title;
        this.views = views;
        this.length = length;
        this.broadcastId = broadcastId;
        this.source = source;
        //this.sourceList = sourceList;
        this.recordedAt = recordedAt;
    }

    public long getVideoLength(final TimeUnit tu) {
        return tu.convert(length, TimeUnit.SECONDS);
    }

    public int getViews() {
        return this.views;
    }

    @Deprecated
    public Iterable<VideoSource> getSources() {
        return this.sourceList;
    }

    public net.serverpeon.twitcharchiver.downloader.VideoSource getSource() {
        return this.source;
    }

    public DateTime getRecordedDate() {
        return recordedAt;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof BroadcastInformation)) return false;

        BroadcastInformation that = (BroadcastInformation) o;

        return broadcastId.equals(that.broadcastId);
    }

    @Override
    public int hashCode() {
        return broadcastId.hashCode();
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("title", title)
                .add("views", views)
                .add("length", length)
                .add("broadcastId", broadcastId)
                .add("recordedAt", recordedAt)
                .add("sourceList", sourceList)
                .toString();
    }

    @Deprecated
    public static class VideoSource {
        public final String videoFileUrl;
        public final int length; //seconds
        public final boolean muted;

        public VideoSource(final String video_file_url, final int length, final boolean muted) {
            this.videoFileUrl = video_file_url;
            this.length = length;
            this.muted = muted;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof VideoSource)) return false;

            VideoSource that = (VideoSource) o;

            return videoFileUrl.equals(that.videoFileUrl);

        }

        @Override
        public String toString() {
            return Objects.toStringHelper(this)
                    .add("videoFileUrl", videoFileUrl)
                    .add("length", length)
                    .toString();
        }

        @Override
        public int hashCode() {
            return videoFileUrl.hashCode();
        }
    }
}

@@ -69,64 +69,85 @@
 mon.
-collect.Lists;%0Aimport com.google.common.base.MoreObjects
+base.MoreObjects;%0Aimport net.serverpeon.twitcharchiver.downloader.VideoSource
 ;%0Aim
@@ -180,31 +180,8 @@
 e;%0A%0A
-import java.util.List;%0A
 impo
@@ -399,120 +399,8 @@
 nal 
-List%3CVideoSource%3E sourceList = Lists.newArrayList();%0A    private final net.serverpeon.twitcharchiver.downloader.
 Vide
@@ -596,49 +596,8 @@
 nal 
-net.serverpeon.twitcharchiver.downloader.
 Vide
@@ -831,48 +831,8 @@
 ce;%0A
-        //this.sourceList = sourceList;%0A
     
@@ -1054,159 +1054,15 @@
     
-@Deprecated%0A    public Iterable%3CVideoSource%3E getSources() %7B%0A        return this.sourceList;%0A    %7D%0A%0A    public net.serverpeon.twitcharchiver.downloader.
+public 
 Vide
@@ -1884,1093 +1884,58 @@
 dd(%22
-sourceList%22, sourceList)%0A                .toString();%0A    %7D%0A%0A    @Deprecated%0A    public static class VideoSource %7B%0A        public final String videoFileUrl;%0A        public final int length; //seconds%0A        public final boolean muted;%0A%0A        public VideoSource(final String video_file_url, final int length, final boolean muted) %7B%0A            this.videoFileUrl = video_file_url;%0A            this.length = length;%0A            this.muted = muted;%0A        %7D%0A%0A        @Override%0A        public boolean equals(Object o) %7B%0A            if (this == o) return true;%0A            if (!(o instanceof VideoSource)) return false;%0A%0A            VideoSource that = (VideoSource) o;%0A%0A            return videoFileUrl.equals(that.videoFileUrl);%0A%0A        %7D%0A%0A        @Override%0A        public String toString() %7B%0A            return Objects.toStringHelper(this)%0A                    .add(%22videoFileUrl%22, videoFileUrl)%0A                    .add(%22length%22, length)%0A                    .toString();%0A        %7D%0A%0A        @Override%0A        public int hashCode() %7B%0A            return videoFileUrl.hashCode();%0A        %7D
+videoSource%22, source)%0A                .toString();
 %0A   

Remove deprecated legacy downloading system