don't use search query when only a single result is needed
This commit is contained in:
parent
b9118de8c3
commit
8e0ded8d33
|
@ -57,7 +57,12 @@ namespace MediaBrowser.Providers.Omdb
|
|||
return GetSearchResults(searchInfo, "movie", cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(ItemLookupInfo searchInfo, string type, CancellationToken cancellationToken)
|
||||
public Task<IEnumerable<RemoteSearchResult>> GetSearchResults(ItemLookupInfo searchInfo, string type, CancellationToken cancellationToken)
|
||||
{
|
||||
return GetSearchResultsInternal(searchInfo, type, true, cancellationToken);
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<RemoteSearchResult>> GetSearchResultsInternal(ItemLookupInfo searchInfo, string type, bool enableMultipleResults, CancellationToken cancellationToken)
|
||||
{
|
||||
bool isSearch = false;
|
||||
|
||||
|
@ -86,7 +91,14 @@ namespace MediaBrowser.Providers.Omdb
|
|||
}
|
||||
|
||||
// &s means search and returns a list of results as opposed to t
|
||||
url += "&s=" + WebUtility.UrlEncode(name);
|
||||
if (enableMultipleResults)
|
||||
{
|
||||
url += "&s=" + WebUtility.UrlEncode(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
url += "&t=" + WebUtility.UrlEncode(name);
|
||||
}
|
||||
url += "&type=" + type;
|
||||
isSearch = true;
|
||||
}
|
||||
|
@ -239,14 +251,14 @@ namespace MediaBrowser.Providers.Omdb
|
|||
|
||||
private async Task<string> GetMovieImdbId(ItemLookupInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
var results = await GetSearchResults(info, "movie", cancellationToken).ConfigureAwait(false);
|
||||
var results = await GetSearchResultsInternal(info, "movie", false, cancellationToken).ConfigureAwait(false);
|
||||
var first = results.FirstOrDefault();
|
||||
return first == null ? null : first.GetProviderId(MetadataProviders.Imdb);
|
||||
}
|
||||
|
||||
private async Task<string> GetSeriesImdbId(SeriesInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
var results = await GetSearchResults(info, cancellationToken).ConfigureAwait(false);
|
||||
var results = await GetSearchResultsInternal(info, "series", false, cancellationToken).ConfigureAwait(false);
|
||||
var first = results.FirstOrDefault();
|
||||
return first == null ? null : first.GetProviderId(MetadataProviders.Imdb);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user