mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-08 18:54:26 -04:00
improve flexibility of tvdb search. try yearless search if nothing comes back initially
This commit is contained in:
parent
d06dca2d66
commit
3ef0ddcd12
@ -194,7 +194,7 @@ namespace MediaBrowser.Providers.TV
|
|||||||
|
|
||||||
if (string.IsNullOrEmpty(seriesId))
|
if (string.IsNullOrEmpty(seriesId))
|
||||||
{
|
{
|
||||||
seriesId = await GetSeriesId(series, cancellationToken);
|
seriesId = await FindSeries(series.Name, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
@ -446,34 +446,15 @@ namespace MediaBrowser.Providers.TV
|
|||||||
return item.ResolveArgs.ContainsMetaFileByName(LocalMetaFileName);
|
return item.ResolveArgs.ContainsMetaFileByName(LocalMetaFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the series id.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="item">The item.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <returns>Task{System.String}.</returns>
|
|
||||||
private async Task<string> GetSeriesId(BaseItem item, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var seriesId = item.GetProviderId(MetadataProviders.Tvdb);
|
|
||||||
if (string.IsNullOrEmpty(seriesId))
|
|
||||||
{
|
|
||||||
seriesId = await FindSeries(item.Name, cancellationToken).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
return seriesId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds the series.
|
/// Finds the series.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.String}.</returns>
|
/// <returns>Task{System.String}.</returns>
|
||||||
public async Task<string> FindSeries(string name, CancellationToken cancellationToken)
|
private async Task<string> FindSeries(string name, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
var url = string.Format(RootUrl + SeriesQuery, WebUtility.UrlEncode(name));
|
||||||
//nope - search for it
|
|
||||||
string url = string.Format(RootUrl + SeriesQuery, WebUtility.UrlEncode(name));
|
|
||||||
var doc = new XmlDocument();
|
var doc = new XmlDocument();
|
||||||
|
|
||||||
using (var results = await HttpClient.Get(new HttpRequestOptions
|
using (var results = await HttpClient.Get(new HttpRequestOptions
|
||||||
@ -489,8 +470,8 @@ namespace MediaBrowser.Providers.TV
|
|||||||
|
|
||||||
if (doc.HasChildNodes)
|
if (doc.HasChildNodes)
|
||||||
{
|
{
|
||||||
XmlNodeList nodes = doc.SelectNodes("//Series");
|
var nodes = doc.SelectNodes("//Series");
|
||||||
string comparableName = GetComparableName(name);
|
var comparableName = GetComparableName(name);
|
||||||
if (nodes != null)
|
if (nodes != null)
|
||||||
foreach (XmlNode node in nodes)
|
foreach (XmlNode node in nodes)
|
||||||
{
|
{
|
||||||
@ -509,6 +490,16 @@ namespace MediaBrowser.Providers.TV
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try stripping off the year if it was supplied
|
||||||
|
var parenthIndex = name.LastIndexOf('(');
|
||||||
|
|
||||||
|
if (parenthIndex != -1)
|
||||||
|
{
|
||||||
|
var newName = name.Substring(0, parenthIndex);
|
||||||
|
|
||||||
|
return await FindSeries(newName, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
Logger.Info("TVDb Provider - Could not find " + name + ". Check name on Thetvdb.org.");
|
Logger.Info("TVDb Provider - Could not find " + name + ". Check name on Thetvdb.org.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user