additional cacher error handling + don't bother checking the requests when we don't get data back from plex

This commit is contained in:
Drewster727 2016-04-21 09:00:06 -05:00
parent 076a75b82f
commit ba06e8630f
4 changed files with 60 additions and 24 deletions

View file

@ -62,12 +62,19 @@ namespace PlexRequests.Services.Jobs
if (settings.Enabled) if (settings.Enabled)
{ {
Log.Trace("Getting all movies from CouchPotato"); Log.Trace("Getting all movies from CouchPotato");
try
{
var movies = CpApi.GetMovies(settings.FullUri, settings.ApiKey, new[] { "active" }); var movies = CpApi.GetMovies(settings.FullUri, settings.ApiKey, new[] { "active" });
if (movies != null) if (movies != null)
{ {
Cache.Set(CacheKeys.CouchPotatoQueued, movies, CacheKeys.TimeFrameMinutes.SchedulerCaching); Cache.Set(CacheKeys.CouchPotatoQueued, movies, CacheKeys.TimeFrameMinutes.SchedulerCaching);
} }
} }
catch (System.Exception ex)
{
Log.Error(ex, "Failed caching queued items from CouchPotato");
}
}
} }
// we do not want to set here... // we do not want to set here...

View file

@ -75,6 +75,13 @@ namespace PlexRequests.Services.Jobs
} }
var libraries = CachedLibraries(authSettings, plexSettings, true); //force setting the cache (10 min intervals via scheduler) var libraries = CachedLibraries(authSettings, plexSettings, true); //force setting the cache (10 min intervals via scheduler)
if (libraries == null || !libraries.Any())
{
Log.Info("Did not find any libraries in Plex.");
return;
}
var movies = GetPlexMovies().ToArray(); var movies = GetPlexMovies().ToArray();
var shows = GetPlexTvShows().ToArray(); var shows = GetPlexTvShows().ToArray();
var albums = GetPlexAlbums().ToArray(); var albums = GetPlexAlbums().ToArray();
@ -248,6 +255,8 @@ namespace PlexRequests.Services.Jobs
return results; // don't error out here, just let it go! return results; // don't error out here, just let it go!
} }
try
{
if (setCache) if (setCache)
{ {
Log.Trace("Plex Lib API Call"); Log.Trace("Plex Lib API Call");
@ -267,6 +276,12 @@ namespace PlexRequests.Services.Jobs
return GetLibraries(authSettings, plexSettings); return GetLibraries(authSettings, plexSettings);
}, CacheKeys.TimeFrameMinutes.SchedulerCaching); }, CacheKeys.TimeFrameMinutes.SchedulerCaching);
} }
}
catch (Exception ex)
{
Log.Error(ex, "Failed to obtain Plex libraries");
}
return results; return results;
} }

View file

@ -62,12 +62,19 @@ namespace PlexRequests.Services.Jobs
if (settings.Enabled) if (settings.Enabled)
{ {
Log.Trace("Getting all shows from SickRage"); Log.Trace("Getting all shows from SickRage");
try
{
var shows = SrApi.GetShows(settings.ApiKey, settings.FullUri); var shows = SrApi.GetShows(settings.ApiKey, settings.FullUri);
if (shows != null) if (shows != null)
{ {
Cache.Set(CacheKeys.SickRageQueued, shows.Result, CacheKeys.TimeFrameMinutes.SchedulerCaching); Cache.Set(CacheKeys.SickRageQueued, shows.Result, CacheKeys.TimeFrameMinutes.SchedulerCaching);
} }
} }
catch (System.Exception ex)
{
Log.Error(ex, "Failed caching queued items from SickRage");
}
}
} }
// we do not want to set here... // we do not want to set here...

View file

@ -63,12 +63,19 @@ namespace PlexRequests.Services.Jobs
if (settings.Enabled) if (settings.Enabled)
{ {
Log.Trace("Getting all tv series from Sonarr"); Log.Trace("Getting all tv series from Sonarr");
try
{
var series = SonarrApi.GetSeries(settings.ApiKey, settings.FullUri); var series = SonarrApi.GetSeries(settings.ApiKey, settings.FullUri);
if (series != null) if (series != null)
{ {
Cache.Set(CacheKeys.SonarrQueued, series, CacheKeys.TimeFrameMinutes.SchedulerCaching); Cache.Set(CacheKeys.SonarrQueued, series, CacheKeys.TimeFrameMinutes.SchedulerCaching);
} }
} }
catch (System.Exception ex)
{
Log.Error(ex, "Failed caching queued items from Sonarr");
}
}
} }
// we do not want to set here... // we do not want to set here...