示例#1
0
        private static TvDB_Episode GetTvDBEpisodeFromAniDB(ISession session, AniDB_Episode aep, CrossRef_AniDB_TvDBV2 xref_tvdb2)
        {
            int epnumber = (aep.EpisodeNumber + xref_tvdb2.TvDBStartEpisodeNumber - 1) -
                           (xref_tvdb2.AniDBStartEpisodeNumber - 1);
            TvDB_Episode        tvep     = null;
            int                 season   = xref_tvdb2.TvDBSeasonNumber;
            List <TvDB_Episode> tvdb_eps = RepoFactory.TvDB_Episode.GetBySeriesIDAndSeasonNumber(xref_tvdb2.TvDBID, season);

            tvep = tvdb_eps.Find(a => a.EpisodeNumber == epnumber);
            if (tvep != null)
            {
                return(tvep);
            }

            int lastSeason           = RepoFactory.TvDB_Episode.getLastSeasonForSeries(xref_tvdb2.TvDBID);
            int previousSeasonsCount = 0;

            // we checked once, so increment the season
            season++;
            previousSeasonsCount += tvdb_eps.Count;
            do
            {
                if (season == 0)
                {
                    break;                  // Specials will often be wrong
                }
                if (season > lastSeason)
                {
                    break;
                }
                if (epnumber - previousSeasonsCount <= 0)
                {
                    break;
                }
                // This should be 1 or 0, hopefully 1
                tvdb_eps = RepoFactory.TvDB_Episode.GetBySeriesIDAndSeasonNumber(xref_tvdb2.TvDBID, season);
                tvep     = tvdb_eps.Find(a => a.EpisodeNumber == epnumber - previousSeasonsCount);

                AddCrossRef_AniDB_TvDBV2(session, aep.AnimeID, previousSeasonsCount + 1, xref_tvdb2.TvDBID, season, xref_tvdb2.GetTvDBSeries()?.SeriesName ?? "");

                if (tvep != null)
                {
                    break;
                }
                previousSeasonsCount += tvdb_eps.Count;
                season++;
            } while (true);
            return(tvep);
        }
示例#2
0
 public static TvDB_Series GetTvDBSeries(this CrossRef_AniDB_TvDBV2 cross, ISessionWrapper session)
 {
     return(RepoFactory.TvDB_Series.GetByTvDBID(session, cross.TvDBID));
 }