|
|
|
@ -3,7 +3,6 @@ using Microsoft.Extensions.Logging;
|
|
|
|
|
using Ombi.Api.TheMovieDb;
|
|
|
|
|
using Ombi.Api.TheMovieDb.Models;
|
|
|
|
|
using Ombi.Core.Models.Requests;
|
|
|
|
|
using Ombi.Core.Models.Requests.Movie;
|
|
|
|
|
using Ombi.Core.Models.Search;
|
|
|
|
|
using Ombi.Core.Rules;
|
|
|
|
|
using Ombi.Core.Settings;
|
|
|
|
@ -49,7 +48,6 @@ namespace Ombi.Core.Engine
|
|
|
|
|
return new List<SearchMovieViewModel>();
|
|
|
|
|
|
|
|
|
|
var retVal = new List<SearchMovieViewModel>();
|
|
|
|
|
var dbMovies = await GetMovieRequests();
|
|
|
|
|
|
|
|
|
|
var plexSettings = await PlexSettings.GetSettingsAsync();
|
|
|
|
|
var embySettings = await EmbySettings.GetSettingsAsync();
|
|
|
|
@ -59,22 +57,20 @@ namespace Ombi.Core.Engine
|
|
|
|
|
var movieInfo = await MovieApi.GetMovieInformationWithVideo(m.Id);
|
|
|
|
|
var viewMovie = Mapper.Map<SearchMovieViewModel>(movieInfo);
|
|
|
|
|
|
|
|
|
|
retVal.Add(await ProcessSingleMovie(viewMovie, dbMovies, plexSettings, embySettings));
|
|
|
|
|
retVal.Add(await ProcessSingleMovie(viewMovie, plexSettings, embySettings));
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
return await ProcessSingleMovie(viewMovie, plexSettings, embySettings, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<SearchMovieViewModel>> Search(string search)
|
|
|
|
@ -148,25 +144,22 @@ namespace Ombi.Core.Engine
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
viewMovies.Add(await ProcessSingleMovie(movie, plexSettings, embySettings));
|
|
|
|
|
}
|
|
|
|
|
return viewMovies;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<SearchMovieViewModel> ProcessSingleMovie(SearchMovieViewModel viewMovie,
|
|
|
|
|
Dictionary<int, MovieRequestModel> existingRequests, PlexSettings plexSettings, EmbySettings embySettings, bool lookupExtraInfo = false)
|
|
|
|
|
PlexSettings plexSettings, EmbySettings embySettings, bool lookupExtraInfo = false)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (plexSettings.Enable)
|
|
|
|
@ -175,25 +168,7 @@ namespace Ombi.Core.Engine
|
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
// var plexMovies = PlexChecker.GetPlexMovies(content);
|
|
|
|
|
|
|
|
|
|
// var plexMovie = PlexChecker.GetMovie(plexMovies.ToArray(), movie.Title,
|
|
|
|
|
// movie.ReleaseDate?.Year.ToString(),
|
|
|
|
|
// viewMovie.ImdbId);
|
|
|
|
|
// if (plexMovie != null)
|
|
|
|
|
// {
|
|
|
|
|
// viewMovie.Available = true;
|
|
|
|
|
// viewMovie.PlexUrl = plexMovie.Url;
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
if (embySettings.Enable)
|
|
|
|
|
{
|
|
|
|
@ -208,26 +183,16 @@ namespace Ombi.Core.Engine
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (existingRequests.ContainsKey(viewMovie.Id)) // Do we already have a request for this?
|
|
|
|
|
{
|
|
|
|
|
var requestedMovie = existingRequests[viewMovie.Id];
|
|
|
|
|
|
|
|
|
|
viewMovie.Requested = true;
|
|
|
|
|
viewMovie.Approved = requestedMovie.Approved;
|
|
|
|
|
viewMovie.Available = requestedMovie.Available;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunSearchRules(viewMovie);
|
|
|
|
|
await RunSearchRules(viewMovie);
|
|
|
|
|
|
|
|
|
|
return viewMovie;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async Task<SearchMovieViewModel> ProcessSingleMovie(MovieSearchResult movie,
|
|
|
|
|
Dictionary<int, MovieRequestModel> existingRequests, PlexSettings plexSettings, EmbySettings embySettings)
|
|
|
|
|
private async Task<SearchMovieViewModel> ProcessSingleMovie(MovieSearchResult movie, PlexSettings plexSettings, EmbySettings embySettings)
|
|
|
|
|
{
|
|
|
|
|
var viewMovie = Mapper.Map<SearchMovieViewModel>(movie);
|
|
|
|
|
return await ProcessSingleMovie(viewMovie, existingRequests, plexSettings, embySettings);
|
|
|
|
|
return await ProcessSingleMovie(viewMovie, plexSettings, embySettings);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|