package com.tromdev.youtubefetcher;

import com.google.api.services.youtube.model.Video;
import com.google.api.services.youtube.model.VideoSnippet;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Calder.
 * Represents data for a single YouTube video.
 */
public class VideoData implements Serializable{
    private Video mVideo;

    public void setVideo(Video video){
        mVideo = video;
    }

    public Video getVideo(){
        return mVideo;
    }

    public String getYouTubeId(){
        return mVideo.getId();
    }

    public String getTitle(){
        return mVideo.getSnippet().getTitle();
    }

    public VideoSnippet addTag(String tag){
        VideoSnippet mSnippet = mVideo.getSnippet();
        List<String> mTags = mSnippet.getTags();
        if (mTags == null){
            mTags = new ArrayList<String>(2);
        }
        mTags.add(tag);
        return mSnippet;
    }

    public String getThumbUri(){
        return mVideo.getSnippet().getThumbnails().getDefault().getUrl();
    }

    public String getVideoChannelTitle(){
        return mVideo.getSnippet().getChannelTitle();
    }

    public String getWatchUri(){
        return "http://m.youtube.com/watch?v=" + getYouTubeId();
    }

    public String getChannelId() {
        return mVideo.getSnippet().getChannelId();
    }
}
