From b25d4164c296483958ecc951ff17b901a146a245 Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Sat, 18 Nov 2023 21:01:09 -0500 Subject: [PATCH] Fixed infinite download retry loop in whisperai provider --- bazarr/app/get_providers.py | 1 + libs/subliminal_patch/core.py | 2 +- libs/subliminal_patch/providers/whisperai.py | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bazarr/app/get_providers.py b/bazarr/app/get_providers.py index 026a20291..9ad4fd152 100644 --- a/bazarr/app/get_providers.py +++ b/bazarr/app/get_providers.py @@ -12,6 +12,7 @@ import requests import traceback import re +from requests import ConnectionError from subzero.language import Language from subliminal_patch.exceptions import TooManyRequests, APIThrottled, ParseResponseError, IPAddressBlocked, \ MustGetBlacklisted, SearchLimitReached diff --git a/libs/subliminal_patch/core.py b/libs/subliminal_patch/core.py index 59312ee85..59cfd22a3 100644 --- a/libs/subliminal_patch/core.py +++ b/libs/subliminal_patch/core.py @@ -38,7 +38,7 @@ logger = logging.getLogger(__name__) CUSTOM_PATHS = [] INCLUDE_EXOTIC_SUBS = True -DOWNLOAD_TRIES = 0 +DOWNLOAD_TRIES = 3 DOWNLOAD_RETRY_SLEEP = 6 # fixme: this may be overkill diff --git a/libs/subliminal_patch/providers/whisperai.py b/libs/subliminal_patch/providers/whisperai.py index 8aef88bc0..7e1b62bbb 100644 --- a/libs/subliminal_patch/providers/whisperai.py +++ b/libs/subliminal_patch/providers/whisperai.py @@ -233,7 +233,7 @@ class WhisperAIProvider(Provider): r = self.session.post(f"{self.endpoint}/detect-language", params={'encode': 'false'}, files={'audio_file': out}, - timeout=self.timeout) + timeout=(5, self.timeout)) 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", params={'task': subtitle.task, 'language': whisper_get_language_reverse(subtitle.audio_language), 'output': 'srt', 'encode': 'false'}, files={'audio_file': out}, - timeout=self.timeout) + timeout=(5, self.timeout)) subtitle.content = r.content