/// <summary>
        /// Creates data object for episode scrobbling
        /// </summary>
        internal static TraktScrobbleEpisode CreateEpisodeScrobbleData(VideoInfo info)
        {
            // create scrobble data
            var scrobbleData = new TraktScrobbleEpisode
            {
                Show = new TraktShow
                {
                    Ids = new TraktShowId(),
                    Title = info.Title,
                    Year = info.Year.ToNullableInt32()
                },
                Episode = new TraktEpisode
                {
                    Ids = new TraktEpisodeId(),
                    Number = info.EpisodeIdx.ToInt(),
                    Season = info.SeasonIdx.ToInt()
                },
                Progress = GetPlayerProgress(info),
                AppDate = TraktSettings.BuildDate,
                AppVersion = TraktSettings.Version
            };

            return scrobbleData;
        }
示例#2
0
        /// <summary>
        /// Creates Scrobble data based on a DBEpisode object
        /// </summary>
        private TraktScrobbleEpisode CreateScrobbleData(DBEpisode episode, double progress)
        {
            var show = Helper.getCorrespondingSeries(episode[DBOnlineEpisode.cSeriesID]);
            if (show == null || show[DBOnlineSeries.cTraktIgnore]) return null;

            // check if its a valid episode, tvdb is notorious for episode 0's.
            if (episode[DBOnlineEpisode.cEpisodeIndex] < 1)
            {
                TraktLogger.Info("Ignoring scrobble of invalid episode with episode number zero. Title = '{0}'", episode.ToString());
                return null;
            }

            // bad progress reading from g_player
            if (progress > 100) progress = 100;

            var scrobbleData = new TraktScrobbleEpisode
            {
                Episode = new TraktEpisode
                {
                    Ids = new TraktEpisodeId
                    {
                        Tvdb = episode[DBOnlineEpisode.cID],
                        Imdb = BasicHandler.GetProperImdbId(episode[DBOnlineEpisode.cIMDBID])
                    },
                    Title = episode[DBOnlineEpisode.cEpisodeName],
                    Season = episode[DBOnlineEpisode.cSeasonIndex],
                    Number = episode[DBOnlineEpisode.cEpisodeIndex]
                },
                Show = new TraktShow
                {
                    Ids = new TraktShowId
                    {
                        Tvdb = show[DBSeries.cID],
                        Imdb = BasicHandler.GetProperImdbId(show[DBOnlineSeries.cIMDBID])
                    },
                    Title = show[DBOnlineSeries.cOriginalName],
                    Year = show.Year.ToNullableInt32()
                },
                Progress = Math.Round(progress, 2),
                AppVersion = TraktSettings.Version,
                AppDate = TraktSettings.BuildDate
            };

            return scrobbleData;
        }
        private TraktScrobbleEpisode CreateEpisodeScrobbleData(ITrackingInfo info, double progress = 0)
        {
            var scrobbleData = new TraktScrobbleEpisode
            {
                Episode = new TraktEpisode
                {
                    Ids = new TraktEpisodeId(),
                    Number = (int)info.Episode,
                    Season = (int)info.Season
                },
                Show = new TraktShow
                {
                    Ids = new TraktShowId { Imdb = info.ID_IMDB, Tmdb = info.ID_TMDB.ToNullableInt32(), Tvdb = info.ID_TVDB.ToNullableInt32() },
                    Title = info.Title,
                    Year = info.Year > 0 ? (int?)info.Year : null
                },
                AppDate = TraktSettings.BuildDate,
                AppVersion = TraktSettings.Version,
                Progress = progress
            };

            return scrobbleData;
        }
示例#4
0
 public static TraktScrobbleResponse StopEpisodeScrobble(TraktScrobbleEpisode episode)
 {
     var response = PostToTrakt(TraktURIs.ScrobbleStop, episode.ToJSON());
     return response.FromJSON<TraktScrobbleResponse>();
 }