Use reset_time_utc in download response

This commit is contained in:
MBR#0001 2021-11-01 19:30:18 +01:00
parent 7ee208e0fd
commit b8337449a5
No known key found for this signature in database
GPG Key ID: A938970B8DD3F170
2 changed files with 11 additions and 7 deletions

View File

@ -243,12 +243,9 @@ namespace Jellyfin.Plugin.OpenSubtitles
var info = await OpenSubtitlesHandler.OpenSubtitles.GetSubtitleLinkAsync(fid, _login, _apiKey, cancellationToken).ConfigureAwait(false);
if (info.Data?.Message != null && info.Data.Message.Contains("UTC", StringComparison.Ordinal))
if (info.Data?.ResetTime != null)
{
// "Your quota will be renewed in 20 hours and 52 minutes (2021-08-24 12:02:10 UTC) "
var str = info.Data.Message.Split('(')[1].Trim().Replace(" UTC)", "Z", StringComparison.Ordinal);
_limitReset = DateTime.Parse(str, _usCulture, DateTimeStyles.AdjustToUniversal);
_limitReset = info.Data.ResetTime;
_logger.LogDebug("Updated expiration time to {ResetTime}", _limitReset);
}
@ -295,7 +292,7 @@ namespace Jellyfin.Plugin.OpenSubtitles
{
var msg = string.Format(
CultureInfo.InvariantCulture,
"Failed to obtain download link for file {0}: {1}",
"Failed to obtain download link for file {0}: {1} (empty response)",
fid,
info.Code);

View File

@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using System;
using System.Text.Json.Serialization;
namespace OpenSubtitlesHandler.Models.Responses
{
@ -24,5 +25,11 @@ namespace OpenSubtitlesHandler.Models.Responses
/// </summary>
[JsonPropertyName("message")]
public string? Message { get; set; }
/// <summary>
/// Gets or sets the reset time.
/// </summary>
[JsonPropertyName("reset_time_utc")]
public DateTime? ResetTime { get; set; }
}
}