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
def test_from_code__valid_code(): # Given code = 'pob' # When actual = sut.from_code(code) # Then assert Language.fromietf('pt-BR') == actual
def test_from_code__valid_code(): # Given code = 'pob' # When actual = sut.from_code(code) # Then assert Language.fromietf('pt-BR') == actual
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
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