summaryrefslogtreecommitdiffhomepage
path: root/tests/subliminal_patch/test_animetosho.py
blob: acb62781c5227a439ac381293871c8a973e42724 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3

import os
import pytest

from subliminal_patch.core import Episode
from subliminal_patch.providers.animetosho import AnimeToshoProvider
from subzero.language import Language

@pytest.fixture(scope="session")
def anime_episodes():
    return {
        "frieren_s01e01": Episode(
            "Frieren - Beyond Journey's End S01E28 1080p WEB x264 AAC -Tsundere-Raws (CR) (Sousou no Frieren).mkv",
            "Frieren: Beyond Journey's End",
            1,
            28,
            source="Web",
            series_anidb_id=17617,
            series_anidb_episode_id=271418,
            series_tvdb_id=424536,
            series_imdb_id="tt22248376",
            release_group="Tsundere-Raws",
            resolution="1080p",
            video_codec="H.264",
        ),
        "solo_leveling_s01e10": Episode(
            "[New-raws] Ore Dake Level Up na Ken - 12 END [1080p] [AMZN].mkv",
            "Solo Leveling",
            1,
            12,
            source="Web",
            series_anidb_id=17495,
            series_anidb_episode_id=277518,
            series_tvdb_id=389597,
            series_imdb_id="tt21209876",
            release_group="New-raws",
            resolution="1080p",
            video_codec="H.264",
        ),
    }


def test_list_subtitles(anime_episodes, requests_mock, data):
    language = Language("eng")
    item = anime_episodes["solo_leveling_s01e10"]

    with open(os.path.join(data, 'animetosho_episode_response.json'), "rb") as f:
        requests_mock.get(' https://feed.animetosho.org/json?eid=277518', content=f.read())

    with open(os.path.join(data, 'animetosho_series_response.json'), "rb") as f:
        response = f.read()
        requests_mock.get('https://feed.animetosho.org/json?show=torrent&id=608516', content=response)
        requests_mock.get('https://feed.animetosho.org/json?show=torrent&id=608526', content=response)

    with AnimeToshoProvider(2) as provider:
        subtitles = provider.list_subtitles(item, languages={language})

        assert len(subtitles) == 2