示例#1
0
		public static void UpdateAllInfo(bool force)
		{
			CrossRef_AniDB_TvDBV2Repository repCrossRef = new CrossRef_AniDB_TvDBV2Repository();
			List<CrossRef_AniDB_TvDBV2> allCrossRefs = repCrossRef.GetAll();
			List<int> alreadyLinked = new List<int>();
			foreach (CrossRef_AniDB_TvDBV2 xref in allCrossRefs)
			{
				CommandRequest_TvDBUpdateSeriesAndEpisodes cmd = new CommandRequest_TvDBUpdateSeriesAndEpisodes(xref.TvDBID, force);
				cmd.Save();
			}

		}
示例#2
0
		public static void DownloadAllEpisodes(List<int> tvDBIDs)
		{
			foreach (int tvid in tvDBIDs)
			{
				CommandRequest_TvDBUpdateSeriesAndEpisodes cmd = new CommandRequest_TvDBUpdateSeriesAndEpisodes(tvid, false);
				cmd.Save();
			}
		}
示例#3
0
文件: Importer.cs 项目: dizzydezz/jmm
		public static void CheckForTvDBUpdates(bool forceRefresh)
		{
			if (ServerSettings.TvDB_UpdateFrequency == ScheduledUpdateFrequency.Never && !forceRefresh) return;
			int freqHours = Utils.GetScheduledHours(ServerSettings.TvDB_UpdateFrequency);

			// update tvdb info every 12 hours
			ScheduledUpdateRepository repSched = new ScheduledUpdateRepository();

			ScheduledUpdate sched = repSched.GetByUpdateType((int)ScheduledUpdateType.TvDBInfo);
			if (sched != null)
			{
				// if we have run this in the last 12 hours and are not forcing it, then exit
				TimeSpan tsLastRun = DateTime.Now - sched.LastUpdate;
				if (tsLastRun.TotalHours < freqHours)
				{
					if (!forceRefresh) return;
				}
			}

			List<int> tvDBIDs = new List<int>();
			bool tvDBOnline = false;
			string serverTime = JMMService.TvdbHelper.IncrementalTvDBUpdate(ref tvDBIDs, ref tvDBOnline);

			if (tvDBOnline)
			{
				foreach (int tvid in tvDBIDs)
				{
					// download and update series info, episode info and episode images
					// will also download fanart, posters and wide banners
					CommandRequest_TvDBUpdateSeriesAndEpisodes cmdSeriesEps = new CommandRequest_TvDBUpdateSeriesAndEpisodes(tvid, false);
					cmdSeriesEps.Save();
				}
			}

			if (sched == null)
			{
				sched = new ScheduledUpdate();
				sched.UpdateType = (int)ScheduledUpdateType.TvDBInfo;
			}

			sched.LastUpdate = DateTime.Now;
			sched.UpdateDetails = serverTime;
			repSched.Save(sched);

			TvDBHelper.ScanForMatches();
		}
示例#4
0
		public static string LinkAniDBTvDB(int animeID, enEpisodeType aniEpType, int aniEpNumber, int tvDBID, int tvSeasonNumber, int tvEpNumber, bool excludeFromWebCache)
		{
			using (var session = JMMService.SessionFactory.OpenSession())
			{
				CrossRef_AniDB_TvDBV2Repository repCrossRef = new CrossRef_AniDB_TvDBV2Repository();
				List<CrossRef_AniDB_TvDBV2> xrefTemps = repCrossRef.GetByAnimeIDEpTypeEpNumber(session, animeID, (int)aniEpType, aniEpNumber);
				if (xrefTemps != null && xrefTemps.Count > 0)
				{
                    foreach (CrossRef_AniDB_TvDBV2 xrefTemp in xrefTemps)
                    {
                        // delete the existing one if we are updating
                        TvDBHelper.RemoveLinkAniDBTvDB(xrefTemp.AnimeID, (enEpisodeType)xrefTemp.AniDBStartEpisodeType, xrefTemp.AniDBStartEpisodeNumber,
                            xrefTemp.TvDBID, xrefTemp.TvDBSeasonNumber, xrefTemp.TvDBStartEpisodeNumber);
                    }
				}

				// check if we have this information locally
				// if not download it now
				TvDB_SeriesRepository repSeries = new TvDB_SeriesRepository();
				TvDB_Series tvSeries = repSeries.GetByTvDBID(tvDBID);
				if (tvSeries == null)
				{
					// we download the series info here just so that we have the basic info in the
					// database before the queued task runs later
					tvSeries = GetSeriesInfoOnline(tvDBID);
				}

				// download and update series info, episode info and episode images
				// will also download fanart, posters and wide banners
				CommandRequest_TvDBUpdateSeriesAndEpisodes cmdSeriesEps = new CommandRequest_TvDBUpdateSeriesAndEpisodes(tvDBID, false);
				cmdSeriesEps.Save();

				CrossRef_AniDB_TvDBV2 xref = repCrossRef.GetByTvDBID(session, tvDBID, tvSeasonNumber, tvEpNumber, animeID, (int)aniEpType, aniEpNumber);
				if (xref == null)
					xref = new CrossRef_AniDB_TvDBV2();

				xref.AnimeID = animeID;
				xref.AniDBStartEpisodeType = (int)aniEpType;
				xref.AniDBStartEpisodeNumber = aniEpNumber;

				xref.TvDBID = tvDBID;
				xref.TvDBSeasonNumber = tvSeasonNumber;
				xref.TvDBStartEpisodeNumber = tvEpNumber;
				if (tvSeries != null)
					xref.TvDBTitle = tvSeries.SeriesName;

				if (excludeFromWebCache)
					xref.CrossRefSource = (int)CrossRefSource.WebCache;
				else
					xref.CrossRefSource = (int)CrossRefSource.User;

				repCrossRef.Save(xref);

				StatsCache.Instance.UpdateUsingAnime(animeID);

				logger.Trace("Changed tvdb association: {0}", animeID);

				if (!excludeFromWebCache)
				{
					CommandRequest_WebCacheSendXRefAniDBTvDB req = new CommandRequest_WebCacheSendXRefAniDBTvDB(xref.CrossRef_AniDB_TvDBV2ID);
					req.Save();
				}

                if (ServerSettings.Trakt_IsEnabled && !string.IsNullOrEmpty(ServerSettings.Trakt_AuthToken))
                {
                    CrossRef_AniDB_TraktV2Repository repTraktXrefs = new CrossRef_AniDB_TraktV2Repository();
                    if (repTraktXrefs.GetByAnimeID(animeID).Count == 0)
                    {
                        // check for Trakt associations
                        CommandRequest_TraktSearchAnime cmd2 = new CommandRequest_TraktSearchAnime(animeID, false);
                        cmd2.Save(session);
                    }
                }
            }

			return "";
		}
