def test_list_subtitles_movie(movies):
    video = movies['man_of_steel']
    languages = {Language('eng'), Language('fra')}
    expected_subtitles = {'Tsko', 'Nv0l', 'XnUm', 'EMgo', 'ZmIm', 'whQm', 'MOko', 'aoYm', 'WMgp', 'd_Im', 'GMso',
                          '8RIm', 'NLUo', 'uYcm'}
    with PodnapisiProvider() as provider:
        subtitles = provider.list_subtitles(video, languages)
    assert {subtitle.pid for subtitle in subtitles} == expected_subtitles
    assert {subtitle.language for subtitle in subtitles} == languages
def test_query_movie(movies):
    video = movies['man_of_steel']
    language = Language('eng')
    expected_subtitles = {'Nv0l', 'EMgo', '8RIm', 'whQm', 'aoYm', 'WMgp', 'Tsko', 'uYcm', 'XnUm', 'NLUo', 'ZmIm',
                          'MOko'}
    with PodnapisiProvider() as provider:
        subtitles = provider.query(language, video.title, year=video.year)
    assert {subtitle.pid for subtitle in subtitles} == expected_subtitles
    assert {subtitle.language for subtitle in subtitles} == {language}
def test_query_episode(episodes):
    video = episodes['bbt_s07e05']
    language = Language('eng')
    expected_subtitles = {'EdQo', '2581', 'w581', 'ftUo', 'WNMo'}
    with PodnapisiProvider() as provider:
        subtitles = provider.query(language, video.series, season=video.season, episode=video.episode,
                                   year=video.year)
    assert {subtitle.pid for subtitle in subtitles} == expected_subtitles
    assert {subtitle.language for subtitle in subtitles} == {language}
def test_list_subtitles_episode_alternative_series(episodes):
    video = episodes['marvels_jessica_jones_s01e13']
    languages = {Language('eng')}
    expected_subtitles = {'JPY-', 'BURB', 'm_c-', 'wFFC', 'tVFC', 'wlFC',
                          'iZk-', 'w_g-', 'CJw-', 'v5c-', 's1FC', 'u5c-'}
    with PodnapisiProvider() as provider:
        subtitles = provider.list_subtitles(video, languages)
    assert {subtitle.pid for subtitle in subtitles} == expected_subtitles
    assert {subtitle.language for subtitle in subtitles} == languages
def test_download_subtitle(movies):
    video = movies['man_of_steel']
    languages = {Language('eng'), Language('fra')}
    with PodnapisiProvider() as provider:
        subtitles = provider.list_subtitles(video, languages)
        subtitle = [s for s in subtitles if s.pid == 'GMso'][0]
        provider.download_subtitle(subtitle)
    assert subtitle.content is not None
    assert subtitle.is_valid() is True
def test_list_subtitles_episode(episodes):
    video = episodes['got_s03e10']
    languages = {Language('eng'), Language('fra')}
    expected_subtitles = {'8cMl', '6MMl', 'jcYl', 'am0s', 'msYl', '7sMl', 'k8Yl', '8BM5', 'Eaom', 'z8Ml', 'lMYl',
                          '78Ml', '0MMl', 'a1I8'}
    with PodnapisiProvider() as provider:
        subtitles = provider.list_subtitles(video, languages)
    assert {subtitle.pid for subtitle in subtitles} == expected_subtitles
    assert {subtitle.language for subtitle in subtitles} == languages
Exemple #7
0
def test_download_subtitle(movies):
    video = movies['man_of_steel']
    languages = {Language('eng'), Language('fra')}
    with PodnapisiProvider() as provider:
        subtitles = provider.list_subtitles(video, languages)
        subtitle = [s for s in subtitles if s.pid == 'GMso'][0]
        matches = subtitle.get_matches(video)
        provider.download_subtitle(subtitle)
    assert subtitle.content is not None
    assert subtitle.is_valid() is True
    assert matches == {'title', 'year', 'country', 'source', 'video_codec'}
def test_subtitles_with_title_unicode(movies):
    video = movies['café_society']
    languages = {Language('fra')}
    expected_subtitles = {'iOlD', 'iulD', '2o5B', 'ielD'}
    with PodnapisiProvider() as provider:
        subtitles = provider.list_subtitles(video, languages)
        wanted_subtitle = [s for s in subtitles if s.pid == 'iOlD'][0]
        matches = wanted_subtitle.get_matches(movies['café_society'])
        provider.download_subtitle(wanted_subtitle)
    assert {subtitle.pid for subtitle in subtitles} == expected_subtitles
    assert {subtitle.language for subtitle in subtitles} == languages
    assert matches == {'title', 'year', 'country'}
    assert wanted_subtitle.content is not None
    assert wanted_subtitle.is_valid() is True