Ejemplo n.º 1
0
        public static TraktResponse ScrobbleEpisode(TraktEpisodeScrobbleData data, TraktWatchStatus status)
        {
            string url  = String.Format(TraktConfig.URL.ScrobbleShow, MapToURL(status));
            string json = CallAPI(url, JSONUtil.ToJSON(data));

            return(JSONUtil.FromJSON <TraktResponse>(json));
        }
Ejemplo n.º 2
0
        private bool CallShowAPI(WebTVEpisodeBasic episode, TraktWatchStatus state, int? progress)
        {
            WebTVShowDetailed show = MediaService.GetTVShowDetailedById(episode.PID, episode.ShowId);
            WebTVSeasonDetailed season = MediaService.GetTVSeasonDetailedById(episode.PID, episode.SeasonId);

            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;
            }
        }
Ejemplo n.º 3
0
 public static TraktResponse ScrobbleEpisode(TraktEpisodeScrobbleData data, TraktWatchStatus status)
 {
     string url = String.Format(TraktConfig.URL.ScrobbleShow, MapToURL(status));
     string json = CallAPI(url, JSONUtil.ToJSON(data));
     return JSONUtil.FromJSON<TraktResponse>(json);
 }