mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 19:37:55 +02:00
improve tvdb lookups by imdb
This commit is contained in:
parent
a660aa001e
commit
5e82194749
5 changed files with 29 additions and 20 deletions
|
@ -119,7 +119,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
if (TvdbSeriesProvider.IsValidSeries(searchInfo.SeriesProviderIds) &&
|
if (TvdbSeriesProvider.IsValidSeries(searchInfo.SeriesProviderIds) &&
|
||||||
(searchInfo.IndexNumber.HasValue || searchInfo.PremiereDate.HasValue))
|
(searchInfo.IndexNumber.HasValue || searchInfo.PremiereDate.HasValue))
|
||||||
{
|
{
|
||||||
await TvdbSeriesProvider.Current.EnsureSeriesInfo(searchInfo.SeriesProviderIds, searchInfo.MetadataLanguage, cancellationToken).ConfigureAwait(false);
|
await TvdbSeriesProvider.Current.EnsureSeriesInfo(searchInfo.SeriesProviderIds, null, null, searchInfo.MetadataLanguage, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, searchInfo.SeriesProviderIds);
|
var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, searchInfo.SeriesProviderIds);
|
||||||
|
|
||||||
|
|
|
@ -389,7 +389,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
|
|
||||||
_fileSystem.CreateDirectory(seriesDataPath);
|
_fileSystem.CreateDirectory(seriesDataPath);
|
||||||
|
|
||||||
return TvdbSeriesProvider.Current.DownloadSeriesZip(id, MetadataProviders.Tvdb.ToString(), seriesDataPath, lastTvDbUpdateTime, preferredMetadataLanguage, cancellationToken);
|
return TvdbSeriesProvider.Current.DownloadSeriesZip(id, MetadataProviders.Tvdb.ToString(), null, null, seriesDataPath, lastTvDbUpdateTime, preferredMetadataLanguage, cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
var seriesProviderIds = series.ProviderIds;
|
var seriesProviderIds = series.ProviderIds;
|
||||||
var seasonNumber = season.IndexNumber.Value;
|
var seasonNumber = season.IndexNumber.Value;
|
||||||
|
|
||||||
var seriesDataPath = await TvdbSeriesProvider.Current.EnsureSeriesInfo(seriesProviderIds, series.GetPreferredMetadataLanguage(), cancellationToken).ConfigureAwait(false);
|
var seriesDataPath = await TvdbSeriesProvider.Current.EnsureSeriesInfo(seriesProviderIds, series.Name, series.ProductionYear, series.GetPreferredMetadataLanguage(), cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(seriesDataPath))
|
if (!string.IsNullOrWhiteSpace(seriesDataPath))
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,7 +70,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
{
|
{
|
||||||
var language = item.GetPreferredMetadataLanguage();
|
var language = item.GetPreferredMetadataLanguage();
|
||||||
|
|
||||||
var seriesDataPath = await TvdbSeriesProvider.Current.EnsureSeriesInfo(item.ProviderIds, language, cancellationToken).ConfigureAwait(false);
|
var seriesDataPath = await TvdbSeriesProvider.Current.EnsureSeriesInfo(item.ProviderIds, item.Name, item.ProductionYear, language, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var path = Path.Combine(seriesDataPath, "banners.xml");
|
var path = Path.Combine(seriesDataPath, "banners.xml");
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
|
|
||||||
if (IsValidSeries(itemId.ProviderIds))
|
if (IsValidSeries(itemId.ProviderIds))
|
||||||
{
|
{
|
||||||
await EnsureSeriesInfo(itemId.ProviderIds, itemId.MetadataLanguage, cancellationToken).ConfigureAwait(false);
|
await EnsureSeriesInfo(itemId.ProviderIds, itemId.Name, itemId.Year, itemId.MetadataLanguage, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
result.Item = new Series();
|
result.Item = new Series();
|
||||||
result.HasMetadata = true;
|
result.HasMetadata = true;
|
||||||
|
@ -160,19 +160,11 @@ namespace MediaBrowser.Providers.TV
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Downloads the series zip.
|
/// Downloads the series zip.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="seriesId">The series id.</param>
|
internal async Task DownloadSeriesZip(string seriesId, string idType, string seriesName, int? seriesYear, string seriesDataPath, long? lastTvDbUpdateTime, string preferredMetadataLanguage, CancellationToken cancellationToken)
|
||||||
/// <param name="idType">Type of the identifier.</param>
|
|
||||||
/// <param name="seriesDataPath">The series data path.</param>
|
|
||||||
/// <param name="lastTvDbUpdateTime">The last tv database update time.</param>
|
|
||||||
/// <param name="preferredMetadataLanguage">The preferred metadata language.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <returns>Task.</returns>
|
|
||||||
/// <exception cref="System.ArgumentNullException">seriesId</exception>
|
|
||||||
internal async Task DownloadSeriesZip(string seriesId, string idType, string seriesDataPath, long? lastTvDbUpdateTime, string preferredMetadataLanguage, CancellationToken cancellationToken)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await DownloadSeriesZip(seriesId, idType, seriesDataPath, lastTvDbUpdateTime, preferredMetadataLanguage, preferredMetadataLanguage, cancellationToken).ConfigureAwait(false);
|
await DownloadSeriesZip(seriesId, idType, seriesName, seriesYear, seriesDataPath, lastTvDbUpdateTime, preferredMetadataLanguage, preferredMetadataLanguage, cancellationToken).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (HttpException ex)
|
catch (HttpException ex)
|
||||||
|
@ -185,11 +177,11 @@ namespace MediaBrowser.Providers.TV
|
||||||
|
|
||||||
if (!string.Equals(preferredMetadataLanguage, "en", StringComparison.OrdinalIgnoreCase))
|
if (!string.Equals(preferredMetadataLanguage, "en", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
await DownloadSeriesZip(seriesId, idType, seriesDataPath, lastTvDbUpdateTime, "en", preferredMetadataLanguage, cancellationToken).ConfigureAwait(false);
|
await DownloadSeriesZip(seriesId, idType, seriesName, seriesYear, seriesDataPath, lastTvDbUpdateTime, "en", preferredMetadataLanguage, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DownloadSeriesZip(string seriesId, string idType, string seriesDataPath, long? lastTvDbUpdateTime, string preferredMetadataLanguage, string saveAsMetadataLanguage, CancellationToken cancellationToken)
|
private async Task DownloadSeriesZip(string seriesId, string idType, string seriesName, int? seriesYear, string seriesDataPath, long? lastTvDbUpdateTime, string preferredMetadataLanguage, string saveAsMetadataLanguage, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(seriesId))
|
if (string.IsNullOrWhiteSpace(seriesId))
|
||||||
{
|
{
|
||||||
|
@ -201,6 +193,23 @@ namespace MediaBrowser.Providers.TV
|
||||||
seriesId = await GetSeriesByRemoteId(seriesId, idType, preferredMetadataLanguage, cancellationToken).ConfigureAwait(false);
|
seriesId = await GetSeriesByRemoteId(seriesId, idType, preferredMetadataLanguage, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If searching by remote id came up empty, then do a regular search
|
||||||
|
if (string.IsNullOrWhiteSpace(seriesId) && !string.IsNullOrWhiteSpace(seriesName))
|
||||||
|
{
|
||||||
|
var searchInfo = new SeriesInfo
|
||||||
|
{
|
||||||
|
Name = seriesName,
|
||||||
|
Year = seriesYear,
|
||||||
|
MetadataLanguage = preferredMetadataLanguage
|
||||||
|
};
|
||||||
|
var results = await GetSearchResults(searchInfo, cancellationToken).ConfigureAwait(false);
|
||||||
|
var result = results.FirstOrDefault();
|
||||||
|
if (result != null)
|
||||||
|
{
|
||||||
|
seriesId = result.GetProviderId(MetadataProviders.Tvdb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(seriesId))
|
if (string.IsNullOrWhiteSpace(seriesId))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("seriesId");
|
throw new ArgumentNullException("seriesId");
|
||||||
|
@ -380,7 +389,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
}
|
}
|
||||||
|
|
||||||
private SemaphoreSlim _ensureSemaphore = new SemaphoreSlim(1, 1);
|
private SemaphoreSlim _ensureSemaphore = new SemaphoreSlim(1, 1);
|
||||||
internal async Task<string> EnsureSeriesInfo(Dictionary<string, string> seriesProviderIds, string preferredMetadataLanguage, CancellationToken cancellationToken)
|
internal async Task<string> EnsureSeriesInfo(Dictionary<string, string> seriesProviderIds, string seriesName, int? seriesYear, string preferredMetadataLanguage, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await _ensureSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
|
await _ensureSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
@ -395,7 +404,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
// The post-scan task will take care of updates so we don't need to re-download here
|
// The post-scan task will take care of updates so we don't need to re-download here
|
||||||
if (!IsCacheValid(seriesDataPath, preferredMetadataLanguage))
|
if (!IsCacheValid(seriesDataPath, preferredMetadataLanguage))
|
||||||
{
|
{
|
||||||
await DownloadSeriesZip(seriesId, MetadataProviders.Tvdb.ToString(), seriesDataPath, null, preferredMetadataLanguage, cancellationToken).ConfigureAwait(false);
|
await DownloadSeriesZip(seriesId, MetadataProviders.Tvdb.ToString(), seriesName, seriesYear, seriesDataPath, null, preferredMetadataLanguage, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return seriesDataPath;
|
return seriesDataPath;
|
||||||
|
@ -409,7 +418,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
// The post-scan task will take care of updates so we don't need to re-download here
|
// The post-scan task will take care of updates so we don't need to re-download here
|
||||||
if (!IsCacheValid(seriesDataPath, preferredMetadataLanguage))
|
if (!IsCacheValid(seriesDataPath, preferredMetadataLanguage))
|
||||||
{
|
{
|
||||||
await DownloadSeriesZip(seriesId, MetadataProviders.Imdb.ToString(), seriesDataPath, null, preferredMetadataLanguage, cancellationToken).ConfigureAwait(false);
|
await DownloadSeriesZip(seriesId, MetadataProviders.Imdb.ToString(), seriesName, seriesYear, seriesDataPath, null, preferredMetadataLanguage, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return seriesDataPath;
|
return seriesDataPath;
|
||||||
|
|
Loading…
Reference in a new issue