Fixed infinite download retry loop in whisperai provider

pull/2304/head
morpheus65535 1 year ago
parent d64d6b0a01
commit b25d4164c2

@ -12,6 +12,7 @@ import requests
import traceback import traceback
import re import re
from requests import ConnectionError
from subzero.language import Language from subzero.language import Language
from subliminal_patch.exceptions import TooManyRequests, APIThrottled, ParseResponseError, IPAddressBlocked, \ from subliminal_patch.exceptions import TooManyRequests, APIThrottled, ParseResponseError, IPAddressBlocked, \
MustGetBlacklisted, SearchLimitReached MustGetBlacklisted, SearchLimitReached

@ -38,7 +38,7 @@ logger = logging.getLogger(__name__)
CUSTOM_PATHS = [] CUSTOM_PATHS = []
INCLUDE_EXOTIC_SUBS = True INCLUDE_EXOTIC_SUBS = True
DOWNLOAD_TRIES = 0 DOWNLOAD_TRIES = 3
DOWNLOAD_RETRY_SLEEP = 6 DOWNLOAD_RETRY_SLEEP = 6
# fixme: this may be overkill # fixme: this may be overkill

@ -233,7 +233,7 @@ class WhisperAIProvider(Provider):
r = self.session.post(f"{self.endpoint}/detect-language", r = self.session.post(f"{self.endpoint}/detect-language",
params={'encode': 'false'}, params={'encode': 'false'},
files={'audio_file': out}, files={'audio_file': out},
timeout=self.timeout) timeout=(5, self.timeout))
logger.info(f"Whisper detected language of {path} as {r.json()['detected_language']}") logger.info(f"Whisper detected language of {path} as {r.json()['detected_language']}")
@ -290,6 +290,6 @@ class WhisperAIProvider(Provider):
r = self.session.post(f"{self.endpoint}/asr", r = self.session.post(f"{self.endpoint}/asr",
params={'task': subtitle.task, 'language': whisper_get_language_reverse(subtitle.audio_language), 'output': 'srt', 'encode': 'false'}, params={'task': subtitle.task, 'language': whisper_get_language_reverse(subtitle.audio_language), 'output': 'srt', 'encode': 'false'},
files={'audio_file': out}, files={'audio_file': out},
timeout=self.timeout) timeout=(5, self.timeout))
subtitle.content = r.content subtitle.content = r.content

Loading…
Cancel
Save