summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2022-12-12 06:33:31 -0500
committermorpheus65535 <[email protected]>2022-12-12 06:33:31 -0500
commit979301dee01241028ca1c5e9e30f7cf6fb6cf451 (patch)
tree9a8cfe776de0eb0f256c22bace703cd99f6839c8
parent6a17a7fecd9130a9f8ad477e14293ad002973ea1 (diff)
downloadbazarr-979301dee01241028ca1c5e9e30f7cf6fb6cf451.tar.gz
bazarr-979301dee01241028ca1c5e9e30f7cf6fb6cf451.zip
Updated opensubtitles.com to give more information to the download limit reached exception.
-rw-r--r--libs/subliminal_patch/providers/opensubtitlescom.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/libs/subliminal_patch/providers/opensubtitlescom.py b/libs/subliminal_patch/providers/opensubtitlescom.py
index ca8d90193..532998c0d 100644
--- a/libs/subliminal_patch/providers/opensubtitlescom.py
+++ b/libs/subliminal_patch/providers/opensubtitlescom.py
@@ -454,7 +454,17 @@ def checked(fn, raise_api_limit=False, validate_token=False, validate_json=False
elif status_code == 403:
raise ProviderError("Bazarr API key seems to be in problem")
elif status_code == 406:
- raise DownloadLimitExceeded("Daily download limit reached")
+ try:
+ json_response = response.json()
+ download_count = json_response['requests']
+ remaining_download = json_response['remaining']
+ quota_reset_time = json_response['reset_time']
+ except JSONDecodeError:
+ raise ProviderError('Invalid JSON returned by provider')
+ else:
+ raise DownloadLimitExceeded(f"Daily download limit reached. {download_count} subtitles have been "
+ f"downloaded and {remaining_download} remaining subtitles can be "
+ f"downloaded. Quota will be reset in {quota_reset_time}.")
elif status_code == 410:
raise ProviderError("Download as expired")
elif status_code == 429: