summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVitiko <[email protected]>2022-05-03 14:47:16 -0400
committerVitiko <[email protected]>2022-05-03 14:47:16 -0400
commit7423c80a28b894812b121a89f38d045f7c87d5ca (patch)
tree947f1f442bf262e0ae790bc608370951d95085f0
parent79f81e0edbcb994db1816d874a448b992b81a00f (diff)
downloadbazarr-7423c80a28b894812b121a89f38d045f7c87d5ca.tar.gz
bazarr-7423c80a28b894812b121a89f38d045f7c87d5ca.zip
Subdivx Provider: improve language parser
-rw-r--r--libs/subliminal_patch/providers/subdivx.py7
-rw-r--r--tests/subliminal_patch/conftest.py9
-rw-r--r--tests/subliminal_patch/test_subdivx.py6
3 files changed, 19 insertions, 3 deletions
diff --git a/libs/subliminal_patch/providers/subdivx.py b/libs/subliminal_patch/providers/subdivx.py
index 68b4a33dc..bc902363e 100644
--- a/libs/subliminal_patch/providers/subdivx.py
+++ b/libs/subliminal_patch/providers/subdivx.py
@@ -216,13 +216,14 @@ class SubdivxSubtitlesProvider(Provider):
if not any(item in datos for item in ("Cds:</b> 1", "SubRip")):
continue
- spain = "/pais/7.gif" in datos
- language = Language.fromalpha2("es") if spain else Language("spa", "MX")
-
# description
sub_details = body_soup.find("div", {"id": "buscador_detalle_sub"}).text
description = sub_details.replace(",", " ")
+ # language
+ spain = "/pais/7.gif" in datos or "espaƱa" in description.lower()
+ language = Language.fromalpha2("es") if spain else Language("spa", "MX")
+
# uploader
uploader = body_soup.find("a", {"class": "link1"}).text
download_url = _get_download_url(body_soup)
diff --git a/tests/subliminal_patch/conftest.py b/tests/subliminal_patch/conftest.py
index afd2cc913..d60a807aa 100644
--- a/tests/subliminal_patch/conftest.py
+++ b/tests/subliminal_patch/conftest.py
@@ -126,6 +126,15 @@ def episodes():
resolution="720p",
video_codec="H.264",
),
+ "better_call_saul_s06e04": Episode(
+ "Better.Call.Saul.S06E04.720p.WEBRIP.X264.mkv",
+ "Better Call Saul",
+ 6,
+ 4,
+ source="Web",
+ resolution="720p",
+ video_codec="H.264",
+ ),
"inexistent": Episode(
"Inexistent.TVShow.S01E01.720p.BluRay.X264-REWARD.mkv",
"121361asdfgh",
diff --git a/tests/subliminal_patch/test_subdivx.py b/tests/subliminal_patch/test_subdivx.py
index 2b0a6c11f..7ce4980ce 100644
--- a/tests/subliminal_patch/test_subdivx.py
+++ b/tests/subliminal_patch/test_subdivx.py
@@ -27,6 +27,12 @@ def test_list_subtitles_episode(episodes, episode_key, expected):
assert len(subtitles) >= expected
+def test_list_subtitles_castillian_spanish(episodes):
+ item = episodes["better_call_saul_s06e04"]
+ with SubdivxSubtitlesProvider() as provider:
+ assert provider.list_subtitles(item, {Language.fromietf("es")})
+
+
def test_download_subtitle(movies):
subtitle = SubdivxSubtitle(
Language("spa", "MX"),