mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-30 19:40:05 -07:00
Attempt at fixing a potential bug found from #466
This commit is contained in:
parent
f098e0355e
commit
a7d5378426
11 changed files with 222 additions and 133 deletions
|
@ -43,5 +43,6 @@ namespace PlexRequests.Api.Interfaces
|
||||||
PlexEpisodeMetadata GetEpisodeMetaData(string authToken, Uri host, string ratingKey);
|
PlexEpisodeMetadata GetEpisodeMetaData(string authToken, Uri host, string ratingKey);
|
||||||
PlexSearch GetAllEpisodes(string authToken, Uri host, string section, int startPage, int returnCount);
|
PlexSearch GetAllEpisodes(string authToken, Uri host, string section, int startPage, int returnCount);
|
||||||
PlexServer GetServer(string authToken);
|
PlexServer GetServer(string authToken);
|
||||||
|
PlexMetadata GetSeasons(string authToken, Uri plexFullHost, string ratingKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -311,6 +311,7 @@ namespace PlexRequests.Api.Models.Plex
|
||||||
public string UpdatedAt { get; set; }
|
public string UpdatedAt { get; set; }
|
||||||
[XmlAttribute(AttributeName = "parentTitle")]
|
[XmlAttribute(AttributeName = "parentTitle")]
|
||||||
public string ParentTitle { get; set; }
|
public string ParentTitle { get; set; }
|
||||||
|
public List<Directory1> Seasons { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -301,6 +301,36 @@ namespace PlexRequests.Api
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PlexMetadata GetSeasons(string authToken, Uri plexFullHost, string ratingKey)
|
||||||
|
{
|
||||||
|
var request = new RestRequest
|
||||||
|
{
|
||||||
|
Method = Method.GET,
|
||||||
|
Resource = "library/metadata/{ratingKey}/children"
|
||||||
|
};
|
||||||
|
|
||||||
|
request.AddUrlSegment("ratingKey", ratingKey);
|
||||||
|
AddHeaders(ref request, authToken);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var lib = RetryHandler.Execute(() => Api.ExecuteXml<PlexMetadata>(request, plexFullHost),
|
||||||
|
(exception, timespan) => Log.Error(exception, "Exception when calling GetMetadata for Plex, Retrying {0}", timespan), new[] {
|
||||||
|
TimeSpan.FromSeconds (5),
|
||||||
|
TimeSpan.FromSeconds(10),
|
||||||
|
TimeSpan.FromSeconds(30)
|
||||||
|
});
|
||||||
|
|
||||||
|
return lib;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error(e, "There has been a API Exception when attempting to get the Plex GetMetadata");
|
||||||
|
return new PlexMetadata();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public PlexServer GetServer(string authToken)
|
public PlexServer GetServer(string authToken)
|
||||||
{
|
{
|
||||||
var request = new RestRequest
|
var request = new RestRequest
|
||||||
|
|
|
@ -1,84 +1,84 @@
|
||||||
#region Copyright
|
#region Copyright
|
||||||
// /************************************************************************
|
// /************************************************************************
|
||||||
// Copyright (c) 2016 Jamie Rees
|
// Copyright (c) 2016 Jamie Rees
|
||||||
// File: TheMovieDbApi.cs
|
// File: TheMovieDbApi.cs
|
||||||
// Created By: Jamie Rees
|
// Created By: Jamie Rees
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining
|
// Permission is hereby granted, free of charge, to any person obtaining
|
||||||
// a copy of this software and associated documentation files (the
|
// a copy of this software and associated documentation files (the
|
||||||
// "Software"), to deal in the Software without restriction, including
|
// "Software"), to deal in the Software without restriction, including
|
||||||
// without limitation the rights to use, copy, modify, merge, publish,
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
// permit persons to whom the Software is furnished to do so, subject to
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
// the following conditions:
|
// the following conditions:
|
||||||
//
|
//
|
||||||
// The above copyright notice and this permission notice shall be
|
// The above copyright notice and this permission notice shall be
|
||||||
// included in all copies or substantial portions of the Software.
|
// included in all copies or substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// ************************************************************************/
|
// ************************************************************************/
|
||||||
#endregion
|
#endregion
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using TMDbLib.Client;
|
using TMDbLib.Client;
|
||||||
using TMDbLib.Objects.General;
|
using TMDbLib.Objects.General;
|
||||||
using TMDbLib.Objects.Movies;
|
using TMDbLib.Objects.Movies;
|
||||||
using TMDbLib.Objects.Search;
|
using TMDbLib.Objects.Search;
|
||||||
using TMDbLib.Objects.TvShows;
|
using TMDbLib.Objects.TvShows;
|
||||||
|
|
||||||
namespace PlexRequests.Api
|
namespace PlexRequests.Api
|
||||||
{
|
{
|
||||||
public class TheMovieDbApi : MovieBase
|
public class TheMovieDbApi : MovieBase
|
||||||
{
|
{
|
||||||
public TheMovieDbApi()
|
public TheMovieDbApi()
|
||||||
{
|
{
|
||||||
Client = new TMDbClient(ApiKey);
|
Client = new TMDbClient(ApiKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TMDbClient Client { get; set; }
|
public TMDbClient Client { get; set; }
|
||||||
public async Task<List<SearchMovie>> SearchMovie(string searchTerm)
|
public async Task<List<SearchMovie>> SearchMovie(string searchTerm)
|
||||||
{
|
{
|
||||||
var results = await Client.SearchMovie(searchTerm);
|
var results = await Client.SearchMovie(searchTerm);
|
||||||
return results.Results;
|
return results.Results;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("Should use TvMaze for TV")]
|
[Obsolete("Should use TvMaze for TV")]
|
||||||
public async Task<List<SearchTv>> SearchTv(string searchTerm)
|
public async Task<List<SearchTv>> SearchTv(string searchTerm)
|
||||||
{
|
{
|
||||||
var results = await Client.SearchTvShow(searchTerm);
|
var results = await Client.SearchTvShow(searchTerm);
|
||||||
return results.Results;
|
return results.Results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<MovieResult>> GetCurrentPlayingMovies()
|
public async Task<List<MovieResult>> GetCurrentPlayingMovies()
|
||||||
{
|
{
|
||||||
var movies = await Client.GetMovieList(MovieListType.NowPlaying);
|
var movies = await Client.GetMovieList(MovieListType.NowPlaying);
|
||||||
return movies.Results;
|
return movies.Results;
|
||||||
}
|
}
|
||||||
public async Task<List<MovieResult>> GetUpcomingMovies()
|
public async Task<List<MovieResult>> GetUpcomingMovies()
|
||||||
{
|
{
|
||||||
var movies = await Client.GetMovieList(MovieListType.Upcoming);
|
var movies = await Client.GetMovieList(MovieListType.Upcoming);
|
||||||
return movies.Results;
|
return movies.Results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Movie> GetMovieInformation(int tmdbId)
|
public async Task<Movie> GetMovieInformation(int tmdbId)
|
||||||
{
|
{
|
||||||
var movies = await Client.GetMovie(tmdbId);
|
var movies = await Client.GetMovie(tmdbId);
|
||||||
return movies;
|
return movies;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("Should use TvMaze for TV")]
|
[Obsolete("Should use TvMaze for TV")]
|
||||||
public async Task<TvShow> GetTvShowInformation(int tmdbId)
|
public async Task<TvShow> GetTvShowInformation(int tmdbId)
|
||||||
{
|
{
|
||||||
var show = await Client.GetTvShow(tmdbId);
|
var show = await Client.GetTvShow(tmdbId);
|
||||||
return show;
|
return show;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,11 @@ namespace PlexRequests.Helpers.Tests
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCaseSource(nameof(SeasonNumbers))]
|
||||||
|
public int TitleToSeasonNumber(string title)
|
||||||
|
{
|
||||||
|
return PlexHelper.GetSeasonNumberFromTitle(title);
|
||||||
|
}
|
||||||
|
|
||||||
private static IEnumerable<TestCaseData> PlexGuids
|
private static IEnumerable<TestCaseData> PlexGuids
|
||||||
{
|
{
|
||||||
|
@ -70,6 +75,23 @@ namespace PlexRequests.Helpers.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IEnumerable<TestCaseData> SeasonNumbers
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
yield return new TestCaseData("Season 1").Returns(1).SetName("Season 1");
|
||||||
|
yield return new TestCaseData("Season 2").Returns(2).SetName("Season 2");
|
||||||
|
yield return new TestCaseData("Season 3").Returns(3).SetName("Season 3");
|
||||||
|
yield return new TestCaseData("Season 4").Returns(4).SetName("Season 4");
|
||||||
|
yield return new TestCaseData("Season 5").Returns(5).SetName("Season 5");
|
||||||
|
yield return new TestCaseData("Season 100").Returns(100).SetName("Season 100");
|
||||||
|
yield return new TestCaseData("InvalidSeason").Returns(0).SetName("InvalidSeason");
|
||||||
|
yield return new TestCaseData("Invalid Season with no number").Returns(0).SetName("Invalid Season with no number");
|
||||||
|
yield return new TestCaseData("").Returns(0).SetName("Empty string");
|
||||||
|
yield return new TestCaseData(null).Returns(0).SetName("Null string");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static IEnumerable<TestCaseData> PlexTvEpisodeGuids
|
private static IEnumerable<TestCaseData> PlexTvEpisodeGuids
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
|
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||||
|
|
|
@ -72,6 +72,29 @@ namespace PlexRequests.Helpers
|
||||||
return ep;
|
return ep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int GetSeasonNumberFromTitle(string title)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(title))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var split = title.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (split.Length < 2)
|
||||||
|
{
|
||||||
|
// Cannot get the season number, it's not in the usual format
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int season;
|
||||||
|
if (int.TryParse(split[1], out season))
|
||||||
|
{
|
||||||
|
return season;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EpisodeModelHelper
|
public class EpisodeModelHelper
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace PlexRequests.Services.Interfaces
|
||||||
List<PlexMovie> GetPlexMovies();
|
List<PlexMovie> GetPlexMovies();
|
||||||
bool IsMovieAvailable(PlexMovie[] plexMovies, string title, string year, string providerId = null);
|
bool IsMovieAvailable(PlexMovie[] plexMovies, string title, string year, string providerId = null);
|
||||||
List<PlexTvShow> GetPlexTvShows();
|
List<PlexTvShow> GetPlexTvShows();
|
||||||
bool IsTvShowAvailable(PlexTvShow[] plexShows, string title, string year, string providerId = null);
|
bool IsTvShowAvailable(PlexTvShow[] plexShows, string title, string year, string providerId = null, int[] seasons = null);
|
||||||
List<PlexAlbum> GetPlexAlbums();
|
List<PlexAlbum> GetPlexAlbums();
|
||||||
bool IsAlbumAvailable(PlexAlbum[] plexAlbums, string title, string year, string artist);
|
bool IsAlbumAvailable(PlexAlbum[] plexAlbums, string title, string year, string artist);
|
||||||
bool IsEpisodeAvailable(string theTvDbId, int season, int episode);
|
bool IsEpisodeAvailable(string theTvDbId, int season, int episode);
|
||||||
|
|
|
@ -209,25 +209,33 @@ namespace PlexRequests.Services.Jobs
|
||||||
).ToArray();
|
).ToArray();
|
||||||
|
|
||||||
foreach (var lib in tvLibs)
|
foreach (var lib in tvLibs)
|
||||||
{
|
{
|
||||||
shows.AddRange(lib.Directory.Select(x => new PlexTvShow // shows are in the directory list
|
shows.AddRange(lib.Directory.Select(x => new PlexTvShow // shows are in the directory list
|
||||||
{
|
{
|
||||||
Title = x.Title,
|
Title = x.Title,
|
||||||
ReleaseYear = x.Year,
|
ReleaseYear = x.Year,
|
||||||
ProviderId = x.ProviderId,
|
ProviderId = x.ProviderId,
|
||||||
|
Seasons = x.Seasons.Select(d => PlexHelper.GetSeasonNumberFromTitle(d.Title)).ToArray()
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return shows;
|
return shows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsTvShowAvailable(PlexTvShow[] plexShows, string title, string year, string providerId = null)
|
public bool IsTvShowAvailable(PlexTvShow[] plexShows, string title, string year, string providerId = null, int[] seasons = null)
|
||||||
{
|
{
|
||||||
var advanced = !string.IsNullOrEmpty(providerId);
|
var advanced = !string.IsNullOrEmpty(providerId);
|
||||||
foreach (var show in plexShows)
|
foreach (var show in plexShows)
|
||||||
{
|
{
|
||||||
if (advanced)
|
if (advanced)
|
||||||
{
|
{
|
||||||
|
if (seasons != null)
|
||||||
|
{
|
||||||
|
if (seasons.Any(season => show.Seasons.Contains(season)))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!string.IsNullOrEmpty(show.ProviderId) &&
|
if (!string.IsNullOrEmpty(show.ProviderId) &&
|
||||||
show.ProviderId.Equals(providerId, StringComparison.InvariantCultureIgnoreCase))
|
show.ProviderId.Equals(providerId, StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
|
@ -366,6 +374,8 @@ namespace PlexRequests.Services.Jobs
|
||||||
var currentItem = results[i].Directory[j];
|
var currentItem = results[i].Directory[j];
|
||||||
var metaData = PlexApi.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri,
|
var metaData = PlexApi.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri,
|
||||||
currentItem.RatingKey);
|
currentItem.RatingKey);
|
||||||
|
var seasons = PlexApi.GetSeasons(plexSettings.PlexAuthToken, plexSettings.FullUri, currentItem.RatingKey);
|
||||||
|
results[i].Directory[j] = seasons.Directory;
|
||||||
var providerId = PlexHelper.GetProviderIdFromPlexGuid(metaData.Directory.Guid);
|
var providerId = PlexHelper.GetProviderIdFromPlexGuid(metaData.Directory.Guid);
|
||||||
results[i].Directory[j].ProviderId = providerId;
|
results[i].Directory[j].ProviderId = providerId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
namespace PlexRequests.Services.Models
|
namespace PlexRequests.Services.Models
|
||||||
{
|
{
|
||||||
public class PlexTvShow
|
public class PlexTvShow
|
||||||
{
|
{
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public string ReleaseYear { get; set; }
|
public string ReleaseYear { get; set; }
|
||||||
public string ProviderId { get; set; }
|
public string ProviderId { get; set; }
|
||||||
}
|
public int[] Seasons { get; set; }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ using PlexRequests.Store.Models;
|
||||||
using PlexRequests.Store.Repository;
|
using PlexRequests.Store.Repository;
|
||||||
|
|
||||||
using TMDbLib.Objects.General;
|
using TMDbLib.Objects.General;
|
||||||
|
using TMDbLib.Objects.Search;
|
||||||
|
|
||||||
using Action = PlexRequests.Helpers.Analytics.Action;
|
using Action = PlexRequests.Helpers.Analytics.Action;
|
||||||
using EpisodesModel = PlexRequests.Store.EpisodesModel;
|
using EpisodesModel = PlexRequests.Store.EpisodesModel;
|
||||||
|
@ -190,7 +191,7 @@ namespace PlexRequests.UI.Modules
|
||||||
case MovieSearchType.Search:
|
case MovieSearchType.Search:
|
||||||
var movies = await MovieApi.SearchMovie(searchTerm);
|
var movies = await MovieApi.SearchMovie(searchTerm);
|
||||||
apiMovies = movies.Select(x =>
|
apiMovies = movies.Select(x =>
|
||||||
new MovieResult()
|
new MovieResult
|
||||||
{
|
{
|
||||||
Adult = x.Adult,
|
Adult = x.Adult,
|
||||||
BackdropPath = x.BackdropPath,
|
BackdropPath = x.BackdropPath,
|
||||||
|
@ -594,41 +595,6 @@ namespace PlexRequests.UI.Modules
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var shows = Checker.GetPlexTvShows();
|
|
||||||
var providerId = string.Empty;
|
|
||||||
var plexSettings = await PlexService.GetSettingsAsync();
|
|
||||||
if (plexSettings.AdvancedSearch)
|
|
||||||
{
|
|
||||||
providerId = showId.ToString();
|
|
||||||
}
|
|
||||||
if (episodeRequest)
|
|
||||||
{
|
|
||||||
var cachedEpisodesTask = await Checker.GetEpisodes();
|
|
||||||
var cachedEpisodes = cachedEpisodesTask.ToList();
|
|
||||||
foreach (var d in difference)
|
|
||||||
{
|
|
||||||
if (cachedEpisodes.Any(x => x.SeasonNumber == d.SeasonNumber && x.EpisodeNumber == d.EpisodeNumber && x.ProviderId == providerId))
|
|
||||||
{
|
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{fullShowName} {d.SeasonNumber} - {d.EpisodeNumber} {Resources.UI.Search_AlreadyInPlex}" });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (Checker.IsTvShowAvailable(shows.ToArray(), showInfo.name, showInfo.premiered?.Substring(0, 4), providerId))
|
|
||||||
{
|
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{fullShowName} {Resources.UI.Search_AlreadyInPlex}" });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = string.Format(Resources.UI.Search_CouldNotCheckPlex, fullShowName) });
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var model = new RequestedModel
|
var model = new RequestedModel
|
||||||
{
|
{
|
||||||
ProviderId = showInfo.externals?.thetvdb ?? 0,
|
ProviderId = showInfo.externals?.thetvdb ?? 0,
|
||||||
|
@ -687,6 +653,41 @@ namespace PlexRequests.UI.Modules
|
||||||
|
|
||||||
model.SeasonList = seasonsList.ToArray();
|
model.SeasonList = seasonsList.ToArray();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var shows = Checker.GetPlexTvShows();
|
||||||
|
var providerId = string.Empty;
|
||||||
|
var plexSettings = await PlexService.GetSettingsAsync();
|
||||||
|
if (plexSettings.AdvancedSearch)
|
||||||
|
{
|
||||||
|
providerId = showId.ToString();
|
||||||
|
}
|
||||||
|
if (episodeRequest)
|
||||||
|
{
|
||||||
|
var cachedEpisodesTask = await Checker.GetEpisodes();
|
||||||
|
var cachedEpisodes = cachedEpisodesTask.ToList();
|
||||||
|
foreach (var d in difference)
|
||||||
|
{
|
||||||
|
if (cachedEpisodes.Any(x => x.SeasonNumber == d.SeasonNumber && x.EpisodeNumber == d.EpisodeNumber && x.ProviderId == providerId))
|
||||||
|
{
|
||||||
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{fullShowName} {d.SeasonNumber} - {d.EpisodeNumber} {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}" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = string.Format(Resources.UI.Search_CouldNotCheckPlex, fullShowName) });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (ShouldAutoApprove(RequestType.TvShow, settings))
|
if (ShouldAutoApprove(RequestType.TvShow, settings))
|
||||||
{
|
{
|
||||||
model.Approved = true;
|
model.Approved = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue