mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-04-23 22:27:17 -04:00
Improved Gestdown provider to get better matches using tvdb id
This commit is contained in:
parent
e4bf041ecb
commit
248e49de76
3 changed files with 13 additions and 7 deletions
|
@ -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")
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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]}]}'
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue