From b51f790493cb51a84ccdf03a4757ac1f688bfa01 Mon Sep 17 00:00:00 2001 From: smcpeck Date: Thu, 23 Feb 2017 17:13:45 -0600 Subject: [PATCH] REFACTOR: IAvailabilityChecker - changed arrays to IEnumerables --- Ombi.Services/Interfaces/IAvailabilityChecker.cs | 12 ++++++------ Ombi.Services/Jobs/PlexAvailabilityChecker.cs | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Ombi.Services/Interfaces/IAvailabilityChecker.cs b/Ombi.Services/Interfaces/IAvailabilityChecker.cs index f2915faa0..cf602e531 100644 --- a/Ombi.Services/Interfaces/IAvailabilityChecker.cs +++ b/Ombi.Services/Interfaces/IAvailabilityChecker.cs @@ -37,15 +37,15 @@ namespace Ombi.Services.Interfaces void Start(); void CheckAndUpdateAll(); IEnumerable GetPlexMovies(IEnumerable content); - bool IsMovieAvailable(PlexContent[] plexMovies, string title, string year, string providerId = null); + bool IsMovieAvailable(IEnumerable plexMovies, string title, string year, string providerId = null); IEnumerable GetPlexTvShows(IEnumerable content); - bool IsTvShowAvailable(PlexContent[] plexShows, string title, string year, string providerId = null, int[] seasons = null); + bool IsTvShowAvailable(IEnumerable plexShows, string title, string year, string providerId = null, int[] seasons = null); IEnumerable GetPlexAlbums(IEnumerable content); - bool IsAlbumAvailable(PlexContent[] plexAlbums, string title, string year, string artist); + bool IsAlbumAvailable(IEnumerable plexAlbums, string title, string year, string artist); bool IsEpisodeAvailable(string theTvDbId, int season, int episode); - PlexContent GetAlbum(PlexContent[] plexAlbums, string title, string year, string artist); - PlexContent GetMovie(PlexContent[] plexMovies, string title, string year, string providerId = null); - PlexContent GetTvShow(PlexContent[] plexShows, string title, string year, string providerId = null, int[] seasons = null); + PlexContent GetAlbum(IEnumerable plexAlbums, string title, string year, string artist); + PlexContent GetMovie(IEnumerable plexMovies, string title, string year, string providerId = null); + PlexContent GetTvShow(IEnumerable plexShows, string title, string year, string providerId = null, int[] seasons = null); /// /// Gets the episode's stored in the cache. /// diff --git a/Ombi.Services/Jobs/PlexAvailabilityChecker.cs b/Ombi.Services/Jobs/PlexAvailabilityChecker.cs index e205b5b1b..6ab9da967 100644 --- a/Ombi.Services/Jobs/PlexAvailabilityChecker.cs +++ b/Ombi.Services/Jobs/PlexAvailabilityChecker.cs @@ -189,15 +189,15 @@ namespace Ombi.Services.Jobs 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 plexMovies, string title, string year, string providerId = null) { var movie = GetMovie(plexMovies, title, year, providerId); return movie != null; } - public PlexContent GetMovie(PlexContent[] plexMovies, string title, string year, string providerId = null) + public PlexContent GetMovie(IEnumerable plexMovies, string title, string year, string providerId = null) { - if (plexMovies.Length == 0) + if (plexMovies.Count() == 0) { return null; } @@ -231,14 +231,14 @@ namespace Ombi.Services.Jobs 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 plexShows, string title, string year, string providerId = null, int[] seasons = null) { var show = GetTvShow(plexShows, title, year, providerId, seasons); return show != null; } - public PlexContent GetTvShow(PlexContent[] plexShows, string title, string year, string providerId = null, + public PlexContent GetTvShow(IEnumerable plexShows, string title, string year, string providerId = null, int[] seasons = null) { var advanced = !string.IsNullOrEmpty(providerId); @@ -340,14 +340,14 @@ namespace Ombi.Services.Jobs 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 plexAlbums, string title, string year, string artist) { return plexAlbums.Any(x => x.Title.Contains(title) && x.Artist.Equals(artist, StringComparison.CurrentCultureIgnoreCase)); } - public PlexContent GetAlbum(PlexContent[] plexAlbums, string title, string year, string artist) + public PlexContent GetAlbum(IEnumerable plexAlbums, string title, string year, string artist) { return plexAlbums.FirstOrDefault(x => x.Title.Contains(title) &&