mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
Merge remote-tracking branch 'refs/remotes/origin/dev'
Conflicts: PlexRequests.Services/Jobs/RecentlyAdded.cs
This commit is contained in:
commit
71446f0b59
34 changed files with 761 additions and 323 deletions
|
@ -25,7 +25,8 @@
|
|||
// ************************************************************************/
|
||||
#endregion
|
||||
using System;
|
||||
|
||||
using System.IO;
|
||||
using Mono.Data.Sqlite;
|
||||
using Nancy;
|
||||
using Nancy.ModelBinding;
|
||||
using Nancy.Security;
|
||||
|
@ -35,6 +36,8 @@ using NLog;
|
|||
using PlexRequests.Api.Interfaces;
|
||||
using PlexRequests.Core;
|
||||
using PlexRequests.Core.SettingModels;
|
||||
using PlexRequests.Store;
|
||||
using PlexRequests.Store.Repository;
|
||||
using PlexRequests.UI.Helpers;
|
||||
using PlexRequests.UI.Models;
|
||||
|
||||
|
@ -59,7 +62,7 @@ namespace PlexRequests.UI.Modules
|
|||
Post["/plex"] = _ => PlexTest();
|
||||
Post["/sickrage"] = _ => SickRageTest();
|
||||
Post["/headphones"] = _ => HeadphonesTest();
|
||||
|
||||
Post["/plexdb"] = _ => TestPlexDb();
|
||||
}
|
||||
|
||||
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
@ -223,5 +226,65 @@ namespace PlexRequests.UI.Modules
|
|||
return Response.AsJson(new JsonResponseModel { Result = false, Message = message }); ;
|
||||
}
|
||||
}
|
||||
|
||||
private Response TestPlexDb()
|
||||
{
|
||||
var settings = this.Bind<PlexSettings>();
|
||||
var valid = this.Validate(settings);
|
||||
if (!valid.IsValid)
|
||||
{
|
||||
return Response.AsJson(valid.SendJsonError());
|
||||
}
|
||||
try
|
||||
{
|
||||
var location = string.Empty;
|
||||
|
||||
if (string.IsNullOrEmpty(settings.PlexDatabaseLocationOverride))
|
||||
{
|
||||
if (Type.GetType("Mono.Runtime") != null)
|
||||
{
|
||||
// Mono
|
||||
location = Path.Combine("/var/lib/plexmediaserver/Library/Application Support/",
|
||||
"Plex Media Server", "Plug-in Support", "Databases", "com.plexapp.plugins.library.db");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default Windows
|
||||
location = Path.Combine(Environment.ExpandEnvironmentVariables("%LOCALAPPDATA%"),
|
||||
"Plex Media Server", "Plug-in Support", "Databases", "com.plexapp.plugins.library.db");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
location = Path.Combine(settings.PlexDatabaseLocationOverride, "Plug-in Support", "Databases", "com.plexapp.plugins.library.db");
|
||||
}
|
||||
|
||||
if (File.Exists(location))
|
||||
{
|
||||
return Response.AsJson(new JsonResponseModel
|
||||
{
|
||||
Result = true,
|
||||
Message = "Found the database!"
|
||||
});
|
||||
}
|
||||
|
||||
return Response.AsJson(new JsonResponseModel
|
||||
{
|
||||
Result = false,
|
||||
Message = $"Could not find the database at the following full location : {location}"
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Warn("Exception thrown when attempting to find the plex database: ");
|
||||
Log.Warn(e);
|
||||
var message = $"Could not find Plex's DB, please check your settings. <strong>Exception Message:</strong> {e.Message}";
|
||||
if (e.InnerException != null)
|
||||
{
|
||||
message = $"Could not find Plex's DB, please check your settings. <strong>Exception Message:</strong> {e.InnerException.Message}";
|
||||
}
|
||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = message }); ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -184,14 +184,14 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
private async Task<Response> ProcessMovies(MovieSearchType searchType, string searchTerm)
|
||||
{
|
||||
List<MovieResult> apiMovies;
|
||||
List<SearchMovie> apiMovies;
|
||||
|
||||
switch (searchType)
|
||||
{
|
||||
case MovieSearchType.Search:
|
||||
var movies = await MovieApi.SearchMovie(searchTerm);
|
||||
var movies = await MovieApi.SearchMovie(searchTerm).ConfigureAwait(false);
|
||||
apiMovies = movies.Select(x =>
|
||||
new MovieResult
|
||||
new SearchMovie
|
||||
{
|
||||
Adult = x.Adult,
|
||||
BackdropPath = x.BackdropPath,
|
||||
|
@ -217,7 +217,7 @@ namespace PlexRequests.UI.Modules
|
|||
apiMovies = await MovieApi.GetUpcomingMovies();
|
||||
break;
|
||||
default:
|
||||
apiMovies = new List<MovieResult>();
|
||||
apiMovies = new List<SearchMovie>();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -234,6 +234,8 @@ namespace PlexRequests.UI.Modules
|
|||
var viewMovies = new List<SearchMovieViewModel>();
|
||||
foreach (var movie in apiMovies)
|
||||
{
|
||||
var movieInfoTask = MovieApi.GetMovieInformation(movie.Id).ConfigureAwait(false); // TODO needs to be careful about this, it's adding extra time to search...
|
||||
// https://www.themoviedb.org/talk/5807f4cdc3a36812160041f2
|
||||
var viewMovie = new SearchMovieViewModel
|
||||
{
|
||||
Adult = movie.Adult,
|
||||
|
@ -252,7 +254,8 @@ namespace PlexRequests.UI.Modules
|
|||
VoteCount = movie.VoteCount
|
||||
};
|
||||
var canSee = CanUserSeeThisRequest(viewMovie.Id, settings.UsersCanViewOnlyOwnRequests, dbMovies);
|
||||
var plexMovie = Checker.GetMovie(plexMovies.ToArray(), movie.Title, movie.ReleaseDate?.Year.ToString());
|
||||
var movieInfo = await movieInfoTask;
|
||||
var plexMovie = Checker.GetMovie(plexMovies.ToArray(), movie.Title, movie.ReleaseDate?.Year.ToString(), movieInfo.ImdbId);
|
||||
if (plexMovie != null)
|
||||
{
|
||||
viewMovie.Available = true;
|
||||
|
@ -349,8 +352,7 @@ namespace PlexRequests.UI.Modules
|
|||
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 +592,7 @@ namespace PlexRequests.UI.Modules
|
|||
RequestedUsers = new List<string> { Username },
|
||||
Issues = IssueState.None,
|
||||
ImdbId = showInfo.externals?.imdb ?? string.Empty,
|
||||
SeasonCount = showInfo.seasonCount,
|
||||
SeasonCount = showInfo.Season.Count,
|
||||
TvDbId = showId.ToString()
|
||||
};
|
||||
|
||||
|
@ -703,7 +705,18 @@ namespace PlexRequests.UI.Modules
|
|||
}
|
||||
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}" });
|
||||
}
|
||||
|
|
|
@ -59,7 +59,9 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue