diff options
| author | Patrick Barron <18354464+barronpm@users.noreply.github.com> | 2020-09-03 19:03:08 +0000 |
|---|---|---|
| committer | Patrick Barron <barronpm@gmail.com> | 2020-09-03 15:15:43 -0400 |
| commit | d81430270732591a5a66c9656bf841f46bed6f49 (patch) | |
| tree | c97b2b255d1d2d266939e28b41c12b1cc3bad08f /Jellyfin.Api/Controllers/LiveTvController.cs | |
| parent | 229a5d9e0bf99f9c6f741f654f1dbe0a7f975872 (diff) | |
| parent | 53703566b5e1239bbab308031d94df34a4d168aa (diff) | |
Merge branch 'master' into scoped-displaypreferences
Diffstat (limited to 'Jellyfin.Api/Controllers/LiveTvController.cs')
| -rw-r--r-- | Jellyfin.Api/Controllers/LiveTvController.cs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/Jellyfin.Api/Controllers/LiveTvController.cs b/Jellyfin.Api/Controllers/LiveTvController.cs index 89112eea7..3ccfc826d 100644 --- a/Jellyfin.Api/Controllers/LiveTvController.cs +++ b/Jellyfin.Api/Controllers/LiveTvController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; +using System.Net.Http; using System.Net.Mime; using System.Security.Cryptography; using System.Text; @@ -15,7 +16,6 @@ using Jellyfin.Api.Models.LiveTvDtos; using Jellyfin.Data.Enums; using MediaBrowser.Common; using MediaBrowser.Common.Configuration; -using MediaBrowser.Common.Net; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; @@ -39,7 +39,7 @@ namespace Jellyfin.Api.Controllers { private readonly ILiveTvManager _liveTvManager; private readonly IUserManager _userManager; - private readonly IHttpClient _httpClient; + private readonly IHttpClientFactory _httpClientFactory; private readonly ILibraryManager _libraryManager; private readonly IDtoService _dtoService; private readonly ISessionContext _sessionContext; @@ -52,7 +52,7 @@ namespace Jellyfin.Api.Controllers /// </summary> /// <param name="liveTvManager">Instance of the <see cref="ILiveTvManager"/> interface.</param> /// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param> - /// <param name="httpClient">Instance of the <see cref="IHttpClient"/> interface.</param> + /// <param name="httpClientFactory">Instance of the <see cref="IHttpClientFactory"/> interface.</param> /// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param> /// <param name="dtoService">Instance of the <see cref="IDtoService"/> interface.</param> /// <param name="sessionContext">Instance of the <see cref="ISessionContext"/> interface.</param> @@ -62,7 +62,7 @@ namespace Jellyfin.Api.Controllers public LiveTvController( ILiveTvManager liveTvManager, IUserManager userManager, - IHttpClient httpClient, + IHttpClientFactory httpClientFactory, ILibraryManager libraryManager, IDtoService dtoService, ISessionContext sessionContext, @@ -72,7 +72,7 @@ namespace Jellyfin.Api.Controllers { _liveTvManager = liveTvManager; _userManager = userManager; - _httpClient = httpClient; + _httpClientFactory = httpClientFactory; _libraryManager = libraryManager; _dtoService = dtoService; _sessionContext = sessionContext; @@ -592,11 +592,11 @@ namespace Jellyfin.Api.Controllers GenreIds = RequestHelpers.GetGuids(genreIds) }; - if (!librarySeriesId.Equals(Guid.Empty)) + if (librarySeriesId != null && !librarySeriesId.Equals(Guid.Empty)) { query.IsSeries = true; - if (_libraryManager.GetItemById(librarySeriesId ?? Guid.Empty) is Series series) + if (_libraryManager.GetItemById(librarySeriesId.Value) is Series series) { query.Name = series.Name; } @@ -1004,7 +1004,7 @@ namespace Jellyfin.Api.Controllers /// <param name="validateLogin">Validate login.</param> /// <response code="200">Created listings provider returned.</response> /// <returns>A <see cref="OkResult"/> containing the created listings provider.</returns> - [HttpGet("ListingProviders")] + [HttpPost("ListingProviders")] [Authorize(Policy = Policies.DefaultAuthorization)] [ProducesResponseType(StatusCodes.Status200OK)] [SuppressMessage("Microsoft.Performance", "CA5350:RemoveSha1", MessageId = "AddListingProvider", Justification = "Imported from ServiceStack")] @@ -1069,13 +1069,13 @@ namespace Jellyfin.Api.Controllers [ProducesResponseType(StatusCodes.Status200OK)] public async Task<ActionResult> GetSchedulesDirectCountries() { + var client = _httpClientFactory.CreateClient(); // https://json.schedulesdirect.org/20141201/available/countries - var response = await _httpClient.Get(new HttpRequestOptions - { - Url = "https://json.schedulesdirect.org/20141201/available/countries", - BufferContent = false - }).ConfigureAwait(false); - return File(response, MediaTypeNames.Application.Json); + // Can't dispose the response as it's required up the call chain. + var response = await client.GetAsync("https://json.schedulesdirect.org/20141201/available/countries") + .ConfigureAwait(false); + + return File(await response.Content.ReadAsStreamAsync().ConfigureAwait(false), MediaTypeNames.Application.Json); } /// <summary> |
