mirror of https://github.com/morpheus65535/bazarr
more strict rules to zh detection
This commit is contained in:
parent
cee1ce6214
commit
7e3305a51e
|
@ -58,11 +58,11 @@ def store_subtitles(original_path, reversed_path):
|
|||
|
||||
brazilian_portuguese = [".pt-br", ".pob", "pb"]
|
||||
brazilian_portuguese_forced = [".pt-br.forced", ".pob.forced", "pb.forced"]
|
||||
simplified_chinese_fuzzy = ["hans", u"简", u"双语"]
|
||||
simplified_chinese = [".chs", ".sc", ".zhs", ".gb",".simplified"]
|
||||
simplified_chinese_fuzzy = [u"简", u"双语"]
|
||||
simplified_chinese = [".chs", ".sc", ".zhs",".zh-hans",".hans",".zh_hans",".zhhans",".gb",".simplified"]
|
||||
simplified_chinese_forced = [".chs.forced", ".sc.forced", ".zhs.forced", "hans.forced", ".gb.forced", u"简体中文.forced", u"双语.forced"]
|
||||
traditional_chinese_fuzzy = ["hant", u"繁", u"雙語"]
|
||||
traditional_chinese = [".cht", ".tc", ".zh-tw", ".zht", ".big5", ".traditional"]
|
||||
traditional_chinese_fuzzy = [u"繁", u"雙語"]
|
||||
traditional_chinese = [".cht", ".tc", ".zh-tw", ".zht",".zh-hant",".zhhant",".zh_hant",".hant", ".big5", ".traditional"]
|
||||
traditional_chinese_forced = [".cht.forced", ".tc.forced", ".zht.forced", "hant.forced", ".big5.forced", u"繁體中文.forced", u"雙語.forced", "zh-tw.forced"]
|
||||
|
||||
try:
|
||||
|
@ -91,7 +91,7 @@ def store_subtitles(original_path, reversed_path):
|
|||
logging.debug("BAZARR external subtitles detected: " + "pb:forced")
|
||||
actual_subtitles.append(
|
||||
[str("pb:forced"), path_mappings.path_replace_reverse(subtitle_path)])
|
||||
elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(simplified_chinese)) or (str(subtitle_path).lower())[:-7] in simplified_chinese_fuzzy:
|
||||
elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(simplified_chinese)) or (str(subtitle_path).lower())[:-5] in simplified_chinese_fuzzy:
|
||||
logging.debug("BAZARR external subtitles detected: " + "zh")
|
||||
actual_subtitles.append(
|
||||
[str("zh"), path_mappings.path_replace_reverse(subtitle_path)])
|
||||
|
@ -99,7 +99,7 @@ def store_subtitles(original_path, reversed_path):
|
|||
logging.debug("BAZARR external subtitles detected: " + "zh:forced")
|
||||
actual_subtitles.append(
|
||||
[str("zh:forced"), path_mappings.path_replace_reverse(subtitle_path)])
|
||||
elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(traditional_chinese)) or (str(subtitle_path).lower())[:-7] in traditional_chinese_fuzzy:
|
||||
elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(traditional_chinese)) or (str(subtitle_path).lower())[:-5] in traditional_chinese_fuzzy:
|
||||
logging.debug("BAZARR external subtitles detected: " + "zt")
|
||||
actual_subtitles.append(
|
||||
[str("zt"), path_mappings.path_replace_reverse(subtitle_path)])
|
||||
|
@ -172,11 +172,11 @@ def store_subtitles_movie(original_path, reversed_path):
|
|||
|
||||
brazilian_portuguese = [".pt-br", ".pob", "pb"]
|
||||
brazilian_portuguese_forced = [".pt-br.forced", ".pob.forced", "pb.forced"]
|
||||
simplified_chinese_fuzzy = ["hans", u"简", u"双语"]
|
||||
simplified_chinese = [".chs", ".sc", ".zhs", ".gb",".simplified"]
|
||||
simplified_chinese_fuzzy = [u"简", u"双语"]
|
||||
simplified_chinese = [".chs", ".sc", ".zhs",".zh-hans",".hans",".zh_hans",".zhhans",".gb",".simplified"]
|
||||
simplified_chinese_forced = [".chs.forced", ".sc.forced", ".zhs.forced", "hans.forced", ".gb.forced", u"简体中文.forced", u"双语.forced"]
|
||||
traditional_chinese_fuzzy = ["hant", u"繁", u"雙語"]
|
||||
traditional_chinese = [".cht", ".tc", ".zh-tw", ".zht", ".big5", ".traditional"]
|
||||
traditional_chinese_fuzzy = [u"繁", u"雙語"]
|
||||
traditional_chinese = [".cht", ".tc", ".zh-tw", ".zht",".zh-hant",".zhhant",".zh_hant",".hant", ".big5", ".traditional"]
|
||||
traditional_chinese_forced = [".cht.forced", ".tc.forced", ".zht.forced", "hant.forced", ".big5.forced", u"繁體中文.forced", u"雙語.forced", "zh-tw.forced"]
|
||||
try:
|
||||
dest_folder = get_subtitle_destination_folder() or ''
|
||||
|
@ -201,13 +201,13 @@ def store_subtitles_movie(original_path, reversed_path):
|
|||
elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese_forced)):
|
||||
logging.debug("BAZARR external subtitles detected: " + "pb:forced")
|
||||
actual_subtitles.append([str("pb:forced"), path_mappings.path_replace_reverse_movie(subtitle_path)])
|
||||
elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(simplified_chinese)) or (str(subtitle_path).lower())[:-7] in simplified_chinese_fuzzy:
|
||||
elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(simplified_chinese)) or (str(subtitle_path).lower())[:-5] in simplified_chinese_fuzzy:
|
||||
logging.debug("BAZARR external subtitles detected: " + "zh")
|
||||
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):
|
||||
logging.debug("BAZARR external subtitles detected: " + "zh:forced")
|
||||
actual_subtitles.append([str("zh:forced"), path_mappings.path_replace_reverse_movie(subtitle_path)])
|
||||
elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(traditional_chinese)) or (str(subtitle_path).lower())[:-7] in traditional_chinese_fuzzy:
|
||||
elif str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(traditional_chinese)) or (str(subtitle_path).lower())[:-5] in traditional_chinese_fuzzy:
|
||||
logging.debug("BAZARR external subtitles detected: " + "zt")
|
||||
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):
|
||||
|
@ -549,9 +549,9 @@ def guess_external_subtitles(dest_folder, subtitles):
|
|||
detected_language = guess_language(text)
|
||||
#add simplified and traditional chinese detection
|
||||
if detected_language == 'zh':
|
||||
traditional_chinese_fuzzy = ["hant", u"繁", u"雙語"]
|
||||
traditional_chinese = [".cht", ".tc", ".zh-tw", ".zht", ".big5", ".traditional"]
|
||||
if str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(traditional_chinese)) or (str(subtitle_path).lower())[:-7] in traditional_chinese_fuzzy:
|
||||
traditional_chinese_fuzzy = [u"繁", u"雙語"]
|
||||
traditional_chinese = [".cht", ".tc", ".zh-tw", ".zht",".zh-hant",".zhhant",".zh_hant",".hant", ".big5", ".traditional"]
|
||||
if str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(traditional_chinese)) or (str(subtitle_path).lower())[:-5] in traditional_chinese_fuzzy:
|
||||
detected_language == 'zt'
|
||||
except UnicodeDecodeError:
|
||||
detector = Detector()
|
||||
|
|
Loading…
Reference in New Issue