Beispiel #1
0
        /// <summary>
        /// Sends Scrobble data to Trakt
        /// </summary>
        /// <param name="scrobbleData">The Data to send</param>
        /// <param name="status">The mode to send it as</param>
        /// <returns>The response from Trakt</returns>
        public static TraktResponse ScrobbleEpisodeState(TraktEpisodeScrobble scrobbleData, TraktScrobbleState status)
        {
            // check that we have everything we need
            // server can accept title if movie id is not supplied
            if (status != TraktScrobbleState.cancelwatching)
            {
                if (scrobbleData == null)
                {
                    TraktResponse error = new TraktResponse
                    {
                        Error = "Not enough information to send to server",
                        Status = "failure"
                    };
                    return error;
                }
            }

            // serialize Scrobble object to JSON and send to server
            string response = Transmit(string.Format(TraktConfig.URL.ScrobbleShow, status.ToString()), scrobbleData.ToJSON());

            // return success or failure
            return response.FromJSON<TraktResponse>();
        }
Beispiel #2
0
        private bool CallShowAPI(WebTVEpisodeBasic episode, TraktScrobbleState state, int progress)
        {
            WebTVShowDetailed show = service.GetTVShowDetailedById(episode.PID, episode.ShowId);
            WebTVSeasonDetailed season = service.GetTVSeasonDetailedById(episode.PID, episode.SeasonId);

            TraktEpisodeScrobble data = new TraktEpisodeScrobble()
            {
                MediaCenter = TraktConfig.MediaCenter,
                MediaCenterBuildDate = TraktConfig.MediaCenterDate,
                MediaCenterVersion = TraktConfig.MediaCenterVersion,
                PluginVersion = TraktConfig.PluginVersion,
                Password = GetPasswordHash(),
                UserName = username,

                Duration = show.Runtime.ToString(),
                Episode = episode.EpisodeNumber.ToString(),
                IMDBID = show.IMDBId,
                Progress = progress.ToString(),
                Season = season.SeasonNumber.ToString(),
                Title = show.Title,
                TVDBID = show.TVDBId,
                Year = show.Year.ToString(),
            };

            TraktResponse response = TraktAPI.ScrobbleEpisodeState(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;
            }
            else
            {
                return true;
            }
        }