Пример #1
0
        private bool CallMovieAPI(WebMovieBasic movie, TraktWatchStatus state, int? progress)
        {
            var data = new TraktMovieScrobbleData()
            {
                MediaCenter = TraktConfig.MediaCenter,
                MediaCenterBuildDate = TraktConfig.MediaCenterDate,
                MediaCenterVersion = TraktConfig.MediaCenterVersion,
                PluginVersion = TraktConfig.PluginVersion,
                Password = Configuration["passwordHash"],
                UserName = Configuration["username"],

                Duration = movie.Runtime.ToString(),
                Title = movie.Title,
                Year = movie.Year.ToString()
            };

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

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

            try
            {
                Log.Debug("Trakt: calling service for movie {0} with progress {1} and state {2}", data.Title, data.Progress, state);
                TraktResponse response = TraktAPI.ScrobbleMovie(data, state);
                if (response.Status != "success")
                {
                    Log.Warn("Trakt: failed to update watch status of movie '{0}' ({1}): {2}", movie.Title, movie.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;
            }
        }
Пример #2
0
        private bool CallMovieAPI(WebMovieBasic movie, TraktScrobbleState state, int progress)
        {
            TraktMovieScrobble data = new TraktMovieScrobble()
            {
                MediaCenter = TraktConfig.MediaCenter,
                MediaCenterBuildDate = TraktConfig.MediaCenterDate,
                MediaCenterVersion = TraktConfig.MediaCenterVersion,
                PluginVersion = TraktConfig.PluginVersion,
                Password = GetPasswordHash(),
                UserName = username,

                Duration = movie.Runtime.ToString(),
                IMDBID = movie.IMDBId,
                Progress = progress.ToString(),
                Title = movie.Title,
                TMDBID = movie.TMDBId,
                Year = movie.Year.ToString()
            };

            TraktResponse response = TraktAPI.ScrobbleMovie(data, state);

            if (response.Status != "success")
            {
                Log.Warn("Trakt: failed to update watch status of movie '{0}' ({1}): {2}", movie.Title, movie.Id, response.Error);
                return false;
            }
            else
            {
                return true;
            }
        }