public TVShowViewModel(WebTVShowDetailed show, IEnumerable<WebTVSeasonDetailed> seasons)
 {
     Show = show;
     Seasons = seasons;
 }
 public TVEpisodeViewModel(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     Episode = episode;
     _show = show;
     _season = season;
 }
 public bool StartWatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     Log.Debug("WSD: Start watching episode {0}, season {1}, show {2}", episode.Title, episode.SeasonId, episode.ShowId);
     return true;
 }
 public TVSeasonViewModel(WebTVShowDetailed show, WebTVSeasonDetailed season, IEnumerable<WebTVEpisodeDetailed> episodes)
 {
     Show = show;
     Season = season;
     Episodes = episodes;
 }
 public bool CancelWatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     Log.Debug("WSD: Canceled episode {0}", episode.Title);
     return true;
 }
 public bool FinishEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     Log.Debug("WSD: Finished episode {0}", episode.Title);
     return true;
 }
 public bool WatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode, int progress)
 {
     // Follw.it doesn't require to send a status each X minutes or something
     return true;
 }
 public bool WatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode, int progress)
 {
     Log.Debug("WSD: Watching episode {0} ({1}%)", episode.Title, progress);
     return true;
 }
 public bool StartWatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     return CallFollwitEpisode(episode, FollwitWatchStatus.Watching);
 }
 public bool StartWatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     return CallShowAPI(show, season, episode, TraktWatchStatus.Watching, 0);
 }
 public bool FinishEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     return CallShowAPI(show, season, episode, TraktWatchStatus.Scrobble, 100);
 }
        private bool CallShowAPI(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeBasic episode, TraktWatchStatus state, int? progress)
        {
            var data = new TraktEpisodeScrobbleData()
            {
                MediaCenter = TraktConfig.MediaCenter,
                MediaCenterBuildDate = TraktConfig.MediaCenterDate,
                MediaCenterVersion = TraktConfig.MediaCenterVersion,
                PluginVersion = TraktConfig.PluginVersion,
                Password = Configuration["passwordHash"],
                UserName = Configuration["username"],

                Duration = show.Runtime.ToString(),
                Episode = episode.EpisodeNumber.ToString(),
                Season = season.SeasonNumber.ToString(),
                Title = show.Title,
                Year = show.Year.ToString(),
            };

            if (progress != null)
                data.Progress = progress.Value.ToString();

            if (show.ExternalId.Count(x => x.Site == "IMDB") > 0)
                data.IMDBID = show.ExternalId.First(x => x.Site == "IMDB").Id;
            if (show.ExternalId.Count(x => x.Site == "TVDB") > 0)
                data.TVDBID = show.ExternalId.First(x => x.Site == "TVDB").Id;
            if (data.IMDBID == null && data.TVDBID == null)
            {
                Log.Info("Trakt: IMDB and TVDB unknown of episode {0}, not sending", episode.Title);
                return false;
            }

            try
            {
                Log.Debug("Trakt: calling service for show {0} (episode {1}) with progress {2} and state {3}", data.Title, episode.Title, data.Progress, state.ToString());
                TraktResponse response = TraktAPI.ScrobbleEpisode(data, state);
                if (response.Status != "success")
                {
                    Log.Warn("Trakt: failed to update watch status of episode '{0}' ({1}): {2}", episode.Title, episode.Id, response.Error);
                    return false;
                }
                Log.Trace("Trakt: finished service call");
                return true;
            }
            catch (Exception ex)
            {
                Log.Warn("Trakt: failed to call service", ex);
                return false;
            }
        }
 public bool WatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode, int progress)
 {
     return CallShowAPI(show, season, episode, TraktWatchStatus.Watching, progress);
 }