Exemple #1
0
        public static SeriesIDs GetIDs(SVR_AnimeSeries ser)
        {
            // Shoko
            var ids = new SeriesIDs
            {
                ID            = ser.AnimeSeriesID,
                ParentGroup   = ser.AnimeGroupID,
                TopLevelGroup = ser.TopLevelAnimeGroup.AnimeGroupID,
            };

            // AniDB
            var anidbId = ser.GetAnime()?.AnimeID;

            if (anidbId.HasValue)
            {
                ids.AniDB = anidbId.Value;
            }

            // TvDB
            var tvdbIds = RepoFactory.CrossRef_AniDB_TvDB.GetByAnimeID(ser.AniDB_ID);

            if (tvdbIds.Any())
            {
                ids.TvDB.AddRange(tvdbIds.Select(a => a.TvDBID).Distinct());
            }

            // TODO: Cache the rest of these, so that they don't severely slow down the API

            // TMDB
            // TODO: make this able to support more than one, in fact move it to its own and remove CrossRef_Other
            var tmdbId = RepoFactory.CrossRef_AniDB_Other.GetByAnimeIDAndType(ser.AniDB_ID, CrossRefType.MovieDB);

            if (tmdbId != null && int.TryParse(tmdbId.CrossRefID, out int movieID))
            {
                ids.TMDB.Add(movieID);
            }

            // Trakt
            // var traktIds = RepoFactory.CrossRef_AniDB_TraktV2.GetByAnimeID(ser.AniDB_ID).Select(a => a.TraktID)
            //     .Distinct().ToList();
            // if (traktIds.Any()) ids.TraktTv.AddRange(traktIds);

            // MAL
            var malIds = RepoFactory.CrossRef_AniDB_MAL.GetByAnimeID(ser.AniDB_ID).Select(a => a.MALID).Distinct()
                         .ToList();

            if (malIds.Any())
            {
                ids.MAL.AddRange(malIds);
            }

            // TODO: AniList later
            return(ids);
        }
Exemple #2
0
        public static SeriesIDs GetIDs(SVR_AnimeSeries ser)
        {
            // Shoko
            var ids = new SeriesIDs {
                ID = ser.AnimeSeriesID
            };
            // AniDB
            var anime = ser.GetAnime();

            if (anime != null)
            {
                ids.AniDB = anime.AnimeID;
            }
            // TvDB
            var tvdbs = RepoFactory.CrossRef_AniDB_TvDB.GetByAnimeID(ser.AniDB_ID);

            if (tvdbs.Any())
            {
                ids.TvDB.AddRange(tvdbs.Select(a => a.TvDBID).Distinct());
            }
            // TODO Cache the rest of these, so that they don't severely slow down the API
            // MovieDB
            // TODO make this able to support more than one, in fact move it to its own and remove CrossRef_Other
            //var moviedb = RepoFactory.CrossRef_AniDB_Other.GetByAnimeIDAndType(ser.AniDB_ID, CrossRefType.MovieDB);
            //if (moviedb != null && int.TryParse(moviedb.CrossRefID, out int movieID)) ids.MovieDB.Add(movieID);
            // Trakt
            //var traktids = RepoFactory.CrossRef_AniDB_TraktV2.GetByAnimeID(ser.AniDB_ID).Select(a => a.TraktID)
            //    .Distinct().ToList();
            //if (traktids.Any()) ids.TraktTv.AddRange(traktids);
            // MAL
            var malids = RepoFactory.CrossRef_AniDB_MAL.GetByAnimeID(ser.AniDB_ID).Select(a => a.MALID).Distinct()
                         .ToList();

            if (malids.Any())
            {
                ids.MAL.AddRange(malids);
            }
            // TODO AniList later
            return(ids);
        }