2021-12-30 19:31:59 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import pytest
|
2022-04-19 00:17:51 +00:00
|
|
|
import copy
|
|
|
|
|
2021-12-30 19:31:59 +00:00
|
|
|
from subliminal_patch.providers.subdivx import SubdivxSubtitlesProvider
|
|
|
|
from subliminal_patch.providers.subdivx import SubdivxSubtitle
|
2022-04-19 00:17:51 +00:00
|
|
|
from subliminal_patch.core import SZProviderPool
|
2022-01-12 04:15:57 +00:00
|
|
|
from subliminal_patch.core import Episode
|
2021-12-30 19:31:59 +00:00
|
|
|
from subzero.language import Language
|
|
|
|
|
|
|
|
|
|
|
|
def test_list_subtitles_movie(movies):
|
|
|
|
item = movies["dune"]
|
|
|
|
with SubdivxSubtitlesProvider() as provider:
|
|
|
|
subtitles = provider.list_subtitles(item, {Language("spa", "MX")})
|
2022-04-19 00:17:51 +00:00
|
|
|
assert len(subtitles) >= 9
|
2021-12-30 19:31:59 +00:00
|
|
|
|
|
|
|
|
2022-05-20 19:03:03 +00:00
|
|
|
def test_list_subtitles_movie_with_year_fallback(movies):
|
|
|
|
item = list(movies.values())[0]
|
|
|
|
item.title = "Everything Everywhere All at Once"
|
|
|
|
item.year = 2022
|
|
|
|
|
|
|
|
with SubdivxSubtitlesProvider() as provider:
|
|
|
|
assert provider.list_subtitles(item, {Language("spa", "MX")})
|
|
|
|
|
|
|
|
|
2022-06-21 05:44:24 +00:00
|
|
|
def test_handle_multi_page_search(episodes):
|
|
|
|
with SubdivxSubtitlesProvider() as provider:
|
2022-10-20 23:42:25 +00:00
|
|
|
for _ in provider._handle_multi_page_search(
|
|
|
|
"Game Of Thrones", episodes["got_s03e10"]
|
|
|
|
):
|
|
|
|
pass
|
2022-06-21 05:44:24 +00:00
|
|
|
|
|
|
|
|
2022-04-19 00:17:51 +00:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"episode_key,expected", [("breaking_bad_s01e01", 15), ("inexistent", 0)]
|
|
|
|
)
|
|
|
|
def test_list_subtitles_episode(episodes, episode_key, expected):
|
|
|
|
item = episodes[episode_key]
|
2021-12-30 19:31:59 +00:00
|
|
|
with SubdivxSubtitlesProvider() as provider:
|
|
|
|
subtitles = provider.list_subtitles(item, {Language("spa", "MX")})
|
2022-04-19 00:17:51 +00:00
|
|
|
assert len(subtitles) >= expected
|
2021-12-30 19:31:59 +00:00
|
|
|
|
|
|
|
|
2022-11-09 07:38:50 +00:00
|
|
|
def test_list_subtitles_episode_with_year(episodes):
|
|
|
|
item = list(episodes.values())[0]
|
|
|
|
|
|
|
|
item.series = "The Twilight Zone"
|
|
|
|
item.name = "The Twilight Zone"
|
|
|
|
item.year = 1959
|
|
|
|
item.season = 1
|
|
|
|
item.episode = 1
|
|
|
|
|
|
|
|
with SubdivxSubtitlesProvider() as provider:
|
|
|
|
assert provider.list_subtitles(item, {Language.fromietf("es")})
|
|
|
|
|
|
|
|
|
2022-05-03 18:47:16 +00:00
|
|
|
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")})
|
|
|
|
|
|
|
|
|
2022-10-20 00:06:00 +00:00
|
|
|
def test_list_subtitles_episode_with_title_only_fallback(episodes):
|
2022-10-19 05:17:54 +00:00
|
|
|
item = list(episodes.values())[0]
|
|
|
|
item.series = "The Bear"
|
|
|
|
item.name = "The Bear"
|
|
|
|
item.season = 1
|
|
|
|
item.episode = 1
|
|
|
|
|
|
|
|
with SubdivxSubtitlesProvider() as provider:
|
|
|
|
subtitles = provider.list_subtitles(item, {Language("spa", "MX")})
|
|
|
|
assert len(subtitles) > 2
|
|
|
|
|
2023-05-09 21:08:22 +00:00
|
|
|
def test_list_subtitles_episode_with_episode_title_fallback(episodes):
|
|
|
|
item = list(episodes.values())[0]
|
|
|
|
item.series = "30 for 30"
|
|
|
|
item.title = "The Two Escobars"
|
|
|
|
item.season = 1
|
|
|
|
item.episode = 16
|
|
|
|
|
|
|
|
with SubdivxSubtitlesProvider() as provider:
|
|
|
|
sub = provider.list_subtitles(item, {Language("spa", "MX")})[0]
|
|
|
|
assert sub.get_matches(item)
|
|
|
|
provider.download_subtitle(sub)
|
|
|
|
assert sub.is_valid()
|
|
|
|
|
2022-10-19 05:17:54 +00:00
|
|
|
|
2021-12-30 19:31:59 +00:00
|
|
|
def test_download_subtitle(movies):
|
|
|
|
subtitle = SubdivxSubtitle(
|
|
|
|
Language("spa", "MX"),
|
|
|
|
movies["dune"],
|
|
|
|
"https://www.subdivx.com/X66XNjMxMTAxX-dune--2021-aka-dune-part-one.html",
|
|
|
|
"Dune",
|
|
|
|
"",
|
|
|
|
"",
|
2022-01-12 04:15:57 +00:00
|
|
|
"https://www.subdivx.com/bajar.php?id=631101&u=9",
|
2021-12-30 19:31:59 +00:00
|
|
|
)
|
|
|
|
with SubdivxSubtitlesProvider() as provider:
|
|
|
|
provider.download_subtitle(subtitle)
|
|
|
|
assert subtitle.content is not None
|
2022-01-12 04:15:57 +00:00
|
|
|
|
|
|
|
|
2022-04-19 00:17:51 +00:00
|
|
|
def test_download_subtitle_episode_pack(episodes):
|
|
|
|
video = copy.copy(episodes["breaking_bad_s01e01"])
|
|
|
|
video.episode = 3
|
|
|
|
|
|
|
|
subtitle = SubdivxSubtitle(
|
|
|
|
Language("spa", "MX"),
|
|
|
|
video,
|
|
|
|
"https://www.subdivx.com/X66XMzY1NjEwX-breaking-bad-s01e0107.html",
|
|
|
|
"Breaking Bad S01E01-07",
|
|
|
|
"Son los del torrent que vienen Formato / Dimensiones 624x352 / Tamaño 351 MB -Incluye los Torrents-",
|
|
|
|
"",
|
|
|
|
"https://www.subdivx.com/bajar.php?id=365610&u=7",
|
|
|
|
)
|
|
|
|
with SubdivxSubtitlesProvider() as provider:
|
|
|
|
provider.download_subtitle(subtitle)
|
|
|
|
assert subtitle.content is not None
|
|
|
|
|
|
|
|
|
2022-01-12 04:15:57 +00:00
|
|
|
@pytest.fixture
|
|
|
|
def video():
|
|
|
|
return Episode(
|
|
|
|
**{
|
|
|
|
"name": "/tv/SEAL Team/Season 5/SEAL.Team.S05E11.1080p.WEB.H264-CAKES[rarbg].mkv",
|
|
|
|
"release_group": "CAKES",
|
|
|
|
"series": "SEAL Team",
|
|
|
|
"source": "Web",
|
|
|
|
"resolution": "1080p",
|
|
|
|
"video_codec": "H.264",
|
|
|
|
"season": 5,
|
|
|
|
"episode": 11,
|
|
|
|
"title": "Violence of Action",
|
|
|
|
"alternative_series": [],
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def test_subtitle_description_not_lowercase(video):
|
|
|
|
with SubdivxSubtitlesProvider() as provider:
|
|
|
|
subtitles = provider.list_subtitles(video, {Language("spa", "MX")})
|
|
|
|
assert subtitles
|
2022-10-20 00:06:00 +00:00
|
|
|
assert not subtitles[0]._description.islower()
|
2022-01-12 04:15:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_subtitle_matches(video):
|
|
|
|
subtitle = SubdivxSubtitle(
|
|
|
|
Language("spa", "MX"),
|
|
|
|
video,
|
|
|
|
"SEAL Team S05E10",
|
|
|
|
"https://www.subdivx.com/X66XNjM1MTAxX-seal-team-s05e10.html",
|
|
|
|
(
|
|
|
|
"Mi subtítulo y sincronización en Español neutro, para SEAL TEAM -Temp 05x10 "
|
|
|
|
"Head On para WEB.H265-GGWP, NTb 1080p, WEB-H264.CAKES, WEBRip.x264-ION10 y "
|
|
|
|
"otras seguramente, gracias por sus comentarios, saludos."
|
|
|
|
),
|
|
|
|
"tolobich",
|
|
|
|
"https://www.subdivx.com/bajar.php?id=635101&u=9",
|
|
|
|
)
|
|
|
|
|
|
|
|
matches = subtitle.get_matches(video)
|
|
|
|
assert "source" in matches
|
|
|
|
assert "resolution" in matches
|
|
|
|
assert "video_codec" in matches
|
|
|
|
assert "release_group" in matches
|
2023-04-15 03:19:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_latin_1_subtitles():
|
|
|
|
item = Episode.fromname(
|
|
|
|
"/tv/Grey's Anatomy/Season 19/Greys.Anatomy.S19E13.1080p.WEB.h264-ELEANOR[rarbg].mkv"
|
|
|
|
)
|
|
|
|
|
|
|
|
item.series = "Grey's Anatomy"
|
|
|
|
item.season = 19
|
|
|
|
item.episode = 13
|
|
|
|
|
|
|
|
with SubdivxSubtitlesProvider() as provider:
|
|
|
|
subtitles = provider.list_subtitles(item, {Language.fromietf("es")})
|
|
|
|
subtitle = subtitles[0]
|
|
|
|
|
|
|
|
provider.download_subtitle(subtitle)
|
|
|
|
|
|
|
|
assert subtitle.is_valid()
|