fix(mediaserver): fixed an issue where we were not detecting available content correctly #4542

pull/4552/head
tidusjar 3 years ago
parent a2be81d634
commit 9cdd6f41cd

@ -8,10 +8,8 @@ namespace Ombi.Api.TvMaze
public interface ITvMazeApi
{
Task<IEnumerable<TvMazeEpisodes>> EpisodeLookup(int showId);
Task<List<TvMazeSeasons>> GetSeasons(int id);
Task<List<TvMazeSearch>> Search(string searchTerm);
Task<TvMazeShow> ShowLookup(int showId);
Task<TvMazeShow> ShowLookupByTheTvDbId(int theTvDbId);
Task<FullSearch> GetTvFullInformation(int id);
}
}

@ -64,27 +64,5 @@ namespace Ombi.Api.TvMaze
return null;
}
}
public async Task<List<TvMazeSeasons>> GetSeasons(int id)
{
var request = new Request($"shows/{id}/seasons", Uri, HttpMethod.Get);
request.AddContentHeader("Content-Type", "application/json");
return await Api.Request<List<TvMazeSeasons>>(request);
}
public async Task<FullSearch> GetTvFullInformation(int id)
{
var request = new Request($"shows/{id}", Uri, HttpMethod.Get);
request.AddQueryString("embed[]", "cast");
request.AddQueryString("embed[]", "crew");
request.AddQueryString("embed[]", "episodes");
request.AddContentHeader("Content-Type", "application/json");
return await Api.Request<FullSearch>(request);
}
}
}

@ -46,7 +46,7 @@ namespace Ombi.Core.Engine
{
langCode = await DefaultLanguageCode(langCode);
var movieInfo = await Cache.GetOrAddAsync(nameof(LookupImdbInformation) + langCode + theMovieDbId,
() => MovieApi.GetMovieInformationWithExtraInfo(theMovieDbId, langCode),
() => MovieApi.GetMovieInformationWithExtraInfo(theMovieDbId, langCode),
DateTimeOffset.Now.AddHours(12));
var viewMovie = Mapper.Map<SearchMovieViewModel>(movieInfo);
@ -81,11 +81,11 @@ namespace Ombi.Core.Engine
{
return resultSet;
}
// Get this person movie credits
var credits = await MovieApi.GetActorMovieCredits(person.id, langaugeCode);
// Grab results from both cast and crew, prefer items in cast. we can handle directors like this.
var movieResults = (from role in credits.cast select new { Id = role.id, Title = role.title, ReleaseDate = role.release_date }).ToList();
var movieResults = (from role in credits.cast select new { Id = role.id, Title = role.title, ReleaseDate = role.release_date }).ToList();
movieResults.AddRange((from job in credits.crew select new { Id = job.id, Title = job.title, ReleaseDate = job.release_date }).ToList());
movieResults = movieResults.Take(10).ToList();
@ -120,7 +120,7 @@ namespace Ombi.Core.Engine
/// <returns></returns>
public async Task<IEnumerable<SearchMovieViewModel>> PopularMovies()
{
var result = await Cache.GetOrAddAsync(CacheKeys.PopularMovies, async () =>
{
var langCode = await DefaultLanguageCode(null);
@ -201,7 +201,7 @@ namespace Ombi.Core.Engine
protected async Task<SearchMovieViewModel> ProcessSingleMovie(SearchMovieViewModel viewMovie, bool lookupExtraInfo = false)
{
if (lookupExtraInfo && viewMovie.ImdbId.IsNullOrEmpty())
if (lookupExtraInfo && viewMovie.ImdbId.IsNullOrEmpty() && viewMovie.Id > 0)
{
var showInfo = await MovieApi.GetMovieInformation(viewMovie.Id);
viewMovie.Id = showInfo.Id; // TheMovieDbId
@ -217,7 +217,7 @@ namespace Ombi.Core.Engine
// This requires the rules to be run first to populate the RequestId property
await CheckForSubscription(viewMovie);
return viewMovie;
}

@ -86,7 +86,7 @@ namespace Ombi.Schedule.Jobs.Emby
}
// If we have a non-4k versison then mark as available
if (embyContent.Quality.HasValue() && !movie.Available)
if (embyContent.Quality != null && !movie.Available)
{
movie.Available = true;
movie.MarkedAsAvailable = DateTime.Now;

@ -111,7 +111,7 @@ namespace Ombi.Schedule.Jobs.Jellyfin
}
// If we have a non-4k versison then mark as available
if (jellyfinContent.Quality.HasValue() && !movie.Available)
if (jellyfinContent.Quality != null && !movie.Available)
{
movie.Available = true;
movie.MarkedAsAvailable = DateTime.Now;

@ -447,17 +447,20 @@ namespace Ombi.Schedule.Jobs.Ombi
default:
break;
}
}
}
if (hasTvDbId && type == RequestType.TvShow)
{
_log.LogInformation("The show {0} has tvdbid but not ImdbId, searching for ImdbId", title);
if (int.TryParse(tvDbId, out var id))
var result = await _movieApi.Find(tvDbId.ToString(), ExternalSource.tvdb_id);
var movieDbId = result.tv_results.FirstOrDefault()?.id ?? 0;
if (movieDbId != 0)
{
var result = await _tvApi.ShowLookupByTheTvDbId(id);
return result?.externals?.imdb;
var externalsResult = await _movieApi.GetTvExternals(movieDbId);
return externalsResult.imdb_id;
}
}
return string.Empty;

@ -218,7 +218,7 @@ namespace Ombi.Schedule.Jobs.Plex
}
// If we have a non-4k versison then mark as available
if (item.Quality.HasValue() && !movie.Available)
if (item.Quality != null && !movie.Available)
{
movie.Available = true;
movie.Approved = true;

@ -381,7 +381,7 @@ namespace Ombi.Schedule.Jobs.Plex
var qualities = movie.Media?.Select(x => x.videoResolution);
var is4k = qualities != null && qualities.Any(x => x.Equals("4k", StringComparison.InvariantCultureIgnoreCase));
var selectedQuality = is4k ? string.Empty : qualities?.OrderBy(x => x)?.FirstOrDefault() ?? string.Empty;
var selectedQuality = is4k ? null : qualities?.OrderBy(x => x)?.FirstOrDefault() ?? string.Empty;
var item = new PlexServerContent
{

Loading…
Cancel
Save