diff --git a/PlexRequests.Api.Models/Tv/TVMazeShow.cs b/PlexRequests.Api.Models/Tv/TVMazeShow.cs index 840edfdf8..cbff57b65 100644 --- a/PlexRequests.Api.Models/Tv/TVMazeShow.cs +++ b/PlexRequests.Api.Models/Tv/TVMazeShow.cs @@ -1,79 +1,89 @@ -using System.Collections.Generic; - -namespace PlexRequests.Api.Models.Tv -{ - public class TvMazeShow - { - public int id { get; set; } - public string url { get; set; } - public string name { get; set; } - public string type { get; set; } - public string language { get; set; } - public List genres { get; set; } - public string status { get; set; } - public int runtime { get; set; } - public string premiered { get; set; } - public Schedule schedule { get; set; } - public Rating rating { get; set; } - public int weight { get; set; } - public Network network { get; set; } - public object webChannel { get; set; } - public Externals externals { get; set; } - public Image image { get; set; } - public string summary { get; set; } - public int updated { get; set; } - public Links _links { get; set; } - public int seasonCount { get; set; } - public Embedded _embedded { get; set; } - } - - public class Season - { - public int id { get; set; } - public string url { get; set; } - public int number { get; set; } - public string name { get; set; } - public int? episodeOrder { get; set; } - public string premiereDate { get; set; } - public string endDate { get; set; } - public Network2 network { get; set; } - public object webChannel { get; set; } - public Image2 image { get; set; } - public string summary { get; set; } - public Links2 _links { get; set; } - } - public class Country2 -{ - public string name { get; set; } - public string code { get; set; } - public string timezone { get; set; } -} - -public class Network2 -{ - public int id { get; set; } - public string name { get; set; } - public Country2 country { get; set; } -} - -public class Image2 -{ - public string medium { get; set; } - public string original { get; set; } -} - -public class Self2 -{ - public string href { get; set; } -} - -public class Links2 -{ - public Self2 self { get; set; } -} - - public class Embedded - { - public List seasons { get; set; } - } +using System.Collections.Generic; + +namespace PlexRequests.Api.Models.Tv +{ + public class TvMazeShow + { + public TvMazeShow() + { + Season = new List(); + } + public int id { get; set; } + public string url { get; set; } + public string name { get; set; } + public string type { get; set; } + public string language { get; set; } + public List genres { get; set; } + public string status { get; set; } + public int runtime { get; set; } + public string premiered { get; set; } + public Schedule schedule { get; set; } + public Rating rating { get; set; } + public int weight { get; set; } + public Network network { get; set; } + public object webChannel { get; set; } + public Externals externals { get; set; } + public Image image { get; set; } + public string summary { get; set; } + public int updated { get; set; } + public Links _links { get; set; } + public List Season { get; set; } + public Embedded _embedded { get; set; } + } + + public class TvMazeCustomSeason + { + public int SeasonNumber { get; set; } + public int EpisodeNumber { get; set; } + } + + public class Season + { + public int id { get; set; } + public string url { get; set; } + public int number { get; set; } + public string name { get; set; } + public int? episodeOrder { get; set; } + public string premiereDate { get; set; } + public string endDate { get; set; } + public Network2 network { get; set; } + public object webChannel { get; set; } + public Image2 image { get; set; } + public string summary { get; set; } + public Links2 _links { get; set; } + } + public class Country2 +{ + public string name { get; set; } + public string code { get; set; } + public string timezone { get; set; } +} + +public class Network2 +{ + public int id { get; set; } + public string name { get; set; } + public Country2 country { get; set; } +} + +public class Image2 +{ + public string medium { get; set; } + public string original { get; set; } +} + +public class Self2 +{ + public string href { get; set; } +} + +public class Links2 +{ + public Self2 self { get; set; } +} + + public class Embedded + { + public List seasons { get; set; } + } } \ No newline at end of file diff --git a/PlexRequests.Api/TvMazeApi.cs b/PlexRequests.Api/TvMazeApi.cs index 5d5c60c0f..98f95306e 100644 --- a/PlexRequests.Api/TvMazeApi.cs +++ b/PlexRequests.Api/TvMazeApi.cs @@ -93,8 +93,18 @@ public TvMazeShow ShowLookupByTheTvDbId(int theTvDbId) request.AddHeader("Content-Type", "application/json"); var obj = Api.Execute(request, new Uri(Uri)); - obj.seasonCount = GetSeasonCount(obj.id); + var episodes = EpisodeLookup(obj.id).ToList(); + + foreach (var e in episodes) + { + obj.Season.Add(new TvMazeCustomSeason + { + SeasonNumber = e.season, + EpisodeNumber = e.number + }); + } + return obj; } @@ -110,6 +120,7 @@ public List GetSeasons(int id) return Api.Execute>(request, new Uri(Uri)); } + public int GetSeasonCount(int id) { var obj = GetSeasons(id); diff --git a/PlexRequests.Services/Jobs/PlexAvailabilityChecker.cs b/PlexRequests.Services/Jobs/PlexAvailabilityChecker.cs index fc7c38778..ed1426993 100644 --- a/PlexRequests.Services/Jobs/PlexAvailabilityChecker.cs +++ b/PlexRequests.Services/Jobs/PlexAvailabilityChecker.cs @@ -271,7 +271,7 @@ public PlexTvShow GetTvShow(PlexTvShow[] plexShows, string title, string year, s { if (advanced) { - if (show.ProviderId == providerId) + if (show.ProviderId == providerId && seasons != null) { if (seasons.Any(season => show.Seasons.Contains(season))) { diff --git a/PlexRequests.Services/Jobs/PlexEpisodeCacher.cs b/PlexRequests.Services/Jobs/PlexEpisodeCacher.cs index 3a4af04dd..3ed43db50 100644 --- a/PlexRequests.Services/Jobs/PlexEpisodeCacher.cs +++ b/PlexRequests.Services/Jobs/PlexEpisodeCacher.cs @@ -112,6 +112,10 @@ public void CacheEpisodes(PlexSettings settings) // Loop through the metadata and create the model to insert into the DB foreach (var metadataVideo in metadata.Video) { + if(string.IsNullOrEmpty(metadataVideo.GrandparentTitle)) + { + continue; + } var epInfo = PlexHelper.GetSeasonsAndEpisodesFromPlexGuid(metadataVideo.Guid); entities.TryAdd( new PlexEpisodes diff --git a/PlexRequests.UI/Modules/SearchModule.cs b/PlexRequests.UI/Modules/SearchModule.cs index 874bd39c8..f9492ee80 100644 --- a/PlexRequests.UI/Modules/SearchModule.cs +++ b/PlexRequests.UI/Modules/SearchModule.cs @@ -349,8 +349,7 @@ private async Task SearchTvShow(string searchTerm) providerId = viewT.Id.ToString(); } - var plexShow = Checker.GetTvShow(plexTvShows.ToArray(), t.show.name, t.show.premiered?.Substring(0, 4), - providerId); + var plexShow = Checker.GetTvShow(plexTvShows.ToArray(), t.show.name, t.show.premiered?.Substring(0, 4), providerId); if (plexShow != null) { viewT.Available = true; @@ -590,7 +589,7 @@ private async Task RequestTvShow(int showId, string seasons) RequestedUsers = new List { Username }, Issues = IssueState.None, ImdbId = showInfo.externals?.imdb ?? string.Empty, - SeasonCount = showInfo.seasonCount, + SeasonCount = showInfo.Season.Count, TvDbId = showId.ToString() }; @@ -703,7 +702,18 @@ private async Task RequestTvShow(int showId, string seasons) } else { - if (Checker.IsTvShowAvailable(shows.ToArray(), showInfo.name, showInfo.premiered?.Substring(0, 4), providerId, model.SeasonList)) + if (plexSettings.EnableTvEpisodeSearching) + { + foreach (var s in showInfo.Season) + { + var result = Checker.IsEpisodeAvailable(showId.ToString(), s.SeasonNumber, s.EpisodeNumber); + if (result) + { + return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{fullShowName} {Resources.UI.Search_AlreadyInPlex}" }); + } + } + } + else if (Checker.IsTvShowAvailable(shows.ToArray(), showInfo.name, showInfo.premiered?.Substring(0, 4), providerId, model.SeasonList)) { return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{fullShowName} {Resources.UI.Search_AlreadyInPlex}" }); } diff --git a/PlexRequests.UI/Modules/UpdateCheckerModule.cs b/PlexRequests.UI/Modules/UpdateCheckerModule.cs index 216288c1a..ddf869f28 100644 --- a/PlexRequests.UI/Modules/UpdateCheckerModule.cs +++ b/PlexRequests.UI/Modules/UpdateCheckerModule.cs @@ -59,7 +59,9 @@ private async Task CheckLatestVersion() { return Response.AsJson(new JsonUpdateAvailableModel { UpdateAvailable = false }); } - +#if DEBUG + return Response.AsJson(new JsonUpdateAvailableModel {UpdateAvailable = false}); +#endif var checker = new StatusChecker(); var release = await Cache.GetOrSetAsync(CacheKeys.LastestProductVersion, async() => await checker.GetStatus(), 30); diff --git a/PlexRequests.UI/Views/Admin/SchedulerSettings.cshtml b/PlexRequests.UI/Views/Admin/SchedulerSettings.cshtml index 9c7b8b862..4621981e7 100644 --- a/PlexRequests.UI/Views/Admin/SchedulerSettings.cshtml +++ b/PlexRequests.UI/Views/Admin/SchedulerSettings.cshtml @@ -82,7 +82,7 @@
- +