示例#5
0
        public static string LinkAniDBTvDB(int animeID, enEpisodeType aniEpType, int aniEpNumber, int tvDBID,
            int tvSeasonNumber, int tvEpNumber, bool excludeFromWebCache, bool additiveLink=false)
        {
            using (var session = DatabaseFactory.SessionFactory.OpenSession())
            {
                if(!additiveLink)
                    // remove all current links
                    RemoveAllAniDBTvDBLinks(session.Wrap(), animeID);

                // check if we have this information locally
                // if not download it now
                TvDB_Series tvSeries = RepoFactory.TvDB_Series.GetByTvDBID(tvDBID);
                if (tvSeries == null)
                {
                    // we download the series info here just so that we have the basic info in the
                    // database before the queued task runs later
                    tvSeries = GetSeriesInfoOnline(tvDBID);
                }

                // download and update series info, episode info and episode images
                // will also download fanart, posters and wide banners
                CommandRequest_TvDBUpdateSeriesAndEpisodes cmdSeriesEps =
                    new CommandRequest_TvDBUpdateSeriesAndEpisodes(tvDBID,
                        false);
                //Optimize for batch updates, if there are a lot of LinkAniDBTvDB commands queued
                //this will cause only one updateSeriesAndEpisodes command to be created
                if (RepoFactory.CommandRequest.GetByCommandID(cmdSeriesEps.CommandID) == null)
                {
                    cmdSeriesEps.Save();
                }

                CrossRef_AniDB_TvDBV2 xref = RepoFactory.CrossRef_AniDB_TvDBV2.GetByTvDBID(session, tvDBID, tvSeasonNumber, tvEpNumber,
                    animeID,
                    (int) aniEpType, aniEpNumber);
                if (xref == null)
                    xref = new CrossRef_AniDB_TvDBV2();

                xref.AnimeID = animeID;
                xref.AniDBStartEpisodeType = (int) aniEpType;
                xref.AniDBStartEpisodeNumber = aniEpNumber;

                xref.TvDBID = tvDBID;
                xref.TvDBSeasonNumber = tvSeasonNumber;
                xref.TvDBStartEpisodeNumber = tvEpNumber;
                if (tvSeries != null)
                    xref.TvDBTitle = tvSeries.SeriesName;

                if (excludeFromWebCache)
                    xref.CrossRefSource = (int) CrossRefSource.WebCache;
                else
                    xref.CrossRefSource = (int) CrossRefSource.User;

                RepoFactory.CrossRef_AniDB_TvDBV2.Save(xref);

                AniDB_Anime.UpdateStatsByAnimeID(animeID);

                logger.Trace("Changed tvdb association: {0}", animeID);

                if (!excludeFromWebCache)
                {
                    CommandRequest_WebCacheSendXRefAniDBTvDB req =
                        new CommandRequest_WebCacheSendXRefAniDBTvDB(xref.CrossRef_AniDB_TvDBV2ID);
                    req.Save();
                }

                if (ServerSettings.Trakt_IsEnabled && !string.IsNullOrEmpty(ServerSettings.Trakt_AuthToken))
                {
                    if (RepoFactory.CrossRef_AniDB_TraktV2.GetByAnimeID(animeID).Count == 0)
                    {
                        // check for Trakt associations
                        CommandRequest_TraktSearchAnime cmd2 = new CommandRequest_TraktSearchAnime(animeID, false);
                        cmd2.Save(session);
                    }
                }
            }

            return "";
        }