Пример #1
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;
		}
Пример #2
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;
		}
Пример #3
0
		private AniDB_Anime SaveResultsForAnimeXML(ISession session, int animeID, bool downloadRelations, AniDBHTTPCommand_GetFullAnime getAnimeCmd)
		{
			AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
			AniDB_Anime anime = null;

			logger.Trace("cmdResult.Anime: {0}", getAnimeCmd.Anime);

			anime = repAnime.GetByAnimeID(session, animeID);
			if (anime == null)
				anime = new AniDB_Anime();
			anime.PopulateAndSaveFromHTTP(session, getAnimeCmd.Anime, getAnimeCmd.Episodes, getAnimeCmd.Titles, getAnimeCmd.Categories, getAnimeCmd.Tags,
				getAnimeCmd.Characters, getAnimeCmd.Relations, getAnimeCmd.SimilarAnime, getAnimeCmd.Recommendations, downloadRelations);

			// Request an image download
			CommandRequest_DownloadImage cmd = new CommandRequest_DownloadImage(anime.AniDB_AnimeID, JMMImageType.AniDB_Cover, false);
			cmd.Save(session);
			// create AnimeEpisode records for all episodes in this anime
			// only if we have a series
			AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
			AnimeSeries ser = repSeries.GetByAnimeID(session, animeID);
			if (ser != null)
			{
				ser.CreateAnimeEpisodes(session);
			}

            // update any files, that may have been linked
            /*CrossRef_File_EpisodeRepository repCrossRefs = new CrossRef_File_EpisodeRepository();
            repCrossRefs.GetByAnimeID(*/

			// update cached stats
			StatsCache.Instance.UpdateUsingAnime(session, anime.AnimeID);
			StatsCache.Instance.UpdateAnimeContract(session, anime.AnimeID);

			// download character images
			foreach (AniDB_Anime_Character animeChar in anime.GetAnimeCharacters(session))
			{
				AniDB_Character chr = animeChar.GetCharacter(session);
				if (chr == null) continue;

				if (ServerSettings.AniDB_DownloadCharacters)
				{
					if (!string.IsNullOrEmpty(chr.PosterPath) && !File.Exists(chr.PosterPath))
					{
						logger.Debug("Downloading character image: {0} - {1}({2}) - {3}", anime.MainTitle, chr.CharName, chr.CharID, chr.PosterPath);
						cmd = new CommandRequest_DownloadImage(chr.AniDB_CharacterID, JMMImageType.AniDB_Character, false);
						cmd.Save();
					}
				}

				if (ServerSettings.AniDB_DownloadCreators)
				{
					AniDB_Seiyuu seiyuu = chr.GetSeiyuu(session);
					if (seiyuu == null || string.IsNullOrEmpty(seiyuu.PosterPath)) continue;

					if (!File.Exists(seiyuu.PosterPath))
					{
						logger.Debug("Downloading seiyuu image: {0} - {1}({2}) - {3}", anime.MainTitle, seiyuu.SeiyuuName, seiyuu.SeiyuuID, seiyuu.PosterPath);
						cmd = new CommandRequest_DownloadImage(seiyuu.AniDB_SeiyuuID, JMMImageType.AniDB_Creator, false);
						cmd.Save();
					}
				}

			}

			return anime;
		}
Пример #4
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;
        }