mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
A bit more error handling #32
This commit is contained in:
parent
8a3576456c
commit
450fda6070
1 changed files with 44 additions and 26 deletions
|
@ -112,7 +112,7 @@ namespace PlexRequests.Services
|
||||||
matchResult = MovieTvSearch(results, r.Title, releaseDate);
|
matchResult = MovieTvSearch(results, r.Title, releaseDate);
|
||||||
break;
|
break;
|
||||||
case RequestType.Album:
|
case RequestType.Album:
|
||||||
matchResult = MusicSearch(results, r.Title, r.ArtistName);
|
matchResult = AlbumSearch(results, r.Title, r.ArtistName);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
|
@ -168,7 +168,7 @@ namespace PlexRequests.Services
|
||||||
case PlexType.TvShow:
|
case PlexType.TvShow:
|
||||||
return MovieTvSearch(results, title, year);
|
return MovieTvSearch(results, title, year);
|
||||||
case PlexType.Music:
|
case PlexType.Music:
|
||||||
return MusicSearch(results, title, artist);
|
return AlbumSearch(results, title, artist);
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException(nameof(type), type, null);
|
throw new ArgumentOutOfRangeException(nameof(type), type, null);
|
||||||
}
|
}
|
||||||
|
@ -183,6 +183,9 @@ namespace PlexRequests.Services
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private bool MovieTvSearch(PlexSearch results, string title, string year)
|
private bool MovieTvSearch(PlexSearch results, string title, string year)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(year))
|
if (!string.IsNullOrEmpty(year))
|
||||||
{
|
{
|
||||||
var result = results.Video?.FirstOrDefault(x => x.Title.Equals(title, StringComparison.InvariantCultureIgnoreCase) && x.Year == year);
|
var result = results.Video?.FirstOrDefault(x => x.Title.Equals(title, StringComparison.InvariantCultureIgnoreCase) && x.Year == year);
|
||||||
|
@ -211,6 +214,13 @@ namespace PlexRequests.Services
|
||||||
return result?.Title != null || directoryResult;
|
return result?.Title != null || directoryResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error("Could not finish the Movie/TV check in Plex because of an exception:");
|
||||||
|
Log.Error(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Searches the music on Plex.
|
/// Searches the music on Plex.
|
||||||
|
@ -219,7 +229,9 @@ namespace PlexRequests.Services
|
||||||
/// <param name="title">The title.</param>
|
/// <param name="title">The title.</param>
|
||||||
/// <param name="artist">The artist.</param>
|
/// <param name="artist">The artist.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private bool MusicSearch(PlexSearch results, string title, string artist)
|
private bool AlbumSearch(PlexSearch results, string title, string artist)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
foreach (var r in results.Directory)
|
foreach (var r in results.Directory)
|
||||||
{
|
{
|
||||||
|
@ -230,6 +242,12 @@ namespace PlexRequests.Services
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error("Could not finish the Album check in Plex because of an exception:");
|
||||||
|
Log.Error(e);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue