mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-02-22 22:04:41 +08:00
Gestdown: Check for show before checking for subtitle (#1962)
Will reduce the number of different calls to the provider and only ask for subtitle when we know the show exists.
This commit is contained in:
parent
8348b6c0dc
commit
7f1d3e1adf
1 changed files with 15 additions and 0 deletions
|
@ -104,9 +104,24 @@ class GestdownProvider(Provider):
|
|||
logger.debug("Found subtitle: %s", sub)
|
||||
yield sub
|
||||
|
||||
def _show_exists(self, video):
|
||||
try:
|
||||
response = self._session.get(f"{_BASE_URL}/shows/search/{video.series}")
|
||||
response.raise_for_status()
|
||||
return True
|
||||
except HTTPError as error:
|
||||
if error.response.status_code == 404:
|
||||
return False
|
||||
raise
|
||||
|
||||
|
||||
@_retry_on_423
|
||||
def list_subtitles(self, video, languages):
|
||||
subtitles = []
|
||||
if not self._show_exists(video):
|
||||
logger.debug("Couldn't find the show")
|
||||
return subtitles
|
||||
|
||||
for language in languages:
|
||||
try:
|
||||
subtitles += self._subtitles_search(video, language)
|
||||
|
|
Loading…
Reference in a new issue