def test_search_external_subtitles_no_directory(movies, tmpdir, monkeypatch): video_name = os.path.split(movies['man_of_steel'].name)[1] video_root = os.path.splitext(video_name)[0] tmpdir.ensure(video_name) monkeypatch.chdir(str(tmpdir)) expected_subtitles = { video_name + '.srt': Language('und'), video_root + '.en.srt': Language('eng') } for path in expected_subtitles: tmpdir.ensure(path) subtitles = search_external_subtitles(video_name) assert subtitles == expected_subtitles
def test_search_external_subtitles_in_directory(episodes, tmpdir, monkeypatch): video_name = episodes['marvels_agents_of_shield_s02e06'].name video_root = os.path.splitext(video_name)[0] tmpdir.ensure('tvshows', video_name) subtitles_directory = str(tmpdir.ensure('subtitles', dir=True)) expected_subtitles = { video_name + '.srt': Language('und'), video_root + '.en.srt': Language('eng') } tmpdir.ensure('tvshows', video_name + '.fr.srt') for path in expected_subtitles: tmpdir.ensure('subtitles', path) subtitles = search_external_subtitles(video_name, directory=subtitles_directory) assert subtitles == expected_subtitles
def test_search_external_subtitles(episodes, tmpdir): video_name = os.path.split(episodes['bbt_s07e05'].name)[1] video_root = os.path.splitext(video_name)[0] video_path = str(tmpdir.ensure(video_name)) expected_subtitles = { video_name + '.srt': Language('und'), video_root + '.srt': Language('und'), video_root + '.en.srt': Language('eng'), video_name + '.fra.srt': Language('fra'), video_root + '.pt-BR.srt': Language('por', 'BR'), video_name + '.sr_cyrl.sub': Language('srp', script='Cyrl'), video_name + '.something.srt': Language('und') } tmpdir.ensure(os.path.split(episodes['got_s03e10'].name)[1] + '.srt') for path in expected_subtitles: tmpdir.ensure(path) subtitles = search_external_subtitles(video_path) assert subtitles == expected_subtitles