public static void CheckForTraktSyncUpdate(bool forceRefresh) { if (ServerSettings.Trakt_SyncFrequency == ScheduledUpdateFrequency.Never && !forceRefresh) return; int freqHours = Utils.GetScheduledHours(ServerSettings.Trakt_SyncFrequency); // update the calendar every xxx hours ScheduledUpdateRepository repSched = new ScheduledUpdateRepository(); ScheduledUpdate sched = repSched.GetByUpdateType((int)ScheduledUpdateType.TraktSync); if (sched != null) { // if we have run this in the last xxx hours and are not forcing it, then exit TimeSpan tsLastRun = DateTime.Now - sched.LastUpdate; logger.Trace("Last Trakt Sync: {0} minutes ago", tsLastRun.TotalMinutes); if (tsLastRun.TotalHours < freqHours) { if (!forceRefresh) return; } } if (ServerSettings.Trakt_IsEnabled && !string.IsNullOrEmpty(ServerSettings.Trakt_AuthToken)) { CommandRequest_TraktSyncCollection cmd = new CommandRequest_TraktSyncCollection(false); cmd.Save(); } }
public static void CheckForMALUpdate(bool forceRefresh) { if (ServerSettings.AniDB_Anime_UpdateFrequency == ScheduledUpdateFrequency.Never && !forceRefresh) return; int freqHours = Utils.GetScheduledHours(ServerSettings.MAL_UpdateFrequency); // check for any updated anime info every 12 hours ScheduledUpdateRepository repSched = new ScheduledUpdateRepository(); AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); ScheduledUpdate sched = repSched.GetByUpdateType((int)ScheduledUpdateType.MALUpdate); 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; } } RunImport_ScanMAL(); if (sched == null) { sched = new ScheduledUpdate(); sched.UpdateType = (int)ScheduledUpdateType.MALUpdate; sched.UpdateDetails = ""; } sched.LastUpdate = DateTime.Now; repSched.Save(sched); }
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(); }
public static void CheckForAniDBFileUpdate(bool forceRefresh) { if (ServerSettings.AniDB_File_UpdateFrequency == ScheduledUpdateFrequency.Never && !forceRefresh) return; int freqHours = Utils.GetScheduledHours(ServerSettings.AniDB_File_UpdateFrequency); // check for any updated anime info every 12 hours ScheduledUpdateRepository repSched = new ScheduledUpdateRepository(); AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); ScheduledUpdate sched = repSched.GetByUpdateType((int)ScheduledUpdateType.AniDBFileUpdates); 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; } } UpdateAniDBFileData(true, false, false); // files which have been hashed, but don't have an associated episode VideoLocalRepository repVidLocals = new VideoLocalRepository(); List<VideoLocal> filesWithoutEpisode = repVidLocals.GetVideosWithoutEpisode(); foreach (VideoLocal vl in filesWithoutEpisode) { CommandRequest_ProcessFile cmd = new CommandRequest_ProcessFile(vl.VideoLocalID, true); cmd.Save(); } // now check for any files which have been manually linked and are less than 30 days old if (sched == null) { sched = new ScheduledUpdate(); sched.UpdateType = (int)ScheduledUpdateType.AniDBFileUpdates; sched.UpdateDetails = ""; } sched.LastUpdate = DateTime.Now; repSched.Save(sched); }
public static void CheckForMyListStatsUpdate(bool forceRefresh) { if (ServerSettings.AniDB_MyListStats_UpdateFrequency == ScheduledUpdateFrequency.Never && !forceRefresh) return; int freqHours = Utils.GetScheduledHours(ServerSettings.AniDB_MyListStats_UpdateFrequency); ScheduledUpdateRepository repSched = new ScheduledUpdateRepository(); ScheduledUpdate sched = repSched.GetByUpdateType((int)ScheduledUpdateType.AniDBMylistStats); if (sched != null) { // if we have run this in the last 24 hours and are not forcing it, then exit TimeSpan tsLastRun = DateTime.Now - sched.LastUpdate; logger.Trace("Last AniDB MyList Stats Update: {0} minutes ago", tsLastRun.TotalMinutes); if (tsLastRun.TotalHours < freqHours) { if (!forceRefresh) return; } } CommandRequest_UpdateMylistStats cmd = new CommandRequest_UpdateMylistStats(forceRefresh); cmd.Save(); }
public static void CheckForAnimeUpdate(bool forceRefresh) { if (ServerSettings.AniDB_Anime_UpdateFrequency == ScheduledUpdateFrequency.Never && !forceRefresh) return; int freqHours = Utils.GetScheduledHours(ServerSettings.AniDB_Anime_UpdateFrequency); // check for any updated anime info every 12 hours ScheduledUpdateRepository repSched = new ScheduledUpdateRepository(); AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); ScheduledUpdate sched = repSched.GetByUpdateType((int)ScheduledUpdateType.AniDBUpdates); 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; } } CommandRequest_GetUpdated cmd = new CommandRequest_GetUpdated(true); cmd.Save(); }
public static void CheckForCalendarUpdate(bool forceRefresh) { if (ServerSettings.AniDB_Calendar_UpdateFrequency == ScheduledUpdateFrequency.Never && !forceRefresh) return; int freqHours = Utils.GetScheduledHours(ServerSettings.AniDB_Calendar_UpdateFrequency); // update the calendar every 12 hours // we will always assume that an anime was downloaded via http first ScheduledUpdateRepository repSched = new ScheduledUpdateRepository(); AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); ScheduledUpdate sched = repSched.GetByUpdateType((int)ScheduledUpdateType.AniDBCalendar); 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; } } CommandRequest_GetCalendar cmd = new CommandRequest_GetCalendar(forceRefresh); cmd.Save(); }