Merge pull request #17810 from Shadowghost/fix-tmdb-recommendations
Fix TMDb recommendations
This commit is contained in:
@@ -58,7 +58,7 @@ public class TmdbMovieSimilarProvider : IRemoteSimilarItemsProvider<Movie>
|
||||
}
|
||||
|
||||
var providerName = MetadataProvider.Tmdb.ToString();
|
||||
var page = 0;
|
||||
var page = 1;
|
||||
var totalPages = 1;
|
||||
|
||||
while (page <= totalPages && !cancellationToken.IsCancellationRequested)
|
||||
@@ -67,12 +67,12 @@ public class TmdbMovieSimilarProvider : IRemoteSimilarItemsProvider<Movie>
|
||||
try
|
||||
{
|
||||
(pageResults, totalPages) = await _tmdbClientManager
|
||||
.GetMovieSimilarPageAsync(tmdbId, page, TmdbUtils.GetImageLanguagesParam(string.Empty), cancellationToken)
|
||||
.GetMovieRecommendationsPageAsync(tmdbId, page, TmdbUtils.GetImageLanguagesParam(string.Empty), cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to get similar movies from TMDb for {TmdbId} page {Page}", tmdbId, page);
|
||||
_logger.LogWarning(ex, "Failed to get recommended movies from TMDb for {TmdbId} page {Page}", tmdbId, page);
|
||||
yield break;
|
||||
}
|
||||
|
||||
@@ -81,12 +81,12 @@ public class TmdbMovieSimilarProvider : IRemoteSimilarItemsProvider<Movie>
|
||||
yield break;
|
||||
}
|
||||
|
||||
foreach (var similar in pageResults)
|
||||
foreach (var recommendation in pageResults)
|
||||
{
|
||||
yield return new SimilarItemReference
|
||||
{
|
||||
ProviderName = providerName,
|
||||
ProviderId = similar.Id.ToString(CultureInfo.InvariantCulture)
|
||||
ProviderId = recommendation.Id.ToString(CultureInfo.InvariantCulture)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -67,12 +67,12 @@ public class TmdbSeriesSimilarProvider : IRemoteSimilarItemsProvider<Series>
|
||||
try
|
||||
{
|
||||
(pageResults, totalPages) = await _tmdbClientManager
|
||||
.GetSeriesSimilarPageAsync(tmdbId, page, TmdbUtils.GetImageLanguagesParam(string.Empty), cancellationToken)
|
||||
.GetSeriesRecommendationsPageAsync(tmdbId, page, TmdbUtils.GetImageLanguagesParam(string.Empty), cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to get similar TV shows from TMDb for {TmdbId} page {Page}", tmdbId, page);
|
||||
_logger.LogWarning(ex, "Failed to get recommended TV shows from TMDb for {TmdbId} page {Page}", tmdbId, page);
|
||||
yield break;
|
||||
}
|
||||
|
||||
@@ -81,12 +81,12 @@ public class TmdbSeriesSimilarProvider : IRemoteSimilarItemsProvider<Series>
|
||||
yield break;
|
||||
}
|
||||
|
||||
foreach (var similar in pageResults)
|
||||
foreach (var recommendation in pageResults)
|
||||
{
|
||||
yield return new SimilarItemReference
|
||||
{
|
||||
ProviderName = providerName,
|
||||
ProviderId = similar.Id.ToString(CultureInfo.InvariantCulture)
|
||||
ProviderId = recommendation.Id.ToString(CultureInfo.InvariantCulture)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -508,19 +508,19 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single page of similar movies for a movie from the TMDb API.
|
||||
/// Gets a single page of recommended movies for a movie from the TMDb API.
|
||||
/// </summary>
|
||||
/// <param name="tmdbId">The TMDb id of the movie.</param>
|
||||
/// <param name="page">The page number to fetch (1-based).</param>
|
||||
/// <param name="language">The language for results.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>A tuple containing the list of similar movies and the total number of pages available.</returns>
|
||||
public async Task<(IReadOnlyList<SearchMovie> Results, int TotalPages)> GetMovieSimilarPageAsync(int tmdbId, int page, string? language, CancellationToken cancellationToken)
|
||||
/// <returns>A tuple containing the list of recommended movies and the total number of pages available.</returns>
|
||||
public async Task<(IReadOnlyList<SearchMovie> Results, int TotalPages)> GetMovieRecommendationsPageAsync(int tmdbId, int page, string? language, CancellationToken cancellationToken)
|
||||
{
|
||||
await EnsureClientConfigAsync().ConfigureAwait(false);
|
||||
|
||||
var searchResults = await _tmDbClient
|
||||
.GetMovieSimilarAsync(tmdbId, language, page, cancellationToken)
|
||||
.GetMovieRecommendationsAsync(tmdbId, language, page, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (searchResults?.Results is null || searchResults.Results.Count == 0)
|
||||
@@ -532,19 +532,19 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single page of similar TV shows for a series from the TMDb API.
|
||||
/// Gets a single page of recommended TV shows for a series from the TMDb API.
|
||||
/// </summary>
|
||||
/// <param name="tmdbId">The TMDb id of the TV show.</param>
|
||||
/// <param name="page">The page number to fetch (1-based).</param>
|
||||
/// <param name="language">The language for results.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>A tuple containing the list of similar TV shows and the total number of pages available.</returns>
|
||||
public async Task<(IReadOnlyList<SearchTv> Results, int TotalPages)> GetSeriesSimilarPageAsync(int tmdbId, int page, string? language, CancellationToken cancellationToken)
|
||||
/// <returns>A tuple containing the list of recommended TV shows and the total number of pages available.</returns>
|
||||
public async Task<(IReadOnlyList<SearchTv> Results, int TotalPages)> GetSeriesRecommendationsPageAsync(int tmdbId, int page, string? language, CancellationToken cancellationToken)
|
||||
{
|
||||
await EnsureClientConfigAsync().ConfigureAwait(false);
|
||||
|
||||
var searchResults = await _tmDbClient
|
||||
.GetTvShowSimilarAsync(tmdbId, language, page, cancellationToken)
|
||||
.GetTvShowRecommendationsAsync(tmdbId, language, page, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (searchResults?.Results is null || searchResults.Results.Count == 0)
|
||||
|
||||
Reference in New Issue
Block a user