From e7703ca5a08f6a25590bd9d678f844857c41a108 Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Thu, 21 Sep 2023 06:26:46 -0400 Subject: [PATCH] Added logging for opensubtitles.com 400 error. #2232 --- libs/subliminal_patch/providers/opensubtitlescom.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/subliminal_patch/providers/opensubtitlescom.py b/libs/subliminal_patch/providers/opensubtitlescom.py index 3f09f7f5c..4c2a84d70 100644 --- a/libs/subliminal_patch/providers/opensubtitlescom.py +++ b/libs/subliminal_patch/providers/opensubtitlescom.py @@ -473,7 +473,16 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider): except Exception: status_code = None else: - if status_code == 401: + if status_code == 400: + try: + json_response = response.json() + message = json_response['message'] + except JSONDecodeError: + raise ProviderError('Invalid JSON returned by provider') + else: + log_request_response(response) + raise ConfigurationError(message) + elif status_code == 401: log_request_response(response) self.reset_token() if is_retry: