/// <summary> /// Removes episodes on trakt that no longer exist in users database /// </summary> /// <param name="traktShows">trakt episode collection</param> /// <param name="episodes">list of local episodes</param> /// <param name="seriesID">tvdb series id of series</param> /// <returns>true if episode exists</returns> private TraktEpisodeSync GetEpisodesForTraktRemoval(TraktLibraryShow traktShow, List<DBEpisode> episodes) { List<TraktEpisodeSync.Episode> episodeList = new List<TraktEpisodeSync.Episode>(); foreach (var season in traktShow.Seasons) { foreach (var episode in season.Episodes) { var query = episodes.Where(e => e[DBOnlineEpisode.cSeriesID] == traktShow.SeriesId && e[DBOnlineEpisode.cSeasonIndex] == season.Season && e[DBOnlineEpisode.cEpisodeIndex] == episode).ToList(); if (query.Count == 0) { // we dont have the episode TraktLogger.Info("{0} - {1}x{2} does not exist in local database, marked for removal from trakt", traktShow.ToString(), season.Season.ToString(), episode.ToString()); TraktEpisodeSync.Episode ep = new TraktEpisodeSync.Episode { EpisodeIndex = episode.ToString(), SeasonIndex = season.Season.ToString() }; episodeList.Add(ep); } } } if (episodeList.Count > 0) { TraktEpisodeSync syncData = new TraktEpisodeSync { UserName = TraktSettings.Username, Password = TraktSettings.Password, SeriesID = traktShow.SeriesId, EpisodeList = episodeList }; return syncData; } return null; }
/// <summary> /// Removes episodes on trakt that no longer exist in users database /// </summary> /// <param name="traktShows">trakt episode collection</param> /// <param name="episodes">list of local episodes</param> /// <param name="seriesID">tvdb series id of series</param> /// <returns>true if episode exists</returns> private TraktEpisodeSync GetEpisodesForTraktRemoval(TraktLibraryShow traktShow, List<FileLocal> episodes) { List<TraktEpisodeSync.Episode> episodeList = new List<TraktEpisodeSync.Episode>(); foreach (var season in traktShow.Seasons) { foreach (var episode in season.Episodes) { var query = episodes.Where(e => e.AniDB_File != null && e.AniDB_File.AnimeSeries.TvDB_ID.ToString() == traktShow.SeriesId && e.AniDB_File.AnimeSeries.TvDB_Episodes.Where(t => !string.IsNullOrEmpty(t.Filename) && t.SeasonNumber == season.Season && t.EpisodeNumber == episode).Count() == 1).ToList(); if (query.Count == 0) { // we dont have the episode anymore TraktLogger.Info("{0} - {1}x{2} does not exist in local database, marked for removal from trakt", traktShow.ToString(), season.Season.ToString(), episode.ToString()); TraktEpisodeSync.Episode ep = new TraktEpisodeSync.Episode { EpisodeIndex = episode.ToString(), SeasonIndex = season.Season.ToString() }; episodeList.Add(ep); } } } if (episodeList.Count > 0) { TraktEpisodeSync syncData = new TraktEpisodeSync { UserName = TraktSettings.Username, Password = TraktSettings.Password, SeriesID = traktShow.SeriesId, EpisodeList = episodeList }; return syncData; } return null; }