Skip to content

Commit cda0362

Browse files
committed
add rudeSubN2L
1 parent 230cf1f commit cda0362

File tree

1 file changed

+67
-105
lines changed

1 file changed

+67
-105
lines changed

ASFMKV_dev.py

Lines changed: 67 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
# 不区分大小写
4545
subName2Lang = '.sc = chi; .tc = chi; .chs = chi; .cht = chi; .jap = jpn; .简体中文 = chi; .繁體中文 = chi; .繁体中文 = chi; .zh-hans = chi; .zh-hant = chi'
4646
# *************************************************************************
47+
# rudeSubN2L 暴力执行subName2Lang,只要字幕标题中含有对应的字符即套用而非完整匹配
48+
# True 启用,只要标题中含有对应项就询问
49+
# False 禁用,字幕标题必须与subName2Lang项目完全匹配
50+
rudeSubN2L = False
51+
# *************************************************************************
4752
# mkvout 媒体文件输出目录(封装)
4853
# 在最前方用"?"标记来表示这是一个子目录
4954
# 注意: 在Python中需要在左侧引号前加 r 来保留 Windows 路径中的反斜杠,路径末尾不需要反斜杠
@@ -3214,45 +3219,24 @@ def writeEmbeddedFonts(filePath: str, assInfo: dict):
32143219
fontlist = []
32153220
del font_info2
32163221
elif work == 3:
3217-
if resultw:
3218-
resultw = False
3219-
else:
3220-
resultw = True
3222+
resultw = not resultw
32213223
elif work == 4:
3222-
if copyfont:
3223-
copyfont = False
3224-
else:
3225-
copyfont = True
3224+
copyfont = not copyfont
32263225
elif work == 5:
3227-
if s_subdir:
3228-
s_subdir = False
3229-
else:
3230-
s_subdir = True
3226+
s_subdir = not s_subdir
32313227
elif work == 6:
32323228
if not o_fontload:
3233-
if fontload:
3234-
fontload = False
3235-
else:
3236-
fontload = True
3229+
fontload = not fontload
32373230
else:
32383231
cls()
32393232
print('在禁用系统字体源的情况下,fontload必须为True')
32403233
os.system('pause')
32413234
elif work == 7:
3242-
if exact_lost:
3243-
exact_lost = False
3244-
else:
3245-
exact_lost = True
3235+
exact_lost = not exact_lost
32463236
elif work == 8:
3247-
if char_lost:
3248-
char_lost = False
3249-
else:
3250-
char_lost = True
3237+
char_lost = not char_lost
32513238
elif work == 9:
3252-
if embeddedFontExtract:
3253-
embeddedFontExtract = False
3254-
else:
3255-
embeddedFontExtract = True
3239+
embeddedFontExtract = not embeddedFontExtract
32563240
else:
32573241
leave = False
32583242
if work < 3: os.system('pause')
@@ -3436,9 +3420,16 @@ def showFocusSub(i: str):
34363420
showFocusSub(i)
34373421
print('')
34383422

