summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAntoine Aflalo <[email protected]>2023-03-02 04:11:50 +0100
committerGitHub <[email protected]>2023-03-01 22:11:50 -0500
commit248e49de76c4a94e9dc6db9166521b8527f476bc (patch)
tree5efecb2ceece0277a7f75021c681609833f7de0c
parente4bf041ecb4921c8829ab60b8de13fde982cd20e (diff)
downloadbazarr-248e49de76c4a94e9dc6db9166521b8527f476bc.tar.gz
bazarr-248e49de76c4a94e9dc6db9166521b8527f476bc.zip
Improved Gestdown provider to get better matches using tvdb idv1.2.0v1.1.5-beta.27
-rw-r--r--libs/subliminal_patch/providers/gestdown.py16
-rw-r--r--tests/subliminal_patch/conftest.py2
-rw-r--r--tests/subliminal_patch/test_gestdown.py2
3 files changed, 13 insertions, 7 deletions
diff --git a/libs/subliminal_patch/providers/gestdown.py b/libs/subliminal_patch/providers/gestdown.py
index c5adbadb9..f8add61ac 100644
--- a/libs/subliminal_patch/providers/gestdown.py
+++ b/libs/subliminal_patch/providers/gestdown.py
@@ -26,7 +26,7 @@ class GestdownSubtitle(Subtitle):
self.page_link = _BASE_URL + data["downloadUri"]
self._id = data["subtitleId"]
self.release_info = data["version"]
- self._matches = {"title", "series", "season", "episode"}
+ self._matches = {"title", "series", "season", "episode", "tvdb_id"}
def get_matches(self, video):
update_matches(self._matches, video, self.release_info)
@@ -106,9 +106,9 @@ class GestdownProvider(Provider):
def _search_show(self, video):
try:
- response = self._session.get(f"{_BASE_URL}/shows/search/{video.series}")
+ response = self._session.get(f"{_BASE_URL}/shows/external/tvdb/{video.series_tvdb_id}")
response.raise_for_status()
- return response.json()["shows"][0]
+ return response.json()["shows"]
except HTTPError as error:
if error.response.status_code == 404:
return None
@@ -118,14 +118,18 @@ class GestdownProvider(Provider):
@_retry_on_423
def list_subtitles(self, video, languages):
subtitles = []
- show = self._search_show(video)
- if show is None:
+ shows = self._search_show(video)
+ if shows is None:
logger.debug("Couldn't find the show")
return subtitles
for language in languages:
try:
- subtitles += self._subtitles_search(video, language, show["id"])
+ for show in shows:
+ subs = list(self._subtitles_search(video, language, show["id"]))
+ if len(subs) > 0:
+ subtitles += subs
+ continue
except HTTPError as error:
if error.response.status_code == 404:
logger.debug("Couldn't find the show or its season/episode")
diff --git a/tests/subliminal_patch/conftest.py b/tests/subliminal_patch/conftest.py
index 07c79e9d2..6dd0dd559 100644
--- a/tests/subliminal_patch/conftest.py
+++ b/tests/subliminal_patch/conftest.py
@@ -123,6 +123,7 @@ def episodes():
1,
1,
source="Blu-Ray",
+ series_tvdb_id=81189,
series_imdb_id="tt0903747",
release_group="REWARD",
resolution="720p",
@@ -133,6 +134,7 @@ def episodes():
"Better Call Saul",
6,
4,
+ series_tvdb_id=273181,
source="Web",
resolution="720p",
video_codec="H.264",
diff --git a/tests/subliminal_patch/test_gestdown.py b/tests/subliminal_patch/test_gestdown.py
index 117430a1d..35749d7e7 100644
--- a/tests/subliminal_patch/test_gestdown.py
+++ b/tests/subliminal_patch/test_gestdown.py
@@ -79,7 +79,7 @@ def test_subtitle_download(subtitle):
def test_list_subtitles_423(episodes, requests_mock, mocker):
mocker.patch("time.sleep")
requests_mock.get(
- "https://api.gestdown.info/shows/search/Breaking%20Bad",
+ "https://api.gestdown.info/shows/external/tvdb/81189",
status_code=200,
text='{"shows":[{"id":"cd880e2e-ef44-47cd-9f3d-a03b343ba2d0","name":"Breaking Bad","nbSeasons":5,"seasons":[1,2,3,4,5]}]}'
)