From 7f1d3e1adf0d87f230ee32b7cf39d90675d173d3 Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sun, 2 Oct 2022 13:17:00 -0400 Subject: [PATCH] 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. --- libs/subliminal_patch/providers/gestdown.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libs/subliminal_patch/providers/gestdown.py b/libs/subliminal_patch/providers/gestdown.py index 386d8f404..6af9920ea 100644 --- a/libs/subliminal_patch/providers/gestdown.py +++ b/libs/subliminal_patch/providers/gestdown.py @@ -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)