3439-
if not autoGet and i in subName2Lang:
3440-
lang = subName2Lang[i]
3441-
autoGet = True
3423+
if not autoGet:
3424+
if i in subName2Lang:
3425+
lang = subName2Lang[i]
3426+
autoGet = True
3427+
elif rudeSubN2L:
3428+
for k in subName2Lang.keys():
3429+
if k.lstrip('.') in i:
3430+
lang = subName2Lang[i]
3431+
autoGet = True
3432+
break
34423433
else:
34433434
if no_mkvm and len(translationLang) > 0:
34443435
searchLang = '仅本地语言搜索'
@@ -3580,7 +3571,7 @@ def showFocusSub(i: str):
35803571
def cFontSubset(font_info):
35813572
global extlist, v_subdir, s_subdir, rmAssIn, rmAttach, fontload, \
35823573
mkvout, assout, fontout, matchStrict, no_mkvm, notfont, warningStop, errorStop, ignoreLost, char_compatible, \
3583-
insteadFF, noRequestFont
3574+
insteadFF, noRequestFont, rudeSubN2L
35843575
leave = True
35853576
while leave:
35863577
cls()
@@ -3593,31 +3584,31 @@ def cFontSubset(font_info):
35933584
showFF = '子集化并封装(FFmpeg)'
35943585
elif not insteadFF:
35953586
showFF = '子集化并封装(mkvmerge)'
3596-
print('''ASFMKV & ASFMKV-FontSubset
3587+
print(f'''ASFMKV & ASFMKV-FontSubset
35973588
选择功能:
35983589
[A] 子集化字体
35993590
[B] 子集化并封装(ASS/SSA内嵌)
3600-
[C] {13}
3591+
[C] {showFF}
36013592
[L] 回到上级菜单
36023593
切换开关:
36033594
[1] 检视媒体扩展名列表 及 语言编码列表
3604-
[2] 搜索子目录(视频): \033[1;33m{0}\033[0m
3605-
[3] 搜索子目录(字幕): \033[1;33m{1}\033[0m
3606-
[4] (封装)移除内挂字幕: \033[1;33m{2}\033[0m
3607-
[5] (封装)移除原有附件: \033[1;33m{3}\033[0m
3608-
[6] (封装)不封装字体: \033[1;33m{8}\033[0m
3609-
[7] 严格字幕匹配: \033[1;33m{7}\033[0m
3610-
[8] 媒体文件输出文件夹: \033[1;33m{4}\033[0m
3611-
[9] 字幕文件输出文件夹: \033[1;33m{5}\033[0m
3612-
[0] 字体文件输出文件夹: \033[1;33m{6}\033[0m
3613-
[U] 广兼容性子集化: \033[1;33m{9}\033[0m
3614-
[W] 忽略字体所缺字: \033[1;33m{12}\033[0m
3615-
[X] 子集化失败中断: \033[1;33m{10}\033[0m
3616-
[Y] 忽略字幕缺少字体:\033[1;33m{14}\033[0m
3617-
[Z] 使用工作目录字体: \033[1;33m{11}\033[0m
3618-
'''.format(v_subdir, s_subdir, rmAssIn, rmAttach, mkvout, assout,
3619-
fontout, matchStrict, notfont, char_compatible, errorStop, fontload, ignoreLost, showFF, noRequestFont))
3620-
work = os.system('choice /M 请输入 /C AC1234567890UWXYZLB{}'.format(showFFKey))
3595+
[2] 搜索子目录(视频): \033[1;33m{v_subdir}\033[0m
3596+
[3] 搜索子目录(字幕): \033[1;33m{s_subdir}\033[0m
3597+
[4] (封装)移除内挂字幕: \033[1;33m{rmAssIn}\033[0m
3598+
[5] (封装)移除原有附件: \033[1;33m{rmAttach}\033[0m
3599+
[6] (封装)不封装字体: \033[1;33m{notfont}\033[0m
3600+
[7] 严格字幕匹配: \033[1;33m{matchStrict}\033[0m
3601+
[8] 媒体文件输出文件夹: \033[1;33m{mkvout}\033[0m
3602+
[9] 字幕文件输出文件夹: \033[1;33m{assout}\033[0m
3603+
[0] 字体文件输出文件夹: \033[1;33m{fontout}\033[0m
3604+
[U] 广兼容性子集化: \033[1;33m{char_compatible}\033[0m
3605+
[V] 忽略字体所缺字: \033[1;33m{ignoreLost}\033[0m
3606+
[W] 子集化失败中断: \033[1;33m{errorStop}\033[0m
3607+
[X] 忽略字幕缺少字体:\033[1;33m{noRequestFont}\033[0m
3608+
[Y] 使用工作目录字体: \033[1;33m{fontload}\033[0m
3609+
[Z] 暴力字幕标题<>语言匹配: \033[1;33m{rudeSubN2L}\033[0m
3610+
''')
3611+
work = os.system(f'choice /M 请输入 /C AC1234567890UVWXYZLB{showFFKey}')
36213612

36223613
if work == 2 and (no_mkvm and not insteadFF):
36233614

@@ -3641,40 +3632,21 @@ def cFontSubset(font_info):
36413632
print('没有检测到mkvmerge,无法输出语言编码列表')
36423633
elif work == 4:
36433634
# [2] 搜索子目录(视频)
3644-
if v_subdir:
3645-
v_subdir = False
3646-
else:
3647-
v_subdir = True
3635+
v_subdir = not v_subdir
36483636
elif work == 5:
36493637
# [3] 搜索子目录(字幕)
3650-
if s_subdir:
3651-
s_subdir = False
3652-
else:
3653-
s_subdir = True
3638+
s_subdir = not s_subdir
36543639
elif work == 6:
36553640
# [4] (封装)移除内挂字幕
3656-
if rmAssIn:
3657-
rmAssIn = False
3658-
else:
3659-
rmAssIn = True
3641+
rmAssIn = not rmAssIn
36603642
elif work == 7:
36613643
# [5] (封装)移除原有附件
3662-
if rmAttach:
3663-
rmAttach = False
3664-
else:
3665-
rmAttach = True
3644+
rmAttach = not rmAttach
36663645
elif work == 8:
36673646
# [6] (封装)不封装字体
3668-
if notfont:
3669-
notfont = False
3670-
else:
3671-
notfont = True
3672-
elif work == 9:
3647+
notfont = not notfont
36733648
# [7] 严格字幕匹配
3674-
if matchStrict:
3675-
matchStrict = False
3676-
else:
3677-
matchStrict = True
3649+
matchStrict = not matchStrict
36783650
elif work in [10, 11, 12]:
36793651
# [8/9/10] 输出文件夹
36803652
cls()
@@ -3688,30 +3660,18 @@ def cFontSubset(font_info):
36883660
fontout = checkOutPath(input(), fontout)
36893661
elif work == 13:
36903662
# [U] 广兼容性子集化
3691-
if char_compatible:
3692-
char_compatible = False
3693-
else:
3694-
char_compatible = True
3663+
char_compatible = not char_compatible
36953664
elif work == 14:
3696-
# [W] 忽略字体所缺字
3697-
if ignoreLost:
3698-
ignoreLost = False
3699-
else:
3700-
ignoreLost = True
3665+
# [V] 忽略字体所缺字
3666+
ignoreLost = not ignoreLost
37013667
elif work == 15:
3702-
# [X] 子集化失败中断
3703-
if errorStop:
3704-
errorStop = False
3705-
else:
3706-
errorStop = True
3668+
# [W] 子集化失败中断
3669+
errorStop = not errorStop
37073670
elif work == 16:
3708-
# [Y] 忽略字幕缺少字体
3709-
if noRequestFont:
3710-
noRequestFont = False
3711-
else:
3712-
noRequestFont = True
3671+
# [X] 忽略字幕缺少字体
3672+
noRequestFont = not noRequestFont
37133673
elif work == 17:
3714-
# [Z] 使用工作目录字体
3674+
# [Y] 使用工作目录字体
37153675
if not o_fontload:
37163676
if fontload:
37173677
fontload = False
@@ -3721,8 +3681,10 @@ def cFontSubset(font_info):
37213681
cls()
37223682
print('在禁用系统字体源的情况下,fontload必须为True')
37233683
os.system('pause')
3684+
elif work == 18:
3685+
rudeSubN2L = not rudeSubN2L
37243686

3725-
elif work in [1, 2, 19, 20]:
3687+
elif work in [1, 2, 20, 21]:
37263688
cls()
37273689
if work == 1:
37283690
print('''子集化字体
@@ -3767,7 +3729,7 @@ def cFontSubset(font_info):
37673729
testext = path.splitext(cpath)[1][1:].lower()
37683730
if testext in extlist:
37693731
directout = False
3770-
elif testext in ['ass', 'ssa'] and work in [1, 19]:
3732+
elif testext in ['ass', 'ssa'] and work in [1, 20]:
37713733
directout = False
37723734
subonly = True
37733735
else:
@@ -3786,11 +3748,11 @@ def cFontSubset(font_info):
37863748
subonlyp = [(path.splitext(path.basename(cpath))[0], cpath)]
37873749
cpath = path.dirname(cpath)
37883750
else:
3789-
if work != 19: medias = getFileList(cpath, extlist, v_subdir)
3751+
if work != 20: medias = getFileList(cpath, extlist, v_subdir)
37903752
else: medias = []
37913753
if len(medias) == 0:
37923754
subonlyp = getFileList(cpath, ['ass', 'ssa'], s_subdir)
3793-
if work == 19:
3755+
if work == 20:
37943756
subonly = True
37953757
elif len(subonlyp) > 0:
37963758
cls()
@@ -3827,7 +3789,7 @@ def cFontSubset(font_info):
38273789
mkvout_cache = mkvout
38283790

38293791
domux = False
3830-
if work in [2, 20]: domux = True
3792+
if work in [2, 21]: domux = True
38313793

38323794
if len(medias) > 0:
38333795
media_ass = getSubtitles(cpath, medias)
@@ -3843,9 +3805,9 @@ def cFontSubset(font_info):
38433805
sublangs = getSubsLangsV2(media_ass)
38443806
forceSubTrack = getForceSub(media_ass)
38453807
# print(media_ass)
3846-
if work == 20 or (work == 2 and no_mkvm):
3808+
if work == 21 or (work == 2 and no_mkvm):
38473809
muxer = 1
3848-
elif work == 19:
3810+
elif work == 20:
38493811
muxer = 2
38503812
domux = False
38513813
for k in media_ass.keys():
@@ -3874,7 +3836,7 @@ def cFontSubset(font_info):
38743836
else:
38753837
font_info2 = font_info
38763838
muxer = 0
3877-
if work == 19:
3839+
if work == 20:
38783840
muxer = 2
38793841
for subp in subonlyp:
38803842
newasspaths, newfont_name, mkvr = main(font_info2, [subp[1]],
@@ -3889,7 +3851,7 @@ def cFontSubset(font_info):
38893851

38903852
else:
38913853
leave = False
3892-
if work < 4 or work >= 19:
3854+
if work < 4 or work >= 20:
38933855
os.system('pause')
38943856

38953857

0 commit comments

Comments
 (0)