Merge pull request #1279 from zx900930/development

fix for #1276
pull/1285/head
morpheus65535 4 years ago committed by GitHub
commit 328ae85a44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -58,10 +58,12 @@ def store_subtitles(original_path, reversed_path):
brazilian_portuguese = [".pt-br", ".pob", "pb"] brazilian_portuguese = [".pt-br", ".pob", "pb"]
brazilian_portuguese_forced = [".pt-br.forced", ".pob.forced", "pb.forced"] brazilian_portuguese_forced = [".pt-br.forced", ".pob.forced", "pb.forced"]
simplified_chinese = [".chs", ".sc", ".zhs", ".hans", ".gb", u"", u"双语"] simplified_chinese_long = [".simplified"]
simplified_chinese_forced = [".chs.forced", ".sc.forced", ".zhs.forced", ".hans.forced", ".gb.forced", u"简体中文.forced", u"双语.forced"] simplified_chinese_short = [".chs", ".sc", ".zhs", "hans", ".gb", u"", u"双语"]
traditional_chinese = [".cht", ".tc", ".zht", ".hant", ".big5", u"", u"雙語", "zh-tw"] simplified_chinese_forced = [".chs.forced", ".sc.forced", ".zhs.forced", "hans.forced", ".gb.forced", u"简体中文.forced", u"双语.forced"]
traditional_chinese_forced = [".cht.forced", ".tc.forced", ".zht.forced", ".hant.forced", ".big5.forced", u"繁體中文.forced", u"雙語.forced", "zh-tw.forced"] traditional_chinese_long = [".traditional"]
traditional_chinese_short = [".cht", ".tc", ".zh-tw", ".zht", "hant", "big5", u"", u"雙語"]
traditional_chinese_forced = [".cht.forced", ".tc.forced", ".zht.forced", "hant.forced", ".big5.forced", u"繁體中文.forced", u"雙語.forced", "zh-tw.forced"]
try: try:
dest_folder = get_subtitle_destination_folder() dest_folder = get_subtitle_destination_folder()
@ -89,7 +91,7 @@ def store_subtitles(original_path, reversed_path):
logging.debug("BAZARR external subtitles detected: " + "pb:forced") logging.debug("BAZARR external subtitles detected: " + "pb:forced")
actual_subtitles.append( actual_subtitles.append(
[str("pb:forced"), path_mappings.path_replace_reverse(subtitle_path)]) [str("pb:forced"), path_mappings.path_replace_reverse(subtitle_path)])
elif any(ext in (str(os.path.splitext(subtitle)[0]).lower())[-12:] for ext in simplified_chinese): elif any(ext in (str(subtitle_path).lower())[:-7] for ext in simplified_chinese_short) or (str(subtitle_path).lower())[:-11] in simplified_chinese_long:
logging.debug("BAZARR external subtitles detected: " + "zh") logging.debug("BAZARR external subtitles detected: " + "zh")
actual_subtitles.append( actual_subtitles.append(
[str("zh"), path_mappings.path_replace_reverse(subtitle_path)]) [str("zh"), path_mappings.path_replace_reverse(subtitle_path)])
@ -97,7 +99,7 @@ def store_subtitles(original_path, reversed_path):
logging.debug("BAZARR external subtitles detected: " + "zh:forced") logging.debug("BAZARR external subtitles detected: " + "zh:forced")
actual_subtitles.append( actual_subtitles.append(
[str("zh:forced"), path_mappings.path_replace_reverse(subtitle_path)]) [str("zh:forced"), path_mappings.path_replace_reverse(subtitle_path)])
elif any(ext in (str(os.path.splitext(subtitle)[0]).lower())[-12:] for ext in traditional_chinese): elif any(ext in (str(subtitle_path).lower())[:-7] for ext in traditional_chinese_short) or (str(subtitle_path).lower())[:-12] in traditional_chinese_long:
logging.debug("BAZARR external subtitles detected: " + "zt") logging.debug("BAZARR external subtitles detected: " + "zt")
actual_subtitles.append( actual_subtitles.append(
[str("zt"), path_mappings.path_replace_reverse(subtitle_path)]) [str("zt"), path_mappings.path_replace_reverse(subtitle_path)])
@ -170,10 +172,12 @@ def store_subtitles_movie(original_path, reversed_path):
brazilian_portuguese = [".pt-br", ".pob", "pb"] brazilian_portuguese = [".pt-br", ".pob", "pb"]
brazilian_portuguese_forced = [".pt-br.forced", ".pob.forced", "pb.forced"] brazilian_portuguese_forced = [".pt-br.forced", ".pob.forced", "pb.forced"]
simplified_chinese = [".chs", ".sc", ".zhs", ".hans", ".gb", u"", u"双语"] simplified_chinese_long = [".simplified"]
simplified_chinese_forced = [".chs.forced", ".sc.forced", ".zhs.forced", ".hans.forced", ".gb.forced", u"简体中文.forced", u"双语.forced"] simplified_chinese_short = [".chs", ".sc", ".zhs", "hans", ".gb", u"", u"双语"]
traditional_chinese = [".cht", ".tc", ".zht", ".hant", ".big5", u"", u"雙語", "zh-tw"] simplified_chinese_forced = [".chs.forced", ".sc.forced", ".zhs.forced", "hans.forced", ".gb.forced", u"简体中文.forced", u"双语.forced"]
traditional_chinese_forced = [".cht.forced", ".tc.forced", ".zht.forced",".hant.forced", ".big5.forced", u"繁體中文.forced", u"雙語.forced", "zh-tw.forced"] traditional_chinese_long = [".traditional"]
traditional_chinese_short = [".cht", ".tc", ".zh-tw", ".zht", "hant", "big5", u"", u"雙語"]
traditional_chinese_forced = [".cht.forced", ".tc.forced", ".zht.forced", "hant.forced", ".big5.forced", u"繁體中文.forced", u"雙語.forced", "zh-tw.forced"]
try: try:
dest_folder = get_subtitle_destination_folder() or '' dest_folder = get_subtitle_destination_folder() or ''
core.CUSTOM_PATHS = [dest_folder] if dest_folder else [] core.CUSTOM_PATHS = [dest_folder] if dest_folder else []
@ -197,13 +201,13 @@ def store_subtitles_movie(original_path, reversed_path):
elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese_forced)): elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese_forced)):
logging.debug("BAZARR external subtitles detected: " + "pb:forced") logging.debug("BAZARR external subtitles detected: " + "pb:forced")
actual_subtitles.append([str("pb:forced"), path_mappings.path_replace_reverse_movie(subtitle_path)]) actual_subtitles.append([str("pb:forced"), path_mappings.path_replace_reverse_movie(subtitle_path)])
elif any(ext in (str(os.path.splitext(subtitle)[0]).lower())[-12:] for ext in simplified_chinese): elif any(ext in (str(subtitle_path).lower())[:-7] for ext in simplified_chinese_short) or (str(subtitle_path).lower())[:-11] in simplified_chinese_long:
logging.debug("BAZARR external subtitles detected: " + "zh") logging.debug("BAZARR external subtitles detected: " + "zh")
actual_subtitles.append([str("zh"), path_mappings.path_replace_reverse_movie(subtitle_path)]) actual_subtitles.append([str("zh"), path_mappings.path_replace_reverse_movie(subtitle_path)])
elif any(ext in (str(os.path.splitext(subtitle)[0]).lower())[-12:] for ext in simplified_chinese_forced): elif any(ext in (str(os.path.splitext(subtitle)[0]).lower())[-12:] for ext in simplified_chinese_forced):
logging.debug("BAZARR external subtitles detected: " + "zh:forced") logging.debug("BAZARR external subtitles detected: " + "zh:forced")
actual_subtitles.append([str("zh:forced"), path_mappings.path_replace_reverse_movie(subtitle_path)]) actual_subtitles.append([str("zh:forced"), path_mappings.path_replace_reverse_movie(subtitle_path)])
elif any(ext in (str(os.path.splitext(subtitle)[0]).lower())[-12:] for ext in traditional_chinese): elif any(ext in (str(subtitle_path).lower())[:-7] for ext in traditional_chinese_short) or (str(subtitle_path).lower())[:-12] in traditional_chinese_long:
logging.debug("BAZARR external subtitles detected: " + "zt") logging.debug("BAZARR external subtitles detected: " + "zt")
actual_subtitles.append([str("zt"), path_mappings.path_replace_reverse_movie(subtitle_path)]) actual_subtitles.append([str("zt"), path_mappings.path_replace_reverse_movie(subtitle_path)])
elif any(ext in (str(os.path.splitext(subtitle)[0]).lower())[-12:] for ext in traditional_chinese_forced): elif any(ext in (str(os.path.splitext(subtitle)[0]).lower())[-12:] for ext in traditional_chinese_forced):
@ -545,8 +549,9 @@ def guess_external_subtitles(dest_folder, subtitles):
detected_language = guess_language(text) detected_language = guess_language(text)
#add simplified and traditional chinese detection #add simplified and traditional chinese detection
if detected_language == 'zh': if detected_language == 'zh':
traditional_chinese = [".cht", ".tc", ".traditional",".zh-tw", ".zht", "hant", "big5", u"", u"雙語"] traditional_chinese_long = [".traditional"]
if any(ext in (str(subtitle_path).lower())[:-16] for ext in traditional_chinese): traditional_chinese_short = [".cht", ".tc", ".zh-tw", ".zht", "hant", "big5", u"", u"雙語"]
if any(ext in (str(subtitle_path).lower())[:-7] for ext in traditional_chinese_short) or (str(subtitle_path).lower())[:-12]==traditional_chinese_long:
detected_language == 'zt' detected_language == 'zt'
except UnicodeDecodeError: except UnicodeDecodeError:
detector = Detector() detector = Detector()

Loading…
Cancel
Save