Address comments

pull/3841/head
Bond_009 4 years ago
parent 68edccd9f4
commit ce352e4a1d

@ -30,6 +30,9 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
/// </summary>
public class TmdbMovieProvider : IRemoteMetadataProvider<Movie, MovieInfo>, IHasOrder
{
private const string TmdbConfigUrl = TmdbUtils.BaseTmdbApiUrl + "3/configuration?api_key={0}";
private const string GetMovieInfo3 = TmdbUtils.BaseTmdbApiUrl + @"3/movie/{0}?api_key={1}&append_to_response=casts,releases,images,keywords,trailers";
internal static TmdbMovieProvider Current { get; private set; }
private readonly IJsonSerializer _jsonSerializer;
@ -157,9 +160,6 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
return _tmdbSettings;
}
private const string TmdbConfigUrl = TmdbUtils.BaseTmdbApiUrl + "3/configuration?api_key={0}";
private const string GetMovieInfo3 = TmdbUtils.BaseTmdbApiUrl + @"3/movie/{0}?api_key={1}&append_to_response=casts,releases,images,keywords,trailers";
/// <summary>
/// Gets the movie data path.
/// </summary>
@ -334,7 +334,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
}
using var mainResponse = await GetMovieDbResponse(requestMessage);
using var mainResponse = await GetMovieDbResponse(requestMessage).ConfigureAwait(false);
if (mainResponse.StatusCode == HttpStatusCode.NotFound)
{
return null;
@ -367,7 +367,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
langRequestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
}
using var langResponse = await GetMovieDbResponse(langRequestMessage);
using var langResponse = await GetMovieDbResponse(langRequestMessage).ConfigureAwait(false);
await using var langStream = await langResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
var langResult = await _jsonSerializer.DeserializeFromStreamAsync<MovieResult>(stream).ConfigureAwait(false);
@ -380,10 +380,10 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
/// <summary>
/// Gets the movie db response.
/// </summary>
internal async Task<HttpResponseMessage> GetMovieDbResponse(HttpRequestMessage message)
internal Task<HttpResponseMessage> GetMovieDbResponse(HttpRequestMessage message)
{
message.Headers.UserAgent.Add(new ProductInfoHeaderValue(_appHost.ApplicationUserAgent));
return await _httpClientFactory.CreateClient().SendAsync(message);
return _httpClientFactory.CreateClient().SendAsync(message);
}
/// <inheritdoc />

@ -38,8 +38,8 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase);
private const string SearchUrl = TmdbUtils.BaseTmdbApiUrl + @"3/search/{3}?api_key={1}&query={0}&language={2}";
private const string SearchUrlWithYear = TmdbUtils.BaseTmdbApiUrl + @"3/search/{3}?api_key={1}&query={0}&language={2}&first_air_date_year={4}";
private const string SearchUrlTvWithYear = TmdbUtils.BaseTmdbApiUrl + @"3/search/tv?api_key={1}&query={0}&language={2}&first_air_date_year={3}";
private const string SearchUrlMovieWithYear = TmdbUtils.BaseTmdbApiUrl + @"3/search/movie?api_key={1}&query={0}&language={2}&primary_release_year={3}";
private readonly ILogger _logger;
private readonly IJsonSerializer _json;
private readonly ILibraryManager _libraryManager;
@ -173,11 +173,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
{
url3 = string.Format(
CultureInfo.InvariantCulture,
SearchUrl,
SearchUrlMovieWithYear,
WebUtility.UrlEncode(name),
TmdbUtils.ApiKey,
language,
type) + "&primary_release_year=" + year;
year);
}
else
{
@ -246,15 +246,14 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
{
url3 = string.Format(
CultureInfo.InvariantCulture,
SearchUrlWithYear,
SearchUrlTvWithYear,
WebUtility.UrlEncode(name),
TmdbUtils.ApiKey,
language,
"tv",
year);
}
var requestMessage = new HttpRequestMessage(HttpMethod.Get, url3);
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url3);
foreach (var header in TmdbUtils.AcceptHeaders)
{
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));

Loading…
Cancel
Save