cleanup (2/2)

This commit is contained in:
MBR#0001 2021-12-05 18:05:11 +01:00
parent f9f75e4fd6
commit c7f6323df5
No known key found for this signature in database
GPG Key ID: A938970B8DD3F170
2 changed files with 15 additions and 6 deletions

View File

@ -314,7 +314,7 @@ namespace Jellyfin.Plugin.OpenSubtitles
var res = await OpenSubtitlesHandler.OpenSubtitles.DownloadSubtitleAsync(info.Data.Link, cancellationToken).ConfigureAwait(false);
if (!res.Ok || string.IsNullOrWhiteSpace(res.Data))
if (res.Code != HttpStatusCode.OK || string.IsNullOrWhiteSpace(res.Body))
{
var msg = string.Format(
CultureInfo.InvariantCulture,
@ -325,7 +325,7 @@ namespace Jellyfin.Plugin.OpenSubtitles
throw new HttpRequestException(msg);
}
return new SubtitleResponse { Format = format, Language = language, Stream = new MemoryStream(Encoding.UTF8.GetBytes(res.Data)) };
return new SubtitleResponse { Format = format, Language = language, Stream = new MemoryStream(Encoding.UTF8.GetBytes(res.Body)) };
}
private async Task Login(CancellationToken cancellationToken)

View File

@ -101,12 +101,21 @@ namespace Jellyfin.Plugin.OpenSubtitles.OpenSubtitlesHandler
/// </summary>
/// <param name="url">the subtitle url.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The subtitle string.</returns>
public static async Task<ApiResponse<string>> DownloadSubtitleAsync(string url, CancellationToken cancellationToken)
/// <returns>The Http response.</returns>
public static async Task<HttpResponse> DownloadSubtitleAsync(string url, CancellationToken cancellationToken)
{
var response = await RequestHandler.SendRequestAsync(url, HttpMethod.Get, null, null, null, 1, cancellationToken).ConfigureAwait(false);
var response = await OpenSubtitlesRequestHelper.Instance!.SendRequestAsync(
url,
HttpMethod.Get,
null,
new Dictionary<string, string>(),
cancellationToken).ConfigureAwait(false);
return new ApiResponse<string>(response);
return new HttpResponse
{
Body = response.body,
Code = response.statusCode
};
}
/// <summary>