mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 12:59:39 -07:00
Merge pull request #1178 from smcpeck/master
FEATURE: Search movies by actor
This commit is contained in:
commit
e420d03a77
20 changed files with 440 additions and 136 deletions
8
.github/ISSUE_TEMPLATE.md
vendored
8
.github/ISSUE_TEMPLATE.md
vendored
|
@ -14,6 +14,14 @@ V 1.XX.XX
|
|||
|
||||
Stable/Early Access Preview/development
|
||||
|
||||
#### Media Sever:
|
||||
|
||||
Plex/Emby
|
||||
|
||||
#### Media Server Version:
|
||||
|
||||
<!-- If appropriate --->
|
||||
|
||||
#### Operating System:
|
||||
|
||||
(Place text here)
|
||||
|
|
|
@ -108,7 +108,6 @@ namespace Ombi.Api
|
|||
request.AddHeader("X-Api-Key", apiKey);
|
||||
request.AddJsonBody(options);
|
||||
|
||||
RadarrAddMovie result;
|
||||
try
|
||||
{
|
||||
var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling AddSeries for Sonarr, Retrying {0}", timespan), new TimeSpan[] {
|
||||
|
|
|
@ -37,6 +37,8 @@ using TMDbLib.Objects.General;
|
|||
using TMDbLib.Objects.Movies;
|
||||
using TMDbLib.Objects.Search;
|
||||
using Movie = TMDbLib.Objects.Movies.Movie;
|
||||
using TMDbLib.Objects.People;
|
||||
using System.Linq;
|
||||
|
||||
namespace Ombi.Api
|
||||
{
|
||||
|
@ -69,6 +71,11 @@ namespace Ombi.Api
|
|||
return movies?.Results ?? new List<MovieResult>();
|
||||
}
|
||||
|
||||
private async Task<Movie> GetMovie(int id)
|
||||
{
|
||||
return await Client.GetMovie(id);
|
||||
}
|
||||
|
||||
public TmdbMovieDetails GetMovieInformationWithVideos(int tmdbId)
|
||||
{
|
||||
var request = new RestRequest { Resource = "movie/{movieId}", Method = Method.GET };
|
||||
|
@ -100,5 +107,49 @@ namespace Ombi.Api
|
|||
var movies = await Client.GetMovie(imdbId);
|
||||
return movies ?? new Movie();
|
||||
}
|
||||
|
||||
public async Task<List<Movie>> SearchPerson(string searchTerm)
|
||||
{
|
||||
return await SearchPerson(searchTerm, null);
|
||||
}
|
||||
|
||||
public async Task<List<Movie>> SearchPerson(string searchTerm, Func<int, string, string, Task<bool>> alreadyAvailable)
|
||||
{
|
||||
SearchContainer<SearchPerson> result = await Client.SearchPerson(searchTerm);
|
||||
|
||||
var people = result?.Results ?? new List<SearchPerson>();
|
||||
var person = (people.Count != 0 ? people[0] : null);
|
||||
var movies = new List<Movie>();
|
||||
var counter = 0;
|
||||
try
|
||||
{
|
||||
if (person != null)
|
||||
{
|
||||
var credits = await Client.GetPersonMovieCredits(person.Id);
|
||||
|
||||
// grab results from both cast and crew, prefer items in cast. we can handle directors like this.
|
||||
List<Movie> movieResults = (from MovieRole role in credits.Cast select new Movie() { Id = role.Id, Title = role.Title, ReleaseDate = role.ReleaseDate }).ToList();
|
||||
movieResults.AddRange((from MovieJob job in credits.Crew select new Movie() { Id = job.Id, Title = job.Title, ReleaseDate = job.ReleaseDate }).ToList());
|
||||
|
||||
//only get the first 10 movies and delay a bit between each request so we don't overload the API
|
||||
foreach (var m in movieResults)
|
||||
{
|
||||
if (counter == 10)
|
||||
break;
|
||||
if (alreadyAvailable == null || !(await alreadyAvailable(m.Id, m.Title, m.ReleaseDate.Value.Year.ToString())))
|
||||
{
|
||||
movies.Add(await GetMovie(m.Id));
|
||||
counter++;
|
||||
}
|
||||
await Task.Delay(50);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Log(LogLevel.Error, e);
|
||||
}
|
||||
return movies;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ namespace Ombi.Core.SettingModels
|
|||
public int Port { get; set; }
|
||||
public string BaseUrl { get; set; }
|
||||
public bool SearchForMovies { get; set; }
|
||||
public bool SearchForActors { get; set; }
|
||||
public bool SearchForTvShows { get; set; }
|
||||
public bool SearchForMusic { get; set; }
|
||||
[Obsolete("Use the user management settings")]
|
||||
|
|
|
@ -77,6 +77,7 @@ namespace Ombi.Core
|
|||
{
|
||||
SearchForMovies = true,
|
||||
SearchForTvShows = true,
|
||||
SearchForActors = true,
|
||||
BaseUrl = baseUrl ?? string.Empty,
|
||||
CollectAnalyticData = true,
|
||||
};
|
||||
|
|
|
@ -202,6 +202,7 @@ namespace Ombi.Core.StatusChecker
|
|||
|
||||
public async Task<Uri> OAuth(string url, ISession session)
|
||||
{
|
||||
await Task.Yield();
|
||||
|
||||
var csrf = StringCipher.Encrypt(Guid.NewGuid().ToString("N"), "CSRF");
|
||||
session[SessionKeys.CSRF] = csrf;
|
||||
|
|
|
@ -37,15 +37,15 @@ namespace Ombi.Services.Interfaces
|
|||
void Start();
|
||||
void CheckAndUpdateAll();
|
||||
IEnumerable<PlexContent> GetPlexMovies(IEnumerable<PlexContent> content);
|
||||
bool IsMovieAvailable(PlexContent[] plexMovies, string title, string year, string providerId = null);
|
||||
bool IsMovieAvailable(IEnumerable<PlexContent> plexMovies, string title, string year, string providerId = null);
|
||||
IEnumerable<PlexContent> GetPlexTvShows(IEnumerable<PlexContent> content);
|
||||
bool IsTvShowAvailable(PlexContent[] plexShows, string title, string year, string providerId = null, int[] seasons = null);
|
||||
bool IsTvShowAvailable(IEnumerable<PlexContent> plexShows, string title, string year, string providerId = null, int[] seasons = null);
|
||||
IEnumerable<PlexContent> GetPlexAlbums(IEnumerable<PlexContent> content);
|
||||
bool IsAlbumAvailable(PlexContent[] plexAlbums, string title, string year, string artist);
|
||||
bool IsAlbumAvailable(IEnumerable<PlexContent> plexAlbums, string title, string year, string artist);
|
||||
bool IsEpisodeAvailable(string theTvDbId, int season, int episode);
|
||||
PlexContent GetAlbum(PlexContent[] plexAlbums, string title, string year, string artist);
|
||||
PlexContent GetMovie(PlexContent[] plexMovies, string title, string year, string providerId = null);
|
||||
PlexContent GetTvShow(PlexContent[] plexShows, string title, string year, string providerId = null, int[] seasons = null);
|
||||
PlexContent GetAlbum(IEnumerable<PlexContent> plexAlbums, string title, string year, string artist);
|
||||
PlexContent GetMovie(IEnumerable<PlexContent> plexMovies, string title, string year, string providerId = null);
|
||||
PlexContent GetTvShow(IEnumerable<PlexContent> plexShows, string title, string year, string providerId = null, int[] seasons = null);
|
||||
/// <summary>
|
||||
/// Gets the episode's stored in the cache.
|
||||
/// </summary>
|
||||
|
|
|
@ -161,15 +161,15 @@ namespace Ombi.Services.Jobs
|
|||
return content.Where(x => x.Type == EmbyMediaType.Movie);
|
||||
}
|
||||
|
||||
public bool IsMovieAvailable(EmbyContent[] embyMovies, string title, string year, string providerId)
|
||||
public bool IsMovieAvailable(IEnumerable<EmbyContent> embyMovies, string title, string year, string providerId)
|
||||
{
|
||||
var movie = GetMovie(embyMovies, title, year, providerId);
|
||||
return movie != null;
|
||||
}
|
||||
|
||||
public EmbyContent GetMovie(EmbyContent[] embyMovies, string title, string year, string providerId)
|
||||
public EmbyContent GetMovie(IEnumerable<EmbyContent> embyMovies, string title, string year, string providerId)
|
||||
{
|
||||
if (embyMovies.Length == 0)
|
||||
if (embyMovies.Count() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -200,14 +200,14 @@ namespace Ombi.Services.Jobs
|
|||
return content.Where(x => x.Type == EmbyMediaType.Series);
|
||||
}
|
||||
|
||||
public bool IsTvShowAvailable(EmbyContent[] embyShows, string title, string year, string providerId, int[] seasons = null)
|
||||
public bool IsTvShowAvailable(IEnumerable<EmbyContent> embyShows, string title, string year, string providerId, int[] seasons = null)
|
||||
{
|
||||
var show = GetTvShow(embyShows, title, year, providerId, seasons);
|
||||
return show != null;
|
||||
}
|
||||
|
||||
|
||||
public EmbyContent GetTvShow(EmbyContent[] embyShows, string title, string year, string providerId,
|
||||
public EmbyContent GetTvShow(IEnumerable<EmbyContent> embyShows, string title, string year, string providerId,
|
||||
int[] seasons = null)
|
||||
{
|
||||
foreach (var show in embyShows)
|
||||
|
|
|
@ -14,11 +14,11 @@ namespace Ombi.Services.Jobs
|
|||
IEnumerable<EmbyContent> GetEmbyTvShows(IEnumerable<EmbyContent> content);
|
||||
Task<IEnumerable<EmbyEpisodes>> GetEpisodes();
|
||||
Task<IEnumerable<EmbyEpisodes>> GetEpisodes(int theTvDbId);
|
||||
EmbyContent GetMovie(EmbyContent[] embyMovies, string title, string year, string providerId);
|
||||
EmbyContent GetTvShow(EmbyContent[] embyShows, string title, string year, string providerId, int[] seasons = null);
|
||||
EmbyContent GetMovie(IEnumerable<EmbyContent> embyMovies, string title, string year, string providerId);
|
||||
EmbyContent GetTvShow(IEnumerable<EmbyContent> embyShows, string title, string year, string providerId, int[] seasons = null);
|
||||
bool IsEpisodeAvailable(string theTvDbId, int season, int episode);
|
||||
bool IsMovieAvailable(EmbyContent[] embyMovies, string title, string year, string providerId);
|
||||
bool IsTvShowAvailable(EmbyContent[] embyShows, string title, string year, string providerId, int[] seasons = null);
|
||||
bool IsMovieAvailable(IEnumerable<EmbyContent> embyMovies, string title, string year, string providerId);
|
||||
bool IsTvShowAvailable(IEnumerable<EmbyContent> embyShows, string title, string year, string providerId, int[] seasons = null);
|
||||
void Start();
|
||||
}
|
||||
}
|
|
@ -194,15 +194,15 @@ namespace Ombi.Services.Jobs
|
|||
return content.Where(x => x.Type == Store.Models.Plex.PlexMediaType.Movie);
|
||||
}
|
||||
|
||||
public bool IsMovieAvailable(PlexContent[] plexMovies, string title, string year, string providerId = null)
|
||||
public bool IsMovieAvailable(IEnumerable<PlexContent> plexMovies, string title, string year, string providerId = null)
|
||||
{
|
||||
var movie = GetMovie(plexMovies, title, year, providerId);
|
||||
return movie != null;
|
||||
}
|
||||
|
||||
public PlexContent GetMovie(PlexContent[] plexMovies, string title, string year, string providerId = null)
|
||||
public PlexContent GetMovie(IEnumerable<PlexContent> plexMovies, string title, string year, string providerId = null)
|
||||
{
|
||||
if (plexMovies.Length == 0)
|
||||
if (plexMovies.Count() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -236,14 +236,14 @@ namespace Ombi.Services.Jobs
|
|||
return content.Where(x => x.Type == Store.Models.Plex.PlexMediaType.Show);
|
||||
}
|
||||
|
||||
public bool IsTvShowAvailable(PlexContent[] plexShows, string title, string year, string providerId = null, int[] seasons = null)
|
||||
public bool IsTvShowAvailable(IEnumerable<PlexContent> plexShows, string title, string year, string providerId = null, int[] seasons = null)
|
||||
{
|
||||
var show = GetTvShow(plexShows, title, year, providerId, seasons);
|
||||
return show != null;
|
||||
}
|
||||
|
||||
|
||||
public PlexContent GetTvShow(PlexContent[] plexShows, string title, string year, string providerId = null,
|
||||
public PlexContent GetTvShow(IEnumerable<PlexContent> plexShows, string title, string year, string providerId = null,
|
||||
int[] seasons = null)
|
||||
{
|
||||
var advanced = !string.IsNullOrEmpty(providerId);
|
||||
|
@ -345,14 +345,14 @@ namespace Ombi.Services.Jobs
|
|||
return content.Where(x => x.Type == Store.Models.Plex.PlexMediaType.Artist);
|
||||
}
|
||||
|
||||
public bool IsAlbumAvailable(PlexContent[] plexAlbums, string title, string year, string artist)
|
||||
public bool IsAlbumAvailable(IEnumerable<PlexContent> plexAlbums, string title, string year, string artist)
|
||||
{
|
||||
return plexAlbums.Any(x =>
|
||||
x.Title.Contains(title) &&
|
||||
x.Artist.Equals(artist, StringComparison.CurrentCultureIgnoreCase));
|
||||
}
|
||||
|
||||
public PlexContent GetAlbum(PlexContent[] plexAlbums, string title, string year, string artist)
|
||||
public PlexContent GetAlbum(IEnumerable<PlexContent> plexAlbums, string title, string year, string artist)
|
||||
{
|
||||
return plexAlbums.FirstOrDefault(x =>
|
||||
x.Title.Contains(title) &&
|
||||
|
|
36
Ombi.UI/Content/requests.js
vendored
36
Ombi.UI/Content/requests.js
vendored
|
@ -95,7 +95,10 @@ $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
|||
//if ($tvl.mixItUp('isLoaded')) $tvl.mixItUp('destroy');
|
||||
//$tvl.mixItUp(mixItUpConfig(activeState)); // init or reinit
|
||||
}
|
||||
if (target === "#MoviesTab") {
|
||||
if (target === "#MoviesTab" || target === "#ActorsTab") {
|
||||
if (target === "#ActorsTab") {
|
||||
actorLoad();
|
||||
}
|
||||
$('#approveMovies,#deleteMovies').show();
|
||||
if ($tvl.mixItUp('isLoaded')) {
|
||||
activeState = $tvl.mixItUp('getState');
|
||||
|
@ -733,6 +736,37 @@ function initLoad() {
|
|||
|
||||
}
|
||||
|
||||
|
||||
function actorLoad() {
|
||||
var $ml = $('#actorMovieList');
|
||||
if ($ml.mixItUp('isLoaded')) {
|
||||
activeState = $ml.mixItUp('getState');
|
||||
$ml.mixItUp('destroy');
|
||||
}
|
||||
$ml.html("");
|
||||
|
||||
var $newOnly = $('#searchNewOnly').val();
|
||||
var url = createBaseUrl(base, '/requests/actor' + (!!$newOnly ? '/new' : ''));
|
||||
$.ajax(url).success(function (results) {
|
||||
if (results.length > 0) {
|
||||
results.forEach(function (result) {
|
||||
var context = buildRequestContext(result, "movie");
|
||||
var html = searchTemplate(context);
|
||||
$ml.append(html);
|
||||
});
|
||||
|
||||
|
||||
$('.customTooltip').tooltipster({
|
||||
contentCloning: true
|
||||
});
|
||||
}
|
||||
else {
|
||||
$ml.html(noResultsHtml.format("movie"));
|
||||
}
|
||||
$ml.mixItUp(mixItUpConfig());
|
||||
});
|
||||
};
|
||||
|
||||
function movieLoad() {
|
||||
var $ml = $('#movieList');
|
||||
if ($ml.mixItUp('isLoaded')) {
|
||||
|
|
48
Ombi.UI/Content/search.js
vendored
48
Ombi.UI/Content/search.js
vendored
|
@ -63,6 +63,26 @@ $(function () {
|
|||
|
||||
});
|
||||
|
||||
// Type in actor search
|
||||
$("#actorSearchContent").on("input", function () {
|
||||
triggerActorSearch();
|
||||
});
|
||||
|
||||
// if they toggle the checkbox, we want to refresh our search
|
||||
$("#actorsSearchNew").click(function () {
|
||||
triggerActorSearch();
|
||||
});
|
||||
|
||||
function triggerActorSearch()
|
||||
{
|
||||
if (searchTimer) {
|
||||
clearTimeout(searchTimer);
|
||||
}
|
||||
searchTimer = setTimeout(function () {
|
||||
moviesFromActor();
|
||||
}.bind(this), 800);
|
||||
}
|
||||
|
||||
$('#moviesComingSoon').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
moviesComingSoon();
|
||||
|
@ -300,7 +320,7 @@ $(function () {
|
|||
function movieSearch() {
|
||||
var query = $("#movieSearchContent").val();
|
||||
var url = createBaseUrl(base, '/search/movie/');
|
||||
query ? getMovies(url + query) : resetMovies();
|
||||
query ? getMovies(url + query) : resetMovies("#movieList");
|
||||
}
|
||||
|
||||
function moviesComingSoon() {
|
||||
|
@ -313,6 +333,13 @@ $(function () {
|
|||
getMovies(url);
|
||||
}
|
||||
|
||||
function moviesFromActor() {
|
||||
var query = $("#actorSearchContent").val();
|
||||
var $newOnly = $('#actorsSearchNew')[0].checked;
|
||||
var url = createBaseUrl(base, '/search/actor/' + (!!$newOnly ? 'new/' : ''));
|
||||
query ? getMovies(url + query, "#actorMovieList", "#actorSearchButton") : resetMovies("#actorMovieList");
|
||||
}
|
||||
|
||||
function popularShows() {
|
||||
var url = createBaseUrl(base, '/search/tv/popular');
|
||||
getTvShows(url, true);
|
||||
|
@ -330,30 +357,31 @@ $(function () {
|
|||
getTvShows(url, true);
|
||||
}
|
||||
|
||||
function getMovies(url) {
|
||||
resetMovies();
|
||||
|
||||
$('#movieSearchButton').attr("class", "fa fa-spinner fa-spin");
|
||||
function getMovies(url, target, button) {
|
||||
target = target || "#movieList";
|
||||
button = button || "#movieSearchButton";
|
||||
resetMovies(target);
|
||||
$(button).attr("class", "fa fa-spinner fa-spin");
|
||||
$.ajax(url).success(function (results) {
|
||||
if (results.length > 0) {
|
||||
results.forEach(function (result) {
|
||||
var context = buildMovieContext(result);
|
||||
|
||||
var html = searchTemplate(context);
|
||||
$("#movieList").append(html);
|
||||
$(target).append(html);
|
||||
|
||||
checkNetflix(context.title, context.id);
|
||||
});
|
||||
}
|
||||
else {
|
||||
$("#movieList").html(noResultsHtml);
|
||||
$(target).html(noResultsHtml);
|
||||
}
|
||||
$('#movieSearchButton').attr("class", "fa fa-search");
|
||||
$(button).attr("class", "fa fa-search");
|
||||
});
|
||||
};
|
||||
|
||||
function resetMovies() {
|
||||
$("#movieList").html("");
|
||||
function resetMovies(target) {
|
||||
$(target).html("");
|
||||
}
|
||||
|
||||
function tvSearch() {
|
||||
|
|
|
@ -94,6 +94,8 @@ namespace Ombi.UI.Modules.Admin
|
|||
|
||||
private async Task<Response> ScheduleRun(string key)
|
||||
{
|
||||
await Task.Yield();
|
||||
|
||||
if (key.Equals(JobNames.PlexCacher, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
PlexContentCacher.CacheContent();
|
||||
|
|
|
@ -47,6 +47,8 @@ namespace Ombi.UI.Modules
|
|||
|
||||
public async Task<Response> Netflix(string title)
|
||||
{
|
||||
await Task.Yield();
|
||||
|
||||
var result = NetflixApi.CheckNetflix(title);
|
||||
|
||||
if (!string.IsNullOrEmpty(result.Message))
|
||||
|
|
|
@ -121,6 +121,8 @@ namespace Ombi.UI.Modules
|
|||
|
||||
Get["SearchIndex", "/", true] = async (x, ct) => await RequestLoad();
|
||||
|
||||
Get["actor/{searchTerm}", true] = async (x, ct) => await SearchPerson((string)x.searchTerm);
|
||||
Get["actor/new/{searchTerm}", true] = async (x, ct) => await SearchPerson((string)x.searchTerm, true);
|
||||
Get["movie/{searchTerm}", true] = async (x, ct) => await SearchMovie((string)x.searchTerm);
|
||||
Get["tv/{searchTerm}", true] = async (x, ct) => await SearchTvShow((string)x.searchTerm);
|
||||
Get["music/{searchTerm}", true] = async (x, ct) => await SearchAlbum((string)x.searchTerm);
|
||||
|
@ -182,9 +184,18 @@ namespace Ombi.UI.Modules
|
|||
private ISettingsService<CustomizationSettings> CustomizationSettings { get; }
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private long _plexMovieCacheTime = 0;
|
||||
private IEnumerable<PlexContent> _plexMovies = null;
|
||||
|
||||
private long _embyMovieCacheTime = 0;
|
||||
private IEnumerable<EmbyContent> _embyMovies = null;
|
||||
|
||||
|
||||
private long _dbMovieCacheTime = 0;
|
||||
private Dictionary<int, RequestedModel> _dbMovies = null;
|
||||
|
||||
private async Task<Negotiator> RequestLoad()
|
||||
{
|
||||
|
||||
var settings = await PrService.GetSettingsAsync();
|
||||
var custom = await CustomizationSettings.GetSettingsAsync();
|
||||
var emby = await EmbySettings.GetSettingsAsync();
|
||||
|
@ -222,6 +233,53 @@ namespace Ombi.UI.Modules
|
|||
return await ProcessMovies(MovieSearchType.Search, searchTerm);
|
||||
}
|
||||
|
||||
private async Task<Response> SearchPerson(string searchTerm)
|
||||
{
|
||||
var movies = TransformMovieListToMovieResultList(await MovieApi.SearchPerson(searchTerm));
|
||||
return await TransformMovieResultsToResponse(movies);
|
||||
}
|
||||
|
||||
private async Task<Response> SearchPerson(string searchTerm, bool filterExisting)
|
||||
{
|
||||
var movies = TransformMovieListToMovieResultList(await MovieApi.SearchPerson(searchTerm, AlreadyAvailable));
|
||||
return await TransformMovieResultsToResponse(movies);
|
||||
}
|
||||
|
||||
private async Task<bool> AlreadyAvailable(int id, string title, string year)
|
||||
{
|
||||
var plexSettings = await PlexService.GetSettingsAsync();
|
||||
var embySettings = await EmbySettings.GetSettingsAsync();
|
||||
|
||||
return IsMovieInCache(id, String.Empty) ||
|
||||
(plexSettings.Enable && PlexChecker.IsMovieAvailable(PlexMovies(), title, year)) ||
|
||||
(embySettings.Enable && EmbyChecker.IsMovieAvailable(EmbyMovies(), title, year, String.Empty));
|
||||
}
|
||||
|
||||
private IEnumerable<PlexContent> PlexMovies()
|
||||
{ long now = DateTime.Now.Ticks;
|
||||
if(_plexMovies == null || (now - _plexMovieCacheTime) > 10000)
|
||||
{
|
||||
var content = PlexContentRepository.GetAll();
|
||||
_plexMovies = PlexChecker.GetPlexMovies(content);
|
||||
_plexMovieCacheTime = now;
|
||||
}
|
||||
|
||||
return _plexMovies;
|
||||
}
|
||||
|
||||
private IEnumerable<EmbyContent> EmbyMovies()
|
||||
{
|
||||
long now = DateTime.Now.Ticks;
|
||||
if (_embyMovies == null || (now - _embyMovieCacheTime) > 10000)
|
||||
{
|
||||
var content = EmbyContentRepository.GetAll();
|
||||
_embyMovies = EmbyChecker.GetEmbyMovies(content);
|
||||
_embyMovieCacheTime = now;
|
||||
}
|
||||
|
||||
return _embyMovies;
|
||||
}
|
||||
|
||||
private Response GetTvPoster(int theTvDbId)
|
||||
{
|
||||
var result = TvApi.ShowLookupByTheTvDbId(theTvDbId);
|
||||
|
@ -233,15 +291,10 @@ namespace Ombi.UI.Modules
|
|||
}
|
||||
return banner;
|
||||
}
|
||||
private async Task<Response> ProcessMovies(MovieSearchType searchType, string searchTerm)
|
||||
{
|
||||
List<MovieResult> apiMovies;
|
||||
|
||||
switch (searchType)
|
||||
{
|
||||
case MovieSearchType.Search:
|
||||
var movies = await MovieApi.SearchMovie(searchTerm).ConfigureAwait(false);
|
||||
apiMovies = movies.Select(x =>
|
||||
private List<MovieResult> TransformSearchMovieListToMovieResultList(List<TMDbLib.Objects.Search.SearchMovie> searchMovies)
|
||||
{
|
||||
return searchMovies.Select(x =>
|
||||
new MovieResult
|
||||
{
|
||||
Adult = x.Adult,
|
||||
|
@ -260,6 +313,39 @@ namespace Ombi.UI.Modules
|
|||
VoteCount = x.VoteCount
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private List<MovieResult> TransformMovieListToMovieResultList(List<TMDbLib.Objects.Movies.Movie> movies)
|
||||
{
|
||||
return movies.Select(x =>
|
||||
new MovieResult
|
||||
{
|
||||
Adult = x.Adult,
|
||||
BackdropPath = x.BackdropPath,
|
||||
GenreIds = x.Genres.Select(y => y.Id).ToList(),
|
||||
Id = x.Id,
|
||||
OriginalLanguage = x.OriginalLanguage,
|
||||
OriginalTitle = x.OriginalTitle,
|
||||
Overview = x.Overview,
|
||||
Popularity = x.Popularity,
|
||||
PosterPath = x.PosterPath,
|
||||
ReleaseDate = x.ReleaseDate,
|
||||
Title = x.Title,
|
||||
Video = x.Video,
|
||||
VoteAverage = x.VoteAverage,
|
||||
VoteCount = x.VoteCount
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
private async Task<Response> ProcessMovies(MovieSearchType searchType, string searchTerm)
|
||||
{
|
||||
List<MovieResult> apiMovies;
|
||||
|
||||
switch (searchType)
|
||||
{
|
||||
case MovieSearchType.Search:
|
||||
var movies = await MovieApi.SearchMovie(searchTerm).ConfigureAwait(false);
|
||||
apiMovies = TransformSearchMovieListToMovieResultList(movies);
|
||||
break;
|
||||
case MovieSearchType.CurrentlyPlaying:
|
||||
apiMovies = await MovieApi.GetCurrentPlayingMovies();
|
||||
|
@ -272,20 +358,31 @@ namespace Ombi.UI.Modules
|
|||
break;
|
||||
}
|
||||
|
||||
var allResults = await RequestService.GetAllAsync();
|
||||
allResults = allResults.Where(x => x.Type == RequestType.Movie);
|
||||
return await TransformMovieResultsToResponse(apiMovies);
|
||||
}
|
||||
|
||||
var distinctResults = allResults.DistinctBy(x => x.ProviderId);
|
||||
var dbMovies = distinctResults.ToDictionary(x => x.ProviderId);
|
||||
private async Task<Dictionary<int, RequestedModel>> RequestedMovies()
|
||||
{
|
||||
long now = DateTime.Now.Ticks;
|
||||
if (_dbMovies == null || (now - _dbMovieCacheTime) > 10000)
|
||||
{
|
||||
var allResults = await RequestService.GetAllAsync();
|
||||
allResults = allResults.Where(x => x.Type == RequestType.Movie);
|
||||
|
||||
var distinctResults = allResults.DistinctBy(x => x.ProviderId);
|
||||
_dbMovies = distinctResults.ToDictionary(x => x.ProviderId);
|
||||
_dbMovieCacheTime = now;
|
||||
}
|
||||
return _dbMovies;
|
||||
}
|
||||
|
||||
var cpCached = CpCacher.QueuedIds();
|
||||
var watcherCached = WatcherCacher.QueuedIds();
|
||||
var radarrCached = RadarrCacher.QueuedIds();
|
||||
|
||||
private async Task<Response> TransformMovieResultsToResponse(List<MovieResult> movies)
|
||||
{
|
||||
await Task.Yield();
|
||||
var viewMovies = new List<SearchMovieViewModel>();
|
||||
var counter = 0;
|
||||
foreach (var movie in apiMovies)
|
||||
Dictionary<int, RequestedModel> dbMovies = await RequestedMovies();
|
||||
foreach (var movie in movies)
|
||||
{
|
||||
var viewMovie = new SearchMovieViewModel
|
||||
{
|
||||
|
@ -362,20 +459,11 @@ namespace Ombi.UI.Modules
|
|||
viewMovie.Approved = dbm.Approved;
|
||||
viewMovie.Available = dbm.Available;
|
||||
}
|
||||
if (cpCached.Contains(movie.Id) && canSee) // compare to the couchpotato db
|
||||
else if (canSee)
|
||||
{
|
||||
viewMovie.Approved = true;
|
||||
viewMovie.Requested = true;
|
||||
}
|
||||
if (watcherCached.Contains(viewMovie.ImdbId) && canSee) // compare to the watcher db
|
||||
{
|
||||
viewMovie.Approved = true;
|
||||
viewMovie.Requested = true;
|
||||
}
|
||||
if (radarrCached.Contains(movie.Id) && canSee)
|
||||
{
|
||||
viewMovie.Approved = true;
|
||||
viewMovie.Requested = true;
|
||||
bool exists = IsMovieInCache(movie, viewMovie.ImdbId);
|
||||
viewMovie.Approved = exists;
|
||||
viewMovie.Requested = exists;
|
||||
}
|
||||
viewMovies.Add(viewMovie);
|
||||
}
|
||||
|
@ -383,6 +471,19 @@ namespace Ombi.UI.Modules
|
|||
return Response.AsJson(viewMovies);
|
||||
}
|
||||
|
||||
private bool IsMovieInCache(MovieResult movie, string imdbId)
|
||||
{ int id = movie.Id;
|
||||
return IsMovieInCache(id, imdbId);
|
||||
}
|
||||
|
||||
private bool IsMovieInCache(int id, string imdbId)
|
||||
{ var cpCached = CpCacher.QueuedIds();
|
||||
var watcherCached = WatcherCacher.QueuedIds();
|
||||
var radarrCached = RadarrCacher.QueuedIds();
|
||||
|
||||
return cpCached.Contains(id) || watcherCached.Contains(imdbId) || radarrCached.Contains(id);
|
||||
}
|
||||
|
||||
private bool CanUserSeeThisRequest(int movieId, bool usersCanViewOnlyOwnRequests,
|
||||
Dictionary<int, RequestedModel> moviesInDb)
|
||||
{
|
||||
|
|
|
@ -1,76 +1,96 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 1.3
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">1.3</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
</data>
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
|
@ -89,13 +109,13 @@
|
|||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="UserLogin_Title" xml:space="preserve">
|
||||
<value>Login</value>
|
||||
|
@ -191,6 +211,9 @@
|
|||
<data name="Search_Albums" xml:space="preserve">
|
||||
<value>Albums</value>
|
||||
</data>
|
||||
<data name="Search_NewOnly" xml:space="preserve">
|
||||
<value>Don't include titles that are already requested/available</value>
|
||||
</data>
|
||||
<data name="Search_Paragraph" xml:space="preserve">
|
||||
<value>Want to watch something that is not currently on {0}?! No problem! Just search for it below and request it!</value>
|
||||
</data>
|
||||
|
@ -473,4 +496,7 @@
|
|||
<data name="UserLogin_AdminUsePassword" xml:space="preserve">
|
||||
<value>If you are an administrator, please use the other login page</value>
|
||||
</data>
|
||||
<data name="Search_Actors" xml:space="preserve">
|
||||
<value>Actors</value>
|
||||
</data>
|
||||
</root>
|
18
Ombi.UI/Resources/UI1.Designer.cs
generated
18
Ombi.UI/Resources/UI1.Designer.cs
generated
|
@ -717,6 +717,15 @@ namespace Ombi.UI.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Actors.
|
||||
/// </summary>
|
||||
public static string Search_Actors {
|
||||
get {
|
||||
return ResourceManager.GetString("Search_Actors", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Albums.
|
||||
/// </summary>
|
||||
|
@ -879,6 +888,15 @@ namespace Ombi.UI.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Don't include titles that are already requested/available.
|
||||
/// </summary>
|
||||
public static string Search_NewOnly {
|
||||
get {
|
||||
return ResourceManager.GetString("Search_NewOnly", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Not Requested yet.
|
||||
/// </summary>
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
|
||||
@Html.Checkbox(Model.SearchForMovies,"SearchForMovies","Search for Movies")
|
||||
|
||||
@Html.Checkbox(Model.SearchForActors,"SearchForActors","Search for Movies by Actor")
|
||||
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
|
|
|
@ -27,6 +27,13 @@
|
|||
<a id="movieTabButton" href="#MoviesTab" aria-controls="home" role="tab" data-toggle="tab"><i class="fa fa-film"></i> @UI.Search_Movies</a>
|
||||
|
||||
</li>
|
||||
@if (Model.Settings.SearchForActors)
|
||||
{
|
||||
<li role="presentation">
|
||||
<a id="actorTabButton" href="#ActorsTab" aria-controls="profile" role="tab" data-toggle="tab"><i class="fa fa-users"></i> @UI.Search_Actors</a>
|
||||
|
||||
</li>
|
||||
}
|
||||
}
|
||||
@if (Model.Settings.SearchForTvShows)
|
||||
{
|
||||
|
@ -72,8 +79,28 @@
|
|||
<div id="movieList">
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@if (Model.Settings.SearchForActors)
|
||||
{
|
||||
<!-- Actors tab -->
|
||||
<div role="tabpanel" class="tab-pane" id="ActorsTab">
|
||||
<div class="input-group">
|
||||
<input id="actorSearchContent" type="text" class="form-control form-control-custom form-control-search form-control-withbuttons">
|
||||
<div class="input-group-addon">
|
||||
<i id="actorSearchButton" class="fa fa-search"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<input type="checkbox" id="actorsSearchNew" name="actorsSearchNew"><label for="actorsSearchNew">@UI.Search_NewOnly</label>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<!-- Movie content -->
|
||||
<div id="actorMovieList">
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@if (Model.Settings.SearchForTvShows)
|
||||
{
|
||||
|
@ -123,7 +150,7 @@
|
|||
}
|
||||
|
||||
|
||||
<script id="search-templateNew" type="text/x-handlebars-template">
|
||||
<script id="search-templateNew" type="text/x-handlebars-template">
|
||||
<div class="row">
|
||||
<div id="{{id}}imgDiv" class="col-sm-2">
|
||||
|
||||
|
@ -287,7 +314,7 @@
|
|||
</script>
|
||||
|
||||
<!-- Movie and TV Results template -->
|
||||
<script id="search-template" type="text/x-handlebars-template">
|
||||
<script id="search-template" type="text/x-handlebars-template">
|
||||
<div class="row">
|
||||
<div id="{{id}}imgDiv" class="col-sm-2">
|
||||
|
||||
|
|
16
README.md
16
README.md
|
@ -8,20 +8,20 @@ ____
|
|||
[](https://github.com/tidusjar/Ombi)
|
||||
[](http://waffle.io/tidusjar/Ombi)
|
||||
|
||||
[](https://github.com/tidusjar/Ombi/issues/new) [](http://feathub.com/tidusjar/Ombi)
|
||||
|
||||
| Service | Master | Early Access | Dev |
|
||||
|----------|:---------------------------:|:----------------------------:|:----------------------------:|
|
||||
| AppVeyor | [](https://ci.appveyor.com/project/tidusjar/requestplex/branch/master) | [](https://ci.appveyor.com/project/tidusjar/requestplex/branch/eap) | [](https://ci.appveyor.com/project/tidusjar/requestplex/branch/dev)
|
||||
| Travis | [](https://travis-ci.org/tidusjar/Ombi) | [](https://travis-ci.org/tidusjar/Ombi) | [](https://travis-ci.org/tidusjar/Ombi)
|
||||
|
||||
| Download |[](https://github.com/tidusjar/Ombi/releases) | [](https://ci.appveyor.com/project/tidusjar/requestplex/branch/eap/artifacts) | [](https://ci.appveyor.com/project/tidusjar/requestplex/branch/dev/artifacts) |
|
||||
# Features
|
||||
Here some of the features Ombi has:
|
||||
* All your users to Request Movies, TV Shows (Whole series, whole seaons or even single episodes!) and Albums
|
||||
* Easily manage your requests
|
||||
|
||||
* User management system (supports plex.tv accounts and local accounts) [NEW]
|
||||
* Sending newsletters [NEW]
|
||||
* Fault Queue for requests (Buffer requests if Sonar/Couchpotato/SickRage is offline) [NEW]
|
||||
|
||||
* User management system (supports plex.tv accounts and local accounts)
|
||||
* Sending newsletters
|
||||
* Fault Queue for requests (Buffer requests if Sonar/Couchpotato/SickRage is offline)
|
||||
* Allow your users to report issues and manage them separately
|
||||
* A landing page that will give you the availability of your Plex server and also add custom notification text to inform your users of downtime.
|
||||
* Allow your users to get notifications!
|
||||
|
@ -35,9 +35,12 @@ Here some of the features Ombi has:
|
|||
### Integration
|
||||
We integrate with the following applications:
|
||||
* Plex server 1.2 (and higher)
|
||||
* Emby (beta)
|
||||
* Sonarr
|
||||
* SickRage
|
||||
* CouchPotato
|
||||
* Radarr (beta)
|
||||
* Watcher (beta)
|
||||
* Headphones
|
||||
|
||||
### Notifications
|
||||
|
@ -46,6 +49,7 @@ Supported notifications:
|
|||
* Pushbullet
|
||||
* Pushover
|
||||
* Slack
|
||||
* Discord
|
||||
* Weekly Recently Added email notification to all of your Plex Users!
|
||||
|
||||
# Feature Requests
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue