Skip to content

Commit

Permalink
fix(mediaserver): fixed an issue where we were not detecting availabl…
Browse files Browse the repository at this point in the history
…e content correctly #4542
  • Loading branch information
tidusjar committed Mar 18, 2022
1 parent a2be81d commit 9cdd6f4
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 38 deletions.
2 changes: 0 additions & 2 deletions src/Ombi.Api.TvMaze/ITvMazeApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
22 changes: 0 additions & 22 deletions src/Ombi.Api.TvMaze/TvMazeApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,5 @@ public async Task<TvMazeShow> ShowLookupByTheTvDbId(int theTvDbId)
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);
}
}
}
12 changes: 6 additions & 6 deletions src/Ombi.Core/Engine/MovieSearchEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task<SearchMovieViewModel> LookupImdbInformation(int theMovieDbId,
{
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);

Expand Down Expand Up @@ -81,11 +81,11 @@ public async Task<IEnumerable<SearchMovieViewModel>> SearchActor(string search,
{
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();
Expand Down Expand Up @@ -120,7 +120,7 @@ public async Task<IEnumerable<SearchMovieViewModel>> SimilarMovies(int theMovieD
/// <returns></returns>
public async Task<IEnumerable<SearchMovieViewModel>> PopularMovies()
{

var result = await Cache.GetOrAddAsync(CacheKeys.PopularMovies, async () =>
{
var langCode = await DefaultLanguageCode(null);
Expand Down Expand Up @@ -201,7 +201,7 @@ protected async Task<List<SearchMovieViewModel>> TransformMovieResultsToResponse

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
Expand All @@ -217,7 +217,7 @@ protected async Task<SearchMovieViewModel> ProcessSingleMovie(SearchMovieViewMod

// This requires the rules to be run first to populate the RequestId property
await CheckForSubscription(viewMovie);

return viewMovie;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Ombi.Schedule/Jobs/Emby/EmbyAvaliabilityChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private async Task ProcessMovies()
}

// 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private async Task ProcessMovies()
}

// 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;
Expand Down
11 changes: 7 additions & 4 deletions src/Ombi.Schedule/Jobs/Ombi/RefreshMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -447,17 +447,20 @@ private async Task<string> GetImdbId(bool hasTheMovieDb, bool hasTvDbId, string
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;
Expand Down
2 changes: 1 addition & 1 deletion src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private async Task ProcessMovies()
}

// 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;
Expand Down
2 changes: 1 addition & 1 deletion src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public async Task MovieLoop(PlexServers servers, Mediacontainer content, HashSet

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
{
Expand Down

0 comments on commit 9cdd6f4

Please sign in to comment.