package com.greinet.tvtotalripper.crawler;

import java.util.Objects;
import java.util.UUID;

/**
 * A wrapper class to collect all episode information
 * @author agreiner
 */
public class EpisodeWrapper {
    
    /** The URL to the episode */
    private final String url;
    /** The title */
    private final String title;
    /** The episode */
    private final String episode;
    /** The season */
    private final String season;
    /** The episode duration */
    private final String duration;
    /** The unique id */
    private final long id;
    /** The show */
    private final String show;
    
    /**
     * Create a episode wrapper to store episode information
     * @param url the URL
     * @param title the title
     * @param episode the episode
     * @param season the season
     * @param show the show
     * @param duration the duration
     */
    public EpisodeWrapper(String url, String title, String episode, String season, String show, String duration) {
        this.url = url;
        this.title = title;
        this.episode = episode;
        this.season = season;
        this.show = show;
        this.duration = duration;
        id = UUID.randomUUID().getLeastSignificantBits();
    }

    public String getShow() {
        return show;
    }
    
    /**
     * Return the unique id
     * @return the id
     */
    public long getId() {
        return id;
    }

    /**
     * Get the URL to the episode
     * @return the URL
     */
    public String getUrl() {
        return url;
    }

    /**
     * Get the title of the episode
     * @return the title
     */
    public String getTitle() {
        return title;
    }

    /**
     * Get the episode 
     * @return the episode 
     */
    public String getEpisode() {
        return episode;
    }

    /**
     * Get the season of the episode
     * @return the season
     */
    public String getSeason() {
        return season;
    }

    /**
     * Get the duration of the episode
     * @return the duration
     */
    public String getDuration() {
        return duration;
    }

    @Override
    public String toString() {
        return title;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 19 * hash + Objects.hashCode(this.url);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final EpisodeWrapper other = (EpisodeWrapper) obj;
        return Objects.equals(this.url, other.url);
    }
}
