mirror of
https://github.com/jellyfin/jellyfin-plugin-opensubtitles.git
synced 2024-11-26 16:00:41 +00:00
cleanup (2/2)
This commit is contained in:
parent
f9f75e4fd6
commit
c7f6323df5
@ -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)
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user