Пример #1
0
def get_eng_from_open_subtitile(sub_shooter, file_path, result_subtitle_file):
    sub_eng = get_opensubtitle_sub(file_path)
    if not sub_eng:
        logger.info('english sub file not found')
        srt_merge([sub_shooter], result_subtitle_file, 0, 2)
    else:
        srt_merge([sub_eng, sub_shooter], result_subtitle_file, 0)
Пример #2
0
def get_chs_from_open_subtitle(sub_shooter, file_path, result_subtitle_file):
    open_subtitle = get_opensubtitle_sub(file_path, 'chs')
    if not open_subtitle:
        logger.info('chinese sub file not found')
        srt_merge([sub_shooter], result_subtitle_file, 0, 2)
    else:
        srt_merge([sub_shooter, open_subtitle], result_subtitle_file, 0)
Пример #3
0
def get_subtitles_for_the_file(file_path):
    result_subtitle_file = splitext(file_path)[0] + ".combined.srt"
    sub_shooter, lang_ = get_shooter_sub(file_path)
    if lang_ == 'chs_eng':
        srt_merge([sub_shooter], result_subtitle_file, 0, 1)
    if lang_ == 'chs':
        get_eng_from_open_subtitile(sub_shooter, file_path,
                                    result_subtitle_file)
    if lang_ == 'eng':
        get_chs_from_open_subtitle(sub_shooter, file_path,
                                   result_subtitle_file)
    if lang_ == 'none':
        get_both_subtitles_from_open_subtitle(file_path, result_subtitle_file)
Пример #4
0
def get_both_subtitles_from_open_subtitle(file_path, result_subtitle_file):
    open_subtitle_chs = get_opensubtitle_sub(file_path, 'chs')
    open_subtitle_eng = get_opensubtitle_sub(file_path)
    if open_subtitle_eng and open_subtitle_chs:
        srt_merge([open_subtitle_chs, open_subtitle_eng], result_subtitle_file,
                  0)
    elif open_subtitle_eng:
        srt_merge([open_subtitle_eng], result_subtitle_file, 0, 2)
        logger.info('chinese sub file not found')
    elif open_subtitle_chs:
        srt_merge([open_subtitle_chs], result_subtitle_file, 0, 2)
        logger.info('english sub file not found')
    else:
        logger.warning('NO SUB FILE FOUND for file: %s', file_path)