public static void ScanForMatches() { IReadOnlyList <SVR_AnimeSeries> allSeries = RepoFactory.AnimeSeries.GetAll(); foreach (SVR_AnimeSeries ser in allSeries) { SVR_AniDB_Anime anime = ser.GetAnime(); if (anime == null) { continue; } if (anime.IsMovieDBLinkDisabled()) { continue; } // don't scan if it is associated on the TvDB if (anime.GetCrossRefTvDBV2().Count > 0) { continue; } // don't scan if it is associated on the MovieDB if (anime.GetCrossRefMovieDB() != null) { continue; } // don't scan if it is not a movie if (!anime.GetSearchOnMovieDB()) { continue; } logger.Trace("Found anime movie without MovieDB association: " + anime.MainTitle); CommandRequest_MovieDBSearchAnime cmd = new CommandRequest_MovieDBSearchAnime(ser.AniDB_ID, false); cmd.Save(); } }
public CL_AniDB_AnimeCrossRefs GetCrossRefDetails(int animeID) { CL_AniDB_AnimeCrossRefs result = new CL_AniDB_AnimeCrossRefs { CrossRef_AniDB_TvDB = new List <CrossRef_AniDB_TvDBV2>(), TvDBSeries = new List <TvDB_Series>(), TvDBEpisodes = new List <TvDB_Episode>(), TvDBImageFanarts = new List <TvDB_ImageFanart>(), TvDBImagePosters = new List <TvDB_ImagePoster>(), TvDBImageWideBanners = new List <TvDB_ImageWideBanner>(), CrossRef_AniDB_MovieDB = null, MovieDBMovie = null, MovieDBFanarts = new List <MovieDB_Fanart>(), MovieDBPosters = new List <MovieDB_Poster>(), CrossRef_AniDB_MAL = null, CrossRef_AniDB_Trakt = new List <CrossRef_AniDB_TraktV2>(), TraktShows = new List <CL_Trakt_Show>(), AnimeID = animeID }; try { using (var session = DatabaseFactory.SessionFactory.OpenSession()) { SVR_AniDB_Anime anime = RepoFactory.AniDB_Anime.GetByAnimeID(animeID); if (anime == null) { return(result); } var xrefs = RepoFactory.CrossRef_AniDB_TvDB.GetV2LinksFromAnime(animeID); // TvDB result.CrossRef_AniDB_TvDB = xrefs; foreach (TvDB_Episode ep in anime.GetTvDBEpisodes()) { result.TvDBEpisodes.Add(ep); } foreach (var xref in xrefs.DistinctBy(a => a.TvDBID)) { TvDB_Series ser = RepoFactory.TvDB_Series.GetByTvDBID(xref.TvDBID); if (ser != null) { result.TvDBSeries.Add(ser); } foreach (TvDB_ImageFanart fanart in RepoFactory.TvDB_ImageFanart.GetBySeriesID(xref.TvDBID)) { result.TvDBImageFanarts.Add(fanart); } foreach (TvDB_ImagePoster poster in RepoFactory.TvDB_ImagePoster.GetBySeriesID(xref.TvDBID)) { result.TvDBImagePosters.Add(poster); } foreach (TvDB_ImageWideBanner banner in RepoFactory.TvDB_ImageWideBanner.GetBySeriesID(xref .TvDBID)) { result.TvDBImageWideBanners.Add(banner); } } // Trakt foreach (CrossRef_AniDB_TraktV2 xref in anime.GetCrossRefTraktV2(session)) { result.CrossRef_AniDB_Trakt.Add(xref); Trakt_Show show = RepoFactory.Trakt_Show.GetByTraktSlug(session, xref.TraktID); if (show != null) { result.TraktShows.Add(show.ToClient()); } } // MovieDB CrossRef_AniDB_Other xrefMovie = anime.GetCrossRefMovieDB(); result.CrossRef_AniDB_MovieDB = xrefMovie; result.MovieDBMovie = anime.GetMovieDBMovie(); foreach (MovieDB_Fanart fanart in anime.GetMovieDBFanarts()) { if (fanart.ImageSize.Equals(Shoko.Models.Constants.MovieDBImageSize.Original, StringComparison.InvariantCultureIgnoreCase)) { result.MovieDBFanarts.Add(fanart); } } foreach (MovieDB_Poster poster in anime.GetMovieDBPosters()) { if (poster.ImageSize.Equals(Shoko.Models.Constants.MovieDBImageSize.Original, StringComparison.InvariantCultureIgnoreCase)) { result.MovieDBPosters.Add(poster); } } // MAL List <CrossRef_AniDB_MAL> xrefMAL = anime.GetCrossRefMAL(); if (xrefMAL == null) { result.CrossRef_AniDB_MAL = null; } else { result.CrossRef_AniDB_MAL = new List <CrossRef_AniDB_MAL>(); foreach (CrossRef_AniDB_MAL xrefTemp in xrefMAL) { result.CrossRef_AniDB_MAL.Add(xrefTemp); } } } return(result); } catch (Exception ex) { logger.Error(ex, ex.ToString()); return(result); } }
public CL_AniDB_AnimeCrossRefs GetCrossRefDetails(int animeID) { CL_AniDB_AnimeCrossRefs result = new CL_AniDB_AnimeCrossRefs { CrossRef_AniDB_TvDB = new List <CL_CrossRef_AniDB_Provider>(), TvDBSeries = new List <TvDB_Series>(), TvDBEpisodes = new List <TvDB_Episode>(), TvDBImageFanarts = new List <TvDB_ImageFanart>(), TvDBImagePosters = new List <TvDB_ImagePoster>(), TvDBImageWideBanners = new List <TvDB_ImageWideBanner>(), CrossRef_AniDB_MovieDB = null, MovieDBMovie = null, MovieDBFanarts = new List <MovieDB_Fanart>(), MovieDBPosters = new List <MovieDB_Poster>(), CrossRef_AniDB_MAL = null, CrossRef_AniDB_Trakt = new List <CL_CrossRef_AniDB_Provider>(), TraktShows = new List <CL_Trakt_Show>(), AnimeID = animeID }; try { SVR_AniDB_Anime anime = Repo.Instance.AniDB_Anime.GetByID(animeID); if (anime == null) { return(result); } var xrefs = Repo.Instance.CrossRef_AniDB_Provider.GetByAnimeIDAndType(animeID, CrossRefType.TvDB).Select(a => a.ToClient()).ToList(); // TvDB result.CrossRef_AniDB_TvDB = xrefs; foreach (TvDB_Episode ep in anime.GetTvDBEpisodes()) { result.TvDBEpisodes.Add(ep); } foreach (var xref in xrefs.DistinctBy(a => a.CrossRefID)) { TvDB_Series ser = Repo.Instance.TvDB_Series.GetByTvDBID(int.Parse(xref.CrossRefID)); if (ser != null) { result.TvDBSeries.Add(ser); } foreach (TvDB_ImageFanart fanart in Repo.Instance.TvDB_ImageFanart.GetBySeriesID(int.Parse(xref.CrossRefID))) { result.TvDBImageFanarts.Add(fanart); } foreach (TvDB_ImagePoster poster in Repo.Instance.TvDB_ImagePoster.GetBySeriesID(int.Parse(xref.CrossRefID))) { result.TvDBImagePosters.Add(poster); } foreach (TvDB_ImageWideBanner banner in Repo.Instance.TvDB_ImageWideBanner.GetBySeriesID(int.Parse(xref.CrossRefID))) { result.TvDBImageWideBanners.Add(banner); } } // Trakt foreach (CL_CrossRef_AniDB_Provider xref in anime.GetCrossRefTraktV2().Select(a => a.ToClient())) { result.CrossRef_AniDB_Trakt.Add(xref); Trakt_Show show = Repo.Instance.Trakt_Show.GetByTraktSlug(xref.CrossRefID); if (show != null) { result.TraktShows.Add(show.ToClient()); } } // MovieDB SVR_CrossRef_AniDB_Provider xrefMovie = anime.GetCrossRefMovieDB(); result.CrossRef_AniDB_MovieDB = xrefMovie; result.MovieDBMovie = anime.GetMovieDBMovie(); foreach (MovieDB_Fanart fanart in anime.GetMovieDBFanarts()) { if (fanart.ImageSize.Equals(Shoko.Models.Constants.MovieDBImageSize.Original, StringComparison.InvariantCultureIgnoreCase)) { result.MovieDBFanarts.Add(fanart); } } foreach (MovieDB_Poster poster in anime.GetMovieDBPosters()) { if (poster.ImageSize.Equals(Shoko.Models.Constants.MovieDBImageSize.Original, StringComparison.InvariantCultureIgnoreCase)) { result.MovieDBPosters.Add(poster); } } // MAL List <SVR_CrossRef_AniDB_Provider> xrefMAL = anime.GetCrossRefMAL(); if (xrefMAL == null) { result.CrossRef_AniDB_MAL = null; } else { result.CrossRef_AniDB_MAL = new List <CrossRef_AniDB_Provider>(); foreach (SVR_CrossRef_AniDB_Provider xrefTemp in xrefMAL) { result.CrossRef_AniDB_MAL.Add(xrefTemp); } } return(result); } catch (Exception ex) { logger.Error(ex, ex.ToString()); return(result); } }