Skip to content

Commit

Permalink
Added opensubtitles specific throttling for server under maintenance …
Browse files Browse the repository at this point in the history
…(http 506)
  • Loading branch information
morpheus65535 committed Dec 24, 2024
1 parent 96618d5 commit 2247c55
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion custom_libs/subliminal_patch/providers/opensubtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import base64
import logging
import os
import traceback
import re
import zlib
import time
Expand Down Expand Up @@ -411,6 +410,8 @@ def checked(fn, raise_api_limit=False):

except requests.RequestException as e:
status_code = e.response.status_code
if status_code == 503 and "Server under maintenance" in e.response.text:
status_code = 506
else:
status_code = int(response['status'][:3])
except:
Expand All @@ -437,6 +438,8 @@ def checked(fn, raise_api_limit=False):
raise APIThrottled
if status_code == 503:
raise ServiceUnavailable(str(status_code))
if status_code == 506:
raise ServiceUnavailable("Server under maintenance")
if status_code != 200:
if response and "status" in response:
raise OpenSubtitlesError(response['status'])
Expand Down

0 comments on commit 2247c55

Please sign in to comment.