Fix adding accept headers
This commit is contained in:
parent
898ccab222
commit
01ed5d5407
|
@ -189,7 +189,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
||||||
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(TmdbUtils.AcceptHeader));
|
foreach (var header in TmdbUtils.AcceptHeaders)
|
||||||
|
{
|
||||||
|
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
|
||||||
|
}
|
||||||
|
|
||||||
using var mainResponse = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage);
|
using var mainResponse = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage);
|
||||||
await using var stream = await mainResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var stream = await mainResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
||||||
var mainResult = await _json.DeserializeFromStreamAsync<CollectionResult>(stream).ConfigureAwait(false);
|
var mainResult = await _json.DeserializeFromStreamAsync<CollectionResult>(stream).ConfigureAwait(false);
|
||||||
|
@ -209,7 +213,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
|
||||||
}
|
}
|
||||||
|
|
||||||
using var langRequestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
using var langRequestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
||||||
langRequestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(TmdbUtils.AcceptHeader));
|
foreach (var header in TmdbUtils.AcceptHeaders)
|
||||||
|
{
|
||||||
|
langRequestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
|
||||||
|
}
|
||||||
|
|
||||||
await using var langStream = await mainResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var langStream = await mainResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
||||||
mainResult = await _json.DeserializeFromStreamAsync<CollectionResult>(langStream).ConfigureAwait(false);
|
mainResult = await _json.DeserializeFromStreamAsync<CollectionResult>(langStream).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||||
}
|
}
|
||||||
|
|
||||||
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, string.Format(CultureInfo.InvariantCulture, TmdbConfigUrl, TmdbUtils.ApiKey));
|
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, string.Format(CultureInfo.InvariantCulture, TmdbConfigUrl, TmdbUtils.ApiKey));
|
||||||
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(TmdbUtils.AcceptHeader));
|
foreach (var header in TmdbUtils.AcceptHeaders)
|
||||||
|
{
|
||||||
|
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
|
||||||
|
}
|
||||||
|
|
||||||
using var response = await GetMovieDbResponse(requestMessage).ConfigureAwait(false);
|
using var response = await GetMovieDbResponse(requestMessage).ConfigureAwait(false);
|
||||||
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
||||||
_tmdbSettings = await _jsonSerializer.DeserializeFromStreamAsync<TmdbSettingsResult>(stream).ConfigureAwait(false);
|
_tmdbSettings = await _jsonSerializer.DeserializeFromStreamAsync<TmdbSettingsResult>(stream).ConfigureAwait(false);
|
||||||
|
@ -325,7 +329,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
||||||
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(TmdbUtils.AcceptHeader));
|
foreach (var header in TmdbUtils.AcceptHeaders)
|
||||||
|
{
|
||||||
|
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
|
||||||
|
}
|
||||||
|
|
||||||
using var mainResponse = await GetMovieDbResponse(requestMessage);
|
using var mainResponse = await GetMovieDbResponse(requestMessage);
|
||||||
if (mainResponse.StatusCode == HttpStatusCode.NotFound)
|
if (mainResponse.StatusCode == HttpStatusCode.NotFound)
|
||||||
{
|
{
|
||||||
|
@ -354,7 +362,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||||
}
|
}
|
||||||
|
|
||||||
using var langRequestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
using var langRequestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
||||||
langRequestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(TmdbUtils.AcceptHeader));
|
foreach (var header in TmdbUtils.AcceptHeaders)
|
||||||
|
{
|
||||||
|
langRequestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
|
||||||
|
}
|
||||||
|
|
||||||
using var langResponse = await GetMovieDbResponse(langRequestMessage);
|
using var langResponse = await GetMovieDbResponse(langRequestMessage);
|
||||||
|
|
||||||
await using var langStream = await langResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var langStream = await langResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
||||||
|
|
|
@ -170,7 +170,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||||
var url3 = string.Format(_searchURL, WebUtility.UrlEncode(name), TmdbUtils.ApiKey, language, type);
|
var url3 = string.Format(_searchURL, WebUtility.UrlEncode(name), TmdbUtils.ApiKey, language, type);
|
||||||
|
|
||||||
var requestMessage = new HttpRequestMessage(HttpMethod.Get, url3);
|
var requestMessage = new HttpRequestMessage(HttpMethod.Get, url3);
|
||||||
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(TmdbUtils.AcceptHeader));
|
foreach (var header in TmdbUtils.AcceptHeaders)
|
||||||
|
{
|
||||||
|
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
|
||||||
|
}
|
||||||
|
|
||||||
using var response = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage).ConfigureAwait(false);
|
using var response = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage).ConfigureAwait(false);
|
||||||
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
||||||
var searchResults = await _json.DeserializeFromStreamAsync<TmdbSearchResult<MovieResult>>(stream).ConfigureAwait(false);
|
var searchResults = await _json.DeserializeFromStreamAsync<TmdbSearchResult<MovieResult>>(stream).ConfigureAwait(false);
|
||||||
|
@ -209,7 +213,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||||
var url3 = string.Format(_searchURL, WebUtility.UrlEncode(name), TmdbUtils.ApiKey, language, "tv");
|
var url3 = string.Format(_searchURL, WebUtility.UrlEncode(name), TmdbUtils.ApiKey, language, "tv");
|
||||||
|
|
||||||
var requestMessage = new HttpRequestMessage(HttpMethod.Get, url3);
|
var requestMessage = new HttpRequestMessage(HttpMethod.Get, url3);
|
||||||
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(TmdbUtils.AcceptHeader));
|
foreach (var header in TmdbUtils.AcceptHeaders)
|
||||||
|
{
|
||||||
|
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
|
||||||
|
}
|
||||||
|
|
||||||
using var response = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage).ConfigureAwait(false);
|
using var response = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage).ConfigureAwait(false);
|
||||||
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
||||||
var searchResults = await _json.DeserializeFromStreamAsync<TmdbSearchResult<TvResult>>(stream).ConfigureAwait(false);
|
var searchResults = await _json.DeserializeFromStreamAsync<TmdbSearchResult<TvResult>>(stream).ConfigureAwait(false);
|
||||||
|
|
|
@ -98,7 +98,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
||||||
var url = string.Format(TmdbUtils.BaseTmdbApiUrl + @"3/search/person?api_key={1}&query={0}", WebUtility.UrlEncode(searchInfo.Name), TmdbUtils.ApiKey);
|
var url = string.Format(TmdbUtils.BaseTmdbApiUrl + @"3/search/person?api_key={1}&query={0}", WebUtility.UrlEncode(searchInfo.Name), TmdbUtils.ApiKey);
|
||||||
|
|
||||||
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
||||||
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(TmdbUtils.AcceptHeader));
|
foreach (var header in TmdbUtils.AcceptHeaders)
|
||||||
|
{
|
||||||
|
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
|
||||||
|
}
|
||||||
|
|
||||||
var response = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage).ConfigureAwait(false);
|
var response = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage).ConfigureAwait(false);
|
||||||
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
|
@ -225,7 +229,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
||||||
var url = string.Format(TmdbUtils.BaseTmdbApiUrl + @"3/person/{1}?api_key={0}&append_to_response=credits,images,external_ids", TmdbUtils.ApiKey, id);
|
var url = string.Format(TmdbUtils.BaseTmdbApiUrl + @"3/person/{1}?api_key={0}&append_to_response=credits,images,external_ids", TmdbUtils.ApiKey, id);
|
||||||
|
|
||||||
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
||||||
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(TmdbUtils.AcceptHeader));
|
foreach (var header in TmdbUtils.AcceptHeaders)
|
||||||
|
{
|
||||||
|
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
|
||||||
|
}
|
||||||
|
|
||||||
using var response = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage).ConfigureAwait(false);
|
using var response = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage).ConfigureAwait(false);
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(dataFilePath));
|
Directory.CreateDirectory(Path.GetDirectoryName(dataFilePath));
|
||||||
await using var fs = new FileStream(dataFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true);
|
await using var fs = new FileStream(dataFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true);
|
||||||
|
|
|
@ -126,7 +126,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
||||||
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(TmdbUtils.AcceptHeader));
|
foreach (var header in TmdbUtils.AcceptHeaders)
|
||||||
|
{
|
||||||
|
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
|
||||||
|
}
|
||||||
|
|
||||||
using var response = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage);
|
using var response = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage);
|
||||||
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
||||||
return await _jsonSerializer.DeserializeFromStreamAsync<EpisodeResult>(stream).ConfigureAwait(false);
|
return await _jsonSerializer.DeserializeFromStreamAsync<EpisodeResult>(stream).ConfigureAwait(false);
|
||||||
|
|
|
@ -213,7 +213,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
||||||
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(TmdbUtils.AcceptHeader));
|
foreach (var header in TmdbUtils.AcceptHeaders)
|
||||||
|
{
|
||||||
|
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
|
||||||
|
}
|
||||||
|
|
||||||
using var response = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage).ConfigureAwait(false);
|
using var response = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage).ConfigureAwait(false);
|
||||||
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
||||||
return await _jsonSerializer.DeserializeFromStreamAsync<SeasonResult>(stream).ConfigureAwait(false);
|
return await _jsonSerializer.DeserializeFromStreamAsync<SeasonResult>(stream).ConfigureAwait(false);
|
||||||
|
|
|
@ -415,7 +415,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
using var mainRequestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
using var mainRequestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
||||||
mainRequestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(TmdbUtils.AcceptHeader));
|
foreach (var header in TmdbUtils.AcceptHeaders)
|
||||||
|
{
|
||||||
|
mainRequestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
|
||||||
|
}
|
||||||
|
|
||||||
using var mainResponse = await TmdbMovieProvider.Current.GetMovieDbResponse(mainRequestMessage);
|
using var mainResponse = await TmdbMovieProvider.Current.GetMovieDbResponse(mainRequestMessage);
|
||||||
await using var mainStream = await mainResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var mainStream = await mainResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
||||||
var mainResult = await _jsonSerializer.DeserializeFromStreamAsync<SeriesResult>(mainStream).ConfigureAwait(false);
|
var mainResult = await _jsonSerializer.DeserializeFromStreamAsync<SeriesResult>(mainStream).ConfigureAwait(false);
|
||||||
|
@ -444,7 +448,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||||
}
|
}
|
||||||
|
|
||||||
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
||||||
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(TmdbUtils.AcceptHeader));
|
foreach (var header in TmdbUtils.AcceptHeaders)
|
||||||
|
{
|
||||||
|
mainRequestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
|
||||||
|
}
|
||||||
|
|
||||||
using var response = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage);
|
using var response = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage);
|
||||||
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
||||||
var englishResult = await _jsonSerializer.DeserializeFromStreamAsync<SeriesResult>(stream).ConfigureAwait(false);
|
var englishResult = await _jsonSerializer.DeserializeFromStreamAsync<SeriesResult>(stream).ConfigureAwait(false);
|
||||||
|
@ -501,7 +509,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||||
externalSource);
|
externalSource);
|
||||||
|
|
||||||
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
using var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
|
||||||
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(TmdbUtils.AcceptHeader));
|
foreach (var header in TmdbUtils.AcceptHeaders)
|
||||||
|
{
|
||||||
|
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(header));
|
||||||
|
}
|
||||||
|
|
||||||
using var response = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage);
|
using var response = await TmdbMovieProvider.Current.GetMovieDbResponse(requestMessage);
|
||||||
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Net.Mime;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Providers.Plugins.Tmdb.Models.General;
|
using MediaBrowser.Providers.Plugins.Tmdb.Models.General;
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Value of the Accept header for requests to the provider.
|
/// Value of the Accept header for requests to the provider.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string AcceptHeader = "application/json,image/*";
|
public static readonly string[] AcceptHeaders = { MediaTypeNames.Application.Json, "image/*" };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Maps the TMDB provided roles for crew members to Jellyfin roles.
|
/// Maps the TMDB provided roles for crew members to Jellyfin roles.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user