コード例 #1
0
        public AniDB_Anime GetAnimeInfoHTTP(ISession session, int animeID, bool forceRefresh, bool downloadRelations)
        {
            //if (!Login()) return null;

            AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
            AniDB_Anime           anime    = null;

            bool skip = true;

            if (forceRefresh)
            {
                skip = false;
            }
            else
            {
                anime = repAnime.GetByAnimeID(session, animeID);
                if (anime == null)
                {
                    skip = false;
                }
            }

            if (skip)
            {
                if (anime == null)
                {
                    anime = repAnime.GetByAnimeID(session, animeID);
                }

                return(anime);
            }

            AniDBHTTPCommand_GetFullAnime getAnimeCmd = null;

            lock (lockAniDBConnections)
            {
                Pause();

                getAnimeCmd = new AniDBHTTPCommand_GetFullAnime();
                getAnimeCmd.Init(animeID, false, forceRefresh, false);
                getAnimeCmd.Process();
            }


            if (getAnimeCmd.Anime != null)
            {
                anime = SaveResultsForAnimeXML(session, animeID, downloadRelations, getAnimeCmd);

                if (forceRefresh)
                {
                    CommandRequest_Azure_SendAnimeFull cmdAzure = new CommandRequest_Azure_SendAnimeFull(anime.AnimeID);
                    cmdAzure.Save(session);
                }
            }

            return(anime);
        }
コード例 #2
0
        public AniDB_Anime GetAnimeInfoHTTP(ISession session, int animeID, bool forceRefresh, bool downloadRelations)
        {
            //if (!Login()) return null;

            AniDB_Anime     anime          = null;
            ISessionWrapper sessionWrapper = session.Wrap();

            bool skip = true;

            if (forceRefresh)
            {
                skip = false;
            }
            else
            {
                anime = RepoFactory.AniDB_Anime.GetByAnimeID(sessionWrapper, animeID);
                if (anime == null)
                {
                    skip = false;
                }
            }

            if (skip)
            {
                if (anime == null)
                {
                    anime = RepoFactory.AniDB_Anime.GetByAnimeID(sessionWrapper, animeID);
                }

                return(anime);
            }

            AniDBHTTPCommand_GetFullAnime getAnimeCmd = null;

            lock (lockAniDBConnections)
            {
                getAnimeCmd = new AniDBHTTPCommand_GetFullAnime();
                getAnimeCmd.Init(animeID, false, forceRefresh, false);
                getAnimeCmd.Process();
            }


            if (getAnimeCmd.Anime != null)
            {
                anime = SaveResultsForAnimeXML(session, animeID, downloadRelations, getAnimeCmd);
                //this endpoint is not working, so comenting...

/*
 *              if (forceRefresh)
 *              {
 *                  CommandRequest_Azure_SendAnimeFull cmdAzure = new CommandRequest_Azure_SendAnimeFull(anime.AnimeID);
 *                  cmdAzure.Save(session);
 *              }*/
            }

            return(anime);
        }
コード例 #3
0
        public AniDB_Anime GetAnimeInfoHTTPFromCache(ISession session, int animeID, bool downloadRelations)
        {
            AniDBHTTPCommand_GetFullAnime getAnimeCmd = null;

            lock (lockAniDBConnections)
            {
                getAnimeCmd = new AniDBHTTPCommand_GetFullAnime();
                getAnimeCmd.Init(animeID, false, false, true);
                getAnimeCmd.Process();
            }

            AniDB_Anime anime = null;

            if (getAnimeCmd.Anime != null)
            {
                anime = SaveResultsForAnimeXML(session, animeID, downloadRelations, getAnimeCmd);
            }
            return(anime);
        }
コード例 #4
0
        public static void PopulateAniDBEpisodeDescriptions()
        {
            int i    = 0;
            var list = RepoFactory.AniDB_Episode.GetAll().Where(a => string.IsNullOrEmpty(a.Description))
                       .Select(a => a.AnimeID).Distinct().ToList();

            foreach (var animeID in list)
            {
                if (i % 10 == 0)
                {
                    ServerState.Instance.CurrentSetupStatus = string.Format(
                        Commons.Properties.Resources.Database_Validating, "Populating Episode Descriptions from Cache",
                        $" {i}/{list.Count}");
                }
                i++;
                try
                {
                    var getAnimeCmd = new AniDBHTTPCommand_GetFullAnime();
                    getAnimeCmd.Init(animeID, false, false, true);
                    var result = getAnimeCmd.Process();
                    if (result == enHelperActivityType.Banned_555 || result == enHelperActivityType.NoSuchAnime)
                    {
                        continue;
                    }
                    if (getAnimeCmd.Anime == null)
                    {
                        continue;
                    }
                    using (var session = DatabaseFactory.SessionFactory.OpenSession())
                    {
                        ShokoService.AnidbProcessor.SaveResultsForAnimeXML(session, animeID, false, getAnimeCmd);
                    }
                }
                catch (Exception e)
                {
                    logger.Error(
                        $"There was an error Populating AniDB_Episode Descriptions for AniDB_Anime {animeID}, Update the Series' AniDB Info for a full stack: {e.Message}");
                }
            }
        }