示例#1
0
		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();
		}
示例#2
0
		public static void RunImport_ScanTvDB()
		{
			TvDBHelper.ScanForMatches();
		}