Beispiel #1
0
    def subtitle(self, episodes):

        # Parse babelfish languages
        bb_lang = {Language.fromietf(l) for l in self.languages}

        # Create subliminal episode set
        sub_episodes = set()
        for episode in episodes:

            ep_path = os.path.join(episode['dir'], episode['filename'])
            sub_episode = Episode.fromguess(ep_path, episode)

            # Look for external subtitles (not done automatically, apparently)
            sub_episode.subtitle_languages |= set(search_external_subtitles(sub_episode.name).values())

            sub_episodes.add(sub_episode)

        # download subtitles in the specified language
        subl_subtitles = download_best_subtitles(sub_episodes, bb_lang, providers=self.providers)

        for video, subtitles in subl_subtitles.items():

            save_subtitles(video, subtitles)

            # save subtitle languages in episode dict
Beispiel #2
0
def test_from_code__valid_code():
    # Given
    code = 'pob'

    # When
    actual = sut.from_code(code)

    # Then
    assert Language.fromietf('pt-BR') == actual
Beispiel #3
0
def test_from_code__valid_code():
    # Given
    code = 'pob'

    # When
    actual = sut.from_code(code)

    # Then
    assert Language.fromietf('pt-BR') == actual
Beispiel #4
0
def test_get_needed_languages__multi_enabled(monkeypatch):
    # Given
    monkeypatch.setattr(app, 'SUBTITLES_MULTI', True)
    monkeypatch.setattr(app, 'SUBTITLES_LANGUAGES', ['pob', 'trash', 'eng', 'fre', 'abc'])
    existing_subtitles = {'pob', 'eng'}

    # When
    actual = sut.get_needed_languages(existing_subtitles)

    # Then
    assert {Language.fromietf('fr')} == actual
Beispiel #5
0
def test_compute_subtitle_path__single_with_valid_language(monkeypatch):
    # Given
    monkeypatch.setattr('medusa.SUBTITLES_MULTI', False)
    subtitle = Subtitle(language=Language('por', 'BR'))
    video_path = '/folder/subfolder/video.mkv'
    subtitles_dir = None

    # When
    actual = sut.compute_subtitle_path(subtitle, video_path, subtitles_dir)

    # Then
    assert '/folder/subfolder/video.srt' == actual
Beispiel #6
0
 def create(language, **kwargs):
     target = Subtitle(Language.fromopensubtitles(language))
     return _patch_object(monkeypatch, target, **kwargs)
Beispiel #7
0
 def create(language, **kwargs):
     target = Subtitle(Language.fromopensubtitles(language))
     return _patch_object(monkeypatch, target, **kwargs)