mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 16:22:55 -07:00
Loads of changes, improved the movie search stylings is back
This commit is contained in:
parent
dbade585e2
commit
22c5d3a19d
38 changed files with 390 additions and 162742 deletions
|
@ -13,6 +13,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Threading.Tasks;
|
||||
using StackExchange.Profiling;
|
||||
|
||||
namespace Ombi.Core.Engine
|
||||
{
|
||||
|
@ -63,17 +64,41 @@ namespace Ombi.Core.Engine
|
|||
return retVal;
|
||||
}
|
||||
|
||||
public async Task<SearchMovieViewModel> LookupImdbInformation(int theMovieDbId)
|
||||
{
|
||||
var dbMovies = await GetMovieRequests();
|
||||
|
||||
var plexSettings = await PlexSettings.GetSettingsAsync();
|
||||
var embySettings = await EmbySettings.GetSettingsAsync();
|
||||
|
||||
var movieInfo = await MovieApi.GetMovieInformationWithVideo(theMovieDbId);
|
||||
var viewMovie = Mapper.Map<SearchMovieViewModel>(movieInfo);
|
||||
|
||||
return await ProcessSingleMovie(viewMovie, dbMovies, plexSettings, embySettings, true);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> Search(string search)
|
||||
{
|
||||
var result = await MovieApi.SearchMovie(search);
|
||||
if (result != null)
|
||||
using (MiniProfiler.Current.Step("Starting Movie Search Engine"))
|
||||
using (MiniProfiler.Current.Step("Searching Movie"))
|
||||
{
|
||||
Logger.LogDebug("Search Result: {result}", result);
|
||||
return await TransformMovieResultsToResponse(result);
|
||||
var result = await MovieApi.SearchMovie(search);
|
||||
|
||||
using (MiniProfiler.Current.Step("Fin API, Transforming"))
|
||||
{
|
||||
if (result != null)
|
||||
{
|
||||
Logger.LogDebug("Search Result: {result}", result);
|
||||
return await TransformMovieResultsToResponse(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> PopularMovies()
|
||||
{
|
||||
var result = await MovieApi.PopularMovies();
|
||||
|
@ -121,28 +146,41 @@ namespace Ombi.Core.Engine
|
|||
private async Task<List<SearchMovieViewModel>> TransformMovieResultsToResponse(
|
||||
IEnumerable<MovieSearchResult> movies)
|
||||
{
|
||||
var viewMovies = new List<SearchMovieViewModel>();
|
||||
var dbMovies = await GetMovieRequests();
|
||||
|
||||
var plexSettings = await PlexSettings.GetSettingsAsync();
|
||||
var embySettings = await EmbySettings.GetSettingsAsync();
|
||||
var viewMovies = new List<SearchMovieViewModel>();
|
||||
Dictionary<int, MovieRequestModel> dbMovies;
|
||||
Settings.Models.External.PlexSettings plexSettings;
|
||||
Settings.Models.External.EmbySettings embySettings;
|
||||
using (MiniProfiler.Current.Step("Gettings Movies and Settings"))
|
||||
{
|
||||
dbMovies = await GetMovieRequests();
|
||||
|
||||
plexSettings = await PlexSettings.GetSettingsAsync();
|
||||
embySettings = await EmbySettings.GetSettingsAsync();
|
||||
}
|
||||
foreach (var movie in movies)
|
||||
{
|
||||
viewMovies.Add(await ProcessSingleMovie(movie, dbMovies, plexSettings, embySettings));
|
||||
}
|
||||
return viewMovies;
|
||||
}
|
||||
|
||||
private async Task<SearchMovieViewModel> ProcessSingleMovie(SearchMovieViewModel viewMovie,
|
||||
Dictionary<int, MovieRequestModel> existingRequests, PlexSettings plexSettings, EmbySettings embySettings)
|
||||
Dictionary<int, MovieRequestModel> existingRequests, PlexSettings plexSettings, EmbySettings embySettings, bool lookupExtraInfo = false)
|
||||
{
|
||||
var showInfo = await MovieApi.GetMovieInformation(viewMovie.Id);
|
||||
viewMovie.Id = showInfo.Id; // TheMovieDbId
|
||||
|
||||
if (plexSettings.Enable)
|
||||
{
|
||||
var item = await PlexContentRepo.Get(showInfo.ImdbId);
|
||||
if (item != null)
|
||||
if (lookupExtraInfo)
|
||||
{
|
||||
viewMovie.Available = true;
|
||||
viewMovie.PlexUrl = item.Url;
|
||||
var showInfo = await MovieApi.GetMovieInformation(viewMovie.Id);
|
||||
viewMovie.Id = showInfo.Id; // TheMovieDbId
|
||||
var item = await PlexContentRepo.Get(showInfo.ImdbId);
|
||||
if (item != null)
|
||||
{
|
||||
viewMovie.Available = true;
|
||||
viewMovie.PlexUrl = item.Url;
|
||||
}
|
||||
}
|
||||
|
||||
// var content = PlexContentRepository.GetAll();
|
||||
|
@ -180,10 +218,11 @@ namespace Ombi.Core.Engine
|
|||
}
|
||||
|
||||
RunSearchRules(viewMovie);
|
||||
|
||||
|
||||
return viewMovie;
|
||||
}
|
||||
|
||||
|
||||
private async Task<SearchMovieViewModel> ProcessSingleMovie(MovieSearchResult movie,
|
||||
Dictionary<int, MovieRequestModel> existingRequests, PlexSettings plexSettings, EmbySettings embySettings)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue