public LinkingEpisode(TvDB_Episode e, LinkingProvider prov) { Id = e.TvDB_EpisodeID.ToString(); Title = e.EpisodeName; Season = e.SeasonNumber; Number = e.EpisodeNumber; AirDate = e.AirDate; SeriesId = e.SeriesID.ToString(); Original = e; _provider = prov; }
public LinkingEpisode(Trakt_Episode e, LinkingProvider prov) { Id = e.Trakt_EpisodeID.ToString(); Title = e.Title; Season = e.Season; Number = e.EpisodeNumber; AirDate = null; SeriesId = e.Trakt_ShowID.ToString(); Original = e; _provider = prov; }
public static List <(AniDB_Episode AniDB, LinkingEpisode Cross, MatchRating Rating)> GetEpisodeMatches(int animeID, string seriescrossId, CrossRefType crossType) { /* These all apply to normal episodes mainly. * It will fail for specials (BD will cause most to have the same air date). * * We will keep a running score to determine how accurate we believe the link is. Lower is better * Ideal score is 1 to 1 match with perfect air dates * * if the episodes are 1-1: * Try to match air date. * if no match: * match to the next episode after the previous match (starting at one) * if two episodes air on the same day: * match in order of episode, grouped by air date * * if the episodes are not 1-1: * try to match air date. * group episodes in order by air date * * if two episodes air on the same day on both sides: * split them as equally as possible, these will likely need manually overriden * if no match: * if all episodes belong to the same season: * split episodes equally and increment from previous match. these will almost definitely need overriden * else: * increment and hope for the best... */ // Get All AniDB and TvDB episodes for a series, normal and specials done separately // Due to fun season splitting on TvDB, // we need extra logic to determine if a series is one or more seasons // Get TvDB first, if we can't get the episodes, then there's no valid link if ((string.IsNullOrEmpty(seriescrossId)) || seriescrossId == "0") { return(new List <(AniDB_Episode AniDB, LinkingEpisode cross, MatchRating Rating)>()); } LinkingProvider provider = new LinkingProvider(crossType); List <LinkingEpisode> tveps = provider.GetAll(seriescrossId); List <LinkingEpisode> tvepsNormal = tveps.Where(a => a.Season != 0).OrderBy(a => a.Season) .ThenBy(a => a.Number).ToList(); List <LinkingEpisode> tvepsSpecial = tveps.Where(a => a.Season == 0).OrderBy(a => a.Number).ToList(); // Get AniDB List <AniDB_Episode> anieps = Repo.Instance.AniDB_Episode.GetByAnimeID(animeID); List <AniDB_Episode> aniepsNormal = anieps.Where(a => a.EpisodeType == (int)EpisodeType.Episode) .OrderBy(a => a.EpisodeNumber).ToList(); SVR_AniDB_Anime anime = Repo.Instance.AniDB_Anime.GetByID(animeID); List <(AniDB_Episode, LinkingEpisode, MatchRating)> matches = new List <(AniDB_Episode, LinkingEpisode, MatchRating)>(); // Try to match OVAs if ((anime?.AnimeType == (int)AnimeType.OVA || anime?.AnimeType == (int)AnimeType.Movie || anime?.AnimeType == (int)AnimeType.TVSpecial) && aniepsNormal.Count > 0 && tvepsSpecial.Count > 0) { TryToMatchSpeicalsToCross(aniepsNormal, tvepsSpecial, ref matches); } // Only try to match normal episodes if this is a series if (anime?.AnimeType != (int)AnimeType.Movie && aniepsNormal.Count > 0 && tvepsNormal.Count > 0) { TryToMatchNormalEpisodesToCross(aniepsNormal, tvepsNormal, anime?.EndDate == null, crossType, ref matches); } // Specials. We aren't going to try too hard here. // We'll try by titles and dates, but we'll rely mostly on overrides List <AniDB_Episode> aniepsSpecial = anieps.Where(a => a.EpisodeType == (int)EpisodeType.Special) .OrderBy(a => a.EpisodeNumber).ToList(); if (aniepsSpecial.Count > 0 && tvepsSpecial.Count > 0) { TryToMatchSpeicalsToCross(aniepsSpecial, tvepsSpecial, ref matches); } return(matches); }