Fix TMDb search name containing year (#5349)
This commit is contained in:
parent
e858e5f0b8
commit
8f99bdd07c
|
@ -111,10 +111,14 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
|
||||
var item = new Episode
|
||||
{
|
||||
Name = info.Name,
|
||||
IndexNumber = info.IndexNumber,
|
||||
ParentIndexNumber = info.ParentIndexNumber,
|
||||
IndexNumberEnd = info.IndexNumberEnd
|
||||
IndexNumberEnd = info.IndexNumberEnd,
|
||||
Name = episodeResult.Name,
|
||||
PremiereDate = episodeResult.AirDate,
|
||||
ProductionYear = episodeResult.AirDate?.Year,
|
||||
Overview = episodeResult.Overview,
|
||||
CommunityRating = Convert.ToSingle(episodeResult.VoteAverage)
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(episodeResult.ExternalIds?.TvdbId))
|
||||
|
@ -122,14 +126,6 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
item.SetProviderId(MetadataProvider.Tvdb, episodeResult.ExternalIds.TvdbId);
|
||||
}
|
||||
|
||||
item.PremiereDate = episodeResult.AirDate;
|
||||
item.ProductionYear = episodeResult.AirDate?.Year;
|
||||
|
||||
item.Name = episodeResult.Name;
|
||||
item.Overview = episodeResult.Overview;
|
||||
|
||||
item.CommunityRating = Convert.ToSingle(episodeResult.VoteAverage);
|
||||
|
||||
if (episodeResult.Videos?.Results != null)
|
||||
{
|
||||
foreach (var video in episodeResult.Videos.Results)
|
||||
|
|
|
@ -10,6 +10,7 @@ using System.Threading.Tasks;
|
|||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Providers;
|
||||
|
@ -22,15 +23,17 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
public class TmdbSeriesProvider : IRemoteMetadataProvider<Series, SeriesInfo>, IHasOrder
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly TmdbClientManager _tmdbClientManager;
|
||||
|
||||
public TmdbSeriesProvider(
|
||||
ILibraryManager libraryManager,
|
||||
IHttpClientFactory httpClientFactory,
|
||||
TmdbClientManager tmdbClientManager)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_tmdbClientManager = tmdbClientManager;
|
||||
Current = this;
|
||||
}
|
||||
|
||||
public string Name => TmdbUtils.ProviderName;
|
||||
|
@ -38,8 +41,6 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
// After TheTVDB
|
||||
public int Order => 1;
|
||||
|
||||
internal static TmdbSeriesProvider Current { get; private set; }
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
var tmdbId = searchInfo.GetProviderId(MetadataProvider.Tmdb);
|
||||
|
@ -104,7 +105,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
}
|
||||
}
|
||||
|
||||
var tvSearchResults = await _tmdbClientManager.SearchSeriesAsync(searchInfo.Name, searchInfo.MetadataLanguage, cancellationToken)
|
||||
var tvSearchResults = await _tmdbClientManager.SearchSeriesAsync(searchInfo.Name, searchInfo.MetadataLanguage, cancellationToken: cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var remoteResults = new RemoteSearchResult[tvSearchResults.Count];
|
||||
|
@ -203,7 +204,10 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
if (string.IsNullOrEmpty(tmdbId))
|
||||
{
|
||||
result.QueriedById = false;
|
||||
var searchResults = await _tmdbClientManager.SearchSeriesAsync(info.Name, info.MetadataLanguage, cancellationToken).ConfigureAwait(false);
|
||||
// ParseName is required here.
|
||||
// Caller provides the filename with extension stripped and NOT the parsed filename
|
||||
var parsedName = _libraryManager.ParseName(info.Name);
|
||||
var searchResults = await _tmdbClientManager.SearchSeriesAsync(parsedName.Name, info.MetadataLanguage, info.Year ?? 0, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (searchResults.Count > 0)
|
||||
{
|
||||
|
|
|
@ -278,9 +278,10 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|||
/// </summary>
|
||||
/// <param name="name">The name of the tv show.</param>
|
||||
/// <param name="language">The tv show's language.</param>
|
||||
/// <param name="year">The year the tv show first aired.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>The TMDb tv show information.</returns>
|
||||
public async Task<IReadOnlyList<SearchTv>> SearchSeriesAsync(string name, string language, CancellationToken cancellationToken)
|
||||
public async Task<IReadOnlyList<SearchTv>> SearchSeriesAsync(string name, string language, int year = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var key = $"searchseries-{name}-{language}";
|
||||
if (_memoryCache.TryGetValue(key, out SearchContainer<SearchTv> series))
|
||||
|
@ -291,7 +292,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|||
await EnsureClientConfigAsync().ConfigureAwait(false);
|
||||
|
||||
var searchResults = await _tmDbClient
|
||||
.SearchTvShowAsync(name, TmdbUtils.NormalizeLanguage(language), cancellationToken: cancellationToken)
|
||||
.SearchTvShowAsync(name, TmdbUtils.NormalizeLanguage(language), firstAirDateYear: year, cancellationToken: cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (searchResults.Results.Count > 0)
|
||||
|
|
Loading…
Reference in New Issue
Block a user