def test_search_subs_by_zimuzu(): directory = os.path.expanduser('~/Downloads/test/') if not os.path.exists(directory): pytest.skip('test directory not exists') rm_subtitles(directory) subfinder = SubFinder(path=directory, subsearcher_class=get_subsearcher('zimuzu'), debug=True) subfinder.start() files = [f for f in os.listdir(directory) if f.endswith('.ass') or f.endswith('.srt')] assert len(files) >= 0
def test_search_subs_by_subhd(videofile: pathlib.Path): parent = videofile.parent rm_subtitles(parent) sc = get_subsearcher('subhd') subfinder = SubFinder(path=videofile, subsearcher_class=sc, debug=True) subfinder.start() exts = sc.SUPPORT_EXTS files = [f for f in parent.iterdir() if f.suffix[1:] in exts] assert len(files) >= 0
def test_videofile(self, tmp_videofiles, tmp_not_videofiles): subfinder = SubFinder() for f in tmp_videofiles: assert subfinder._is_videofile(f) not_videofiles = [ '/path/not/exists/video_file.mkv', ] for f in not_videofiles: assert not subfinder._is_videofile(f) for f in tmp_not_videofiles: assert not subfinder._is_videofile(f)
def test_parse(videofile: pathlib.Path): zimuzu: ZimuzuSubSearcher = ZimuzuSubSearcher(SubFinder()) zimuzu._prepare_search_subs(videofile) subinfo_list = zimuzu._get_subinfo_list(zimuzu.keywords[0]) assert subinfo_list subinfo = subinfo_list[0] assert subinfo assert subinfo['title'] and subinfo['link'] and subinfo['languages']
def test_parse(videofile: pathlib.Path): subhd: SubHDSubSearcher = SubHDSubSearcher(SubFinder()) subhd._prepare_search_subs(videofile) subinfo_list = subhd._get_subinfo_list(subhd.keywords[0]) assert subinfo_list subinfo = subinfo_list[0] assert subinfo assert subinfo['title'] and subinfo['link'] and subinfo[ 'exts'] and subinfo['languages']
def test_gen_subname(): vidoefile = 'test.mkv' language = 'zh' ext = 'srt' subfinder = SubFinder() s = HTMLSubSearcher(subfinder) s._prepare_search_subs(vidoefile) origin_file = 'origin_file.简体&英文.ass' subname = s._gen_subname(origin_file) assert subname == 'test.简体&英文.ass' origin_file = 'origin_file.简体.ass' subname = s._gen_subname(origin_file) assert subname == 'test.简体.ass' origin_file = 'origin_file.英文.ass' subname = s._gen_subname(origin_file) assert subname == 'test.英文.ass' origin_file = 'origin_file.繁体&英文.ass' subname = s._gen_subname(origin_file) assert subname == 'test.繁体&英文.ass'
def zimuku(): s = SubFinder() z = ZimukuSubSearcher(s) return z
def subhd(): s = SubFinder() z = SubHDSubSearcher(s) return z
def shooter(): s = ShooterSubSearcher(SubFinder()) return s