REFACTOR: IAvailabilityChecker - changed arrays to IEnumerables

pull/1178/head
smcpeck 8 years ago
parent 0aa00fd888
commit b51f790493

@ -37,15 +37,15 @@ namespace Ombi.Services.Interfaces
void Start(); void Start();
void CheckAndUpdateAll(); void CheckAndUpdateAll();
IEnumerable<PlexContent> GetPlexMovies(IEnumerable<PlexContent> content); IEnumerable<PlexContent> GetPlexMovies(IEnumerable<PlexContent> content);
bool IsMovieAvailable(PlexContent[] plexMovies, string title, string year, string providerId = null); bool IsMovieAvailable(IEnumerable<PlexContent> plexMovies, string title, string year, string providerId = null);
IEnumerable<PlexContent> GetPlexTvShows(IEnumerable<PlexContent> content); IEnumerable<PlexContent> GetPlexTvShows(IEnumerable<PlexContent> content);
bool IsTvShowAvailable(PlexContent[] plexShows, string title, string year, string providerId = null, int[] seasons = null); bool IsTvShowAvailable(IEnumerable<PlexContent> plexShows, string title, string year, string providerId = null, int[] seasons = null);
IEnumerable<PlexContent> GetPlexAlbums(IEnumerable<PlexContent> content); IEnumerable<PlexContent> GetPlexAlbums(IEnumerable<PlexContent> content);
bool IsAlbumAvailable(PlexContent[] plexAlbums, string title, string year, string artist); bool IsAlbumAvailable(IEnumerable<PlexContent> plexAlbums, string title, string year, string artist);
bool IsEpisodeAvailable(string theTvDbId, int season, int episode); bool IsEpisodeAvailable(string theTvDbId, int season, int episode);
PlexContent GetAlbum(PlexContent[] plexAlbums, string title, string year, string artist); PlexContent GetAlbum(IEnumerable<PlexContent> plexAlbums, string title, string year, string artist);
PlexContent GetMovie(PlexContent[] plexMovies, string title, string year, string providerId = null); PlexContent GetMovie(IEnumerable<PlexContent> plexMovies, string title, string year, string providerId = null);
PlexContent GetTvShow(PlexContent[] plexShows, string title, string year, string providerId = null, int[] seasons = null); PlexContent GetTvShow(IEnumerable<PlexContent> plexShows, string title, string year, string providerId = null, int[] seasons = null);
/// <summary> /// <summary>
/// Gets the episode's stored in the cache. /// Gets the episode's stored in the cache.
/// </summary> /// </summary>

@ -189,15 +189,15 @@ namespace Ombi.Services.Jobs
return content.Where(x => x.Type == Store.Models.Plex.PlexMediaType.Movie); return content.Where(x => x.Type == Store.Models.Plex.PlexMediaType.Movie);
} }
public bool IsMovieAvailable(PlexContent[] plexMovies, string title, string year, string providerId = null) public bool IsMovieAvailable(IEnumerable<PlexContent> plexMovies, string title, string year, string providerId = null)
{ {
var movie = GetMovie(plexMovies, title, year, providerId); var movie = GetMovie(plexMovies, title, year, providerId);
return movie != null; return movie != null;
} }
public PlexContent GetMovie(PlexContent[] plexMovies, string title, string year, string providerId = null) public PlexContent GetMovie(IEnumerable<PlexContent> plexMovies, string title, string year, string providerId = null)
{ {
if (plexMovies.Length == 0) if (plexMovies.Count() == 0)
{ {
return null; return null;
} }
@ -231,14 +231,14 @@ namespace Ombi.Services.Jobs
return content.Where(x => x.Type == Store.Models.Plex.PlexMediaType.Show); return content.Where(x => x.Type == Store.Models.Plex.PlexMediaType.Show);
} }
public bool IsTvShowAvailable(PlexContent[] plexShows, string title, string year, string providerId = null, int[] seasons = null) public bool IsTvShowAvailable(IEnumerable<PlexContent> plexShows, string title, string year, string providerId = null, int[] seasons = null)
{ {
var show = GetTvShow(plexShows, title, year, providerId, seasons); var show = GetTvShow(plexShows, title, year, providerId, seasons);
return show != null; return show != null;
} }
public PlexContent GetTvShow(PlexContent[] plexShows, string title, string year, string providerId = null, public PlexContent GetTvShow(IEnumerable<PlexContent> plexShows, string title, string year, string providerId = null,
int[] seasons = null) int[] seasons = null)
{ {
var advanced = !string.IsNullOrEmpty(providerId); var advanced = !string.IsNullOrEmpty(providerId);
@ -340,14 +340,14 @@ namespace Ombi.Services.Jobs
return content.Where(x => x.Type == Store.Models.Plex.PlexMediaType.Artist); return content.Where(x => x.Type == Store.Models.Plex.PlexMediaType.Artist);
} }
public bool IsAlbumAvailable(PlexContent[] plexAlbums, string title, string year, string artist) public bool IsAlbumAvailable(IEnumerable<PlexContent> plexAlbums, string title, string year, string artist)
{ {
return plexAlbums.Any(x => return plexAlbums.Any(x =>
x.Title.Contains(title) && x.Title.Contains(title) &&
x.Artist.Equals(artist, StringComparison.CurrentCultureIgnoreCase)); x.Artist.Equals(artist, StringComparison.CurrentCultureIgnoreCase));
} }
public PlexContent GetAlbum(PlexContent[] plexAlbums, string title, string year, string artist) public PlexContent GetAlbum(IEnumerable<PlexContent> plexAlbums, string title, string year, string artist)
{ {
return plexAlbums.FirstOrDefault(x => return plexAlbums.FirstOrDefault(x =>
x.Title.Contains(title) && x.Title.Contains(title) &&

Loading…
Cancel
Save