mirror of
https://github.com/jellyfin/jellyfin-plugin-opensubtitles.git
synced 2024-11-26 16:00:41 +00:00
Merge pull request #83 from MBR-0001/limit-handling2
This commit is contained in:
commit
de10383b22
@ -29,6 +29,7 @@ namespace Jellyfin.Plugin.OpenSubtitles
|
||||
private readonly ILogger<OpenSubtitleDownloader> _logger;
|
||||
private LoginInfo? _login;
|
||||
private DateTime? _limitReset;
|
||||
private DateTime? _lastRatelimitLog;
|
||||
private IReadOnlyList<string>? _languages;
|
||||
private string _customApiKey;
|
||||
|
||||
@ -86,6 +87,19 @@ namespace Jellyfin.Plugin.OpenSubtitles
|
||||
throw new ArgumentNullException(nameof(request));
|
||||
}
|
||||
|
||||
await Login(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (request.IsAutomated && _login?.User?.RemainingDownloads <= 0)
|
||||
{
|
||||
if (_lastRatelimitLog == null || DateTime.UtcNow.Subtract(_lastRatelimitLog.Value).TotalSeconds > 60)
|
||||
{
|
||||
_logger.LogInformation("Daily download limit reached, returning no results for automated task");
|
||||
_lastRatelimitLog = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
return Enumerable.Empty<RemoteSubtitleInfo>();
|
||||
}
|
||||
|
||||
long.TryParse(request.GetProviderId(MetadataProvider.Imdb)?.TrimStart('t') ?? string.Empty, NumberStyles.Any, CultureInfo.InvariantCulture, out var imdbId);
|
||||
|
||||
if (request.ContentType == VideoContentType.Episode && (!request.IndexNumber.HasValue || !request.ParentIndexNumber.HasValue || string.IsNullOrEmpty(request.SeriesName)))
|
||||
@ -100,8 +114,6 @@ namespace Jellyfin.Plugin.OpenSubtitles
|
||||
return Enumerable.Empty<RemoteSubtitleInfo>();
|
||||
}
|
||||
|
||||
await Login(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var language = await GetLanguage(request.TwoLetterISOLanguageName, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
string hash;
|
||||
|
@ -26,7 +26,7 @@ This is a plugin allows you to download subtitles from [Open Subtitles](https://
|
||||
|
||||
## Build
|
||||
|
||||
1. To build this plugin you will need [.Net 5.x](https://dotnet.microsoft.com/download/dotnet/5.0).
|
||||
1. To build this plugin you will need [.Net 6.x](https://dotnet.microsoft.com/download/dotnet/6.0).
|
||||
|
||||
2. Build plugin with following command
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user