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
60
61
62
63
64
65
66
67
68
69
70
|
#!/usr/bin/env python3
import os
import pytest
import datetime
import tempfile
import subliminal
from subliminal_patch.providers.addic7ed import Addic7edProvider
from subliminal_patch.providers.addic7ed import Addic7edSubtitle
from dogpile.cache.region import register_backend as register_cache_backend
from subzero.language import Language
_ENV_VARS = (
"ANTICAPTCHA_CLASS",
"ANTICAPTCHA_ACCOUNT_KEY",
"ADDIC7ED_USERNAME",
"ADDIC7ED_PASSWORD",
)
def _can_run():
for env_var in _ENV_VARS:
if not os.environ.get(env_var):
return True
return False
pytestmark = pytest.mark.skipif(
_can_run(), reason=f"Some environment variables not set: {_ENV_VARS}"
)
@pytest.fixture(scope="session")
def region():
register_cache_backend(
"subzero.cache.file", "subzero.cache_backends.file", "SZFileBackend"
)
subliminal.region.configure(
"subzero.cache.file",
expiration_time=datetime.timedelta(days=30),
arguments={"appname": "sz_cache", "app_cache_dir": tempfile.gettempdir()},
)
subliminal.region.backend.sync()
def test_list_subtitles_episode(region, episodes):
item = episodes["breaking_bad_s01e01"]
language = Language("eng")
with Addic7edProvider(
os.environ["ADDIC7ED_USERNAME"], os.environ["ADDIC7ED_PASSWORD"]
) as provider:
subtitles = provider.list_subtitles(item, {language})
assert len(subtitles) == 6
subliminal.region.backend.sync()
def test_list_subtitles_movie(region, movies):
item = movies["dune"]
language = Language("eng")
with Addic7edProvider(
os.environ["ADDIC7ED_USERNAME"], os.environ["ADDIC7ED_PASSWORD"]
) as provider:
subtitles = provider.list_subtitles(item, {language})
assert len(subtitles) == 2
subliminal.region.backend.sync()
|