private string CreateLookupKey(MediaItem episode)
        {
            var tvdid        = MediaItemAspectsUtl.GetTvdbId(episode);
            var seasonIndex  = MediaItemAspectsUtl.GetSeasonIndex(episode);
            var episodeIndex = MediaItemAspectsUtl.GetEpisodeIndex(episode);

            return(string.Format("{0}_{1}_{2}", tvdid, seasonIndex, episodeIndex));
        }
Beispiel #2
0
        private string CreateLookupKey(MediaItem episode)
        {
            string tvdbId       = MediaItemAspectsUtl.GetTvdbId(episode);
            int    seasonIndex  = MediaItemAspectsUtl.GetSeasonIndex(episode);
            int    episodeIndex = MediaItemAspectsUtl.GetEpisodeNumbers(episode).FirstOrDefault();

            return(string.Format("{0}_{1}_{2}", tvdbId, seasonIndex, episodeIndex));
        }
Beispiel #3
0
        private ITraktEpisode ExtractTraktEpisode(MediaItem episodeMediaItem)
        {
            ITraktEpisode episode = new TraktEpisode
            {
                Number       = MediaItemAspectsUtl.GetEpisodeIndex(episodeMediaItem),
                SeasonNumber = MediaItemAspectsUtl.GetSeasonIndex(episodeMediaItem)
            };

            return(episode);
        }
Beispiel #4
0
 private MediaLibraryEpisode GetLibraryEpisode(MediaItem episodeMediaItem, int epNumber)
 {
     return(new MediaLibraryEpisode
     {
         Season = MediaItemAspectsUtl.GetSeasonIndex(episodeMediaItem),
         ShowImdb = MediaItemAspectsUtl.GetSeriesImdbId(episodeMediaItem),
         ShowTitle = MediaItemAspectsUtl.GetSeriesTitle(episodeMediaItem),
         ShowTvdb = MediaItemAspectsUtl.GetTvdbId(episodeMediaItem),
         Number = epNumber
     });
 }
        private ITraktSyncCollectionPost GetCollectedShowsForSync(IList <MediaItem> localCollectedEpisodes, IEnumerable <EpisodeCollected> traktEpisodesCollected)
        {
            _mediaPortalServices.GetLogger().Info("Trakt: finding local episodes to add to trakt collection");
            TraktSyncCollectionPostBuilder     builder        = new TraktSyncCollectionPostBuilder();
            ILookup <string, EpisodeCollected> onlineEpisodes = traktEpisodesCollected.ToLookup(tce => CreateLookupKey(tce), tce => tce);

            foreach (var episode in localCollectedEpisodes)
            {
                string           tvdbKey      = CreateLookupKey(episode);
                EpisodeCollected traktEpisode = onlineEpisodes[tvdbKey].FirstOrDefault();

                if (traktEpisode == null)
                {
                    TraktShow show = new TraktShow
                    {
                        Title = MediaItemAspectsUtl.GetSeriesTitle(episode),
                        Ids   = new TraktShowIds
                        {
                            Tvdb = MediaItemAspectsUtl.GetTvdbId(episode),
                            Imdb = MediaItemAspectsUtl.GetSeriesImdbId(episode)
                        }
                    };

                    TraktMetadata metadata = new TraktMetadata
                    {
                        Audio            = MediaItemAspectsUtl.GetVideoAudioCodec(episode),
                        AudioChannels    = MediaItemAspectsUtl.GetVideoAudioChannel(episode),
                        MediaResolution  = MediaItemAspectsUtl.GetVideoResolution(episode),
                        MediaType        = MediaItemAspectsUtl.GetVideoMediaType(episode),
                        ThreeDimensional = false
                    };

                    DateTime collectedAt = MediaItemAspectsUtl.GetDateAddedToDb(episode);

                    builder.AddShow(show,
                                    new PostSeasons
                    {
                        {
                            MediaItemAspectsUtl.GetSeasonIndex(episode),
                            new PostEpisodes
                            {
                                { MediaItemAspectsUtl.GetEpisodeIndex(episode), metadata, collectedAt }
                            }
                        }
                    });
                }
            }
            return(builder.Build());
        }
        private ITraktSyncHistoryPost GetWatchedShowsForSync(IList <MediaItem> localWatchedEpisodes, IEnumerable <EpisodeWatched> traktEpisodesWatched)
        {
            _mediaPortalServices.GetLogger().Info("Trakt: finding local shows to add to trakt watched history");
            TraktSyncHistoryPostBuilder      builder        = new TraktSyncHistoryPostBuilder();
            ILookup <string, EpisodeWatched> onlineEpisodes = traktEpisodesWatched.ToLookup(twe => CreateLookupKey(twe), twe => twe);

            foreach (var episode in localWatchedEpisodes)
            {
                string         tvdbKey      = CreateLookupKey(episode);
                EpisodeWatched traktEpisode = onlineEpisodes[tvdbKey].FirstOrDefault();

                if (traktEpisode == null)
                {
                    TraktShow show = new TraktShow
                    {
                        Title = MediaItemAspectsUtl.GetSeriesTitle(episode),
                        Ids   = new TraktShowIds
                        {
                            Tvdb = MediaItemAspectsUtl.GetTvdbId(episode),
                            Imdb = MediaItemAspectsUtl.GetSeriesImdbId(episode)
                        }
                    };

                    DateTime watchedAt = MediaItemAspectsUtl.GetLastPlayedDate(episode);

                    builder.AddShow(show, new PostHistorySeasons
                    {
                        {
                            MediaItemAspectsUtl.GetSeasonIndex(episode),
                            new PostHistoryEpisodes
                            {
                                { MediaItemAspectsUtl.GetEpisodeIndex(episode), watchedAt }
                            }
                        }
                    });
                }
            }
            return(builder.Build());
        }