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

pull/193/head
Drewster727 9 years ago
parent 076a75b82f
commit ba06e8630f

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

@ -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,25 +255,33 @@ 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!
} }
if (setCache) try
{ {
Log.Trace("Plex Lib API Call"); if (setCache)
results = GetLibraries(authSettings, plexSettings); {
Log.Trace("Plex Lib API Call");
results = GetLibraries(authSettings, plexSettings);
Log.Trace("Plex Lib Cache Set Call"); Log.Trace("Plex Lib Cache Set Call");
if (results != null) if (results != null)
{
Cache.Set(CacheKeys.PlexLibaries, results, CacheKeys.TimeFrameMinutes.SchedulerCaching);
}
}
else
{ {
Cache.Set(CacheKeys.PlexLibaries, results, CacheKeys.TimeFrameMinutes.SchedulerCaching); Log.Trace("Plex Lib GetSet Call");
results = Cache.GetOrSet(CacheKeys.PlexLibaries, () => {
Log.Trace("Plex Lib API Call (inside getset)");
return GetLibraries(authSettings, plexSettings);
}, CacheKeys.TimeFrameMinutes.SchedulerCaching);
} }
} }
else catch (Exception ex)
{ {
Log.Trace("Plex Lib GetSet Call"); Log.Error(ex, "Failed to obtain Plex libraries");
results = Cache.GetOrSet(CacheKeys.PlexLibaries, () => {
Log.Trace("Plex Lib API Call (inside getset)");
return GetLibraries(authSettings, plexSettings);
}, CacheKeys.TimeFrameMinutes.SchedulerCaching);
} }
return results; return results;
} }

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

@ -63,10 +63,17 @@ 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");
var series = SonarrApi.GetSeries(settings.ApiKey, settings.FullUri); try
if (series != null)
{ {
Cache.Set(CacheKeys.SonarrQueued, series, CacheKeys.TimeFrameMinutes.SchedulerCaching); var series = SonarrApi.GetSeries(settings.ApiKey, settings.FullUri);
if (series != null)
{
Cache.Set(CacheKeys.SonarrQueued, series, CacheKeys.TimeFrameMinutes.SchedulerCaching);
}
}
catch (System.Exception ex)
{
Log.Error(ex, "Failed caching queued items from Sonarr");
} }
} }
} }

Loading…
Cancel
Save