44
44
# 不区分大小写
45
45
subName2Lang = '.sc = chi; .tc = chi; .chs = chi; .cht = chi; .jap = jpn; .简体中文 = chi; .繁體中文 = chi; .繁体中文 = chi; .zh-hans = chi; .zh-hant = chi'
46
46
# *************************************************************************
47
+ # rudeSubN2L 暴力执行subName2Lang,只要字幕标题中含有对应的字符即套用而非完整匹配
48
+ # True 启用,只要标题中含有对应项就询问
49
+ # False 禁用,字幕标题必须与subName2Lang项目完全匹配
50
+ rudeSubN2L = False
51
+ # *************************************************************************
47
52
# mkvout 媒体文件输出目录(封装)
48
53
# 在最前方用"?"标记来表示这是一个子目录
49
54
# 注意: 在Python中需要在左侧引号前加 r 来保留 Windows 路径中的反斜杠,路径末尾不需要反斜杠
@@ -3214,45 +3219,24 @@ def writeEmbeddedFonts(filePath: str, assInfo: dict):
3214
3219
fontlist = []
3215
3220
del font_info2
3216
3221
elif work == 3 :
3217
- if resultw :
3218
- resultw = False
3219
- else :
3220
- resultw = True
3222
+ resultw = not resultw
3221
3223
elif work == 4 :
3222
- if copyfont :
3223
- copyfont = False
3224
- else :
3225
- copyfont = True
3224
+ copyfont = not copyfont
3226
3225
elif work == 5 :
3227
- if s_subdir :
3228
- s_subdir = False
3229
- else :
3230
- s_subdir = True
3226
+ s_subdir = not s_subdir
3231
3227
elif work == 6 :
3232
3228
if not o_fontload :
3233
- if fontload :
3234
- fontload = False
3235
- else :
3236
- fontload = True
3229
+ fontload = not fontload
3237
3230
else :
3238
3231
cls ()
3239
3232
print ('在禁用系统字体源的情况下,fontload必须为True' )
3240
3233
os .system ('pause' )
3241
3234
elif work == 7 :
3242
- if exact_lost :
3243
- exact_lost = False
3244
- else :
3245
- exact_lost = True
3235
+ exact_lost = not exact_lost
3246
3236
elif work == 8 :
3247
- if char_lost :
3248
- char_lost = False
3249
- else :
3250
- char_lost = True
3237
+ char_lost = not char_lost
3251
3238
elif work == 9 :
3252
- if embeddedFontExtract :
3253
- embeddedFontExtract = False
3254
- else :
3255
- embeddedFontExtract = True
3239
+ embeddedFontExtract = not embeddedFontExtract
3256
3240
else :
3257
3241
leave = False
3258
3242
if work < 3 : os .system ('pause' )
@@ -3436,9 +3420,16 @@ def showFocusSub(i: str):
3436
3420
showFocusSub (i )
3437
3421
print ('' )
3438
3422
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
3442
3433
else :
3443
3434
if no_mkvm and len (translationLang ) > 0 :
3444
3435
searchLang = '仅本地语言搜索'
@@ -3580,7 +3571,7 @@ def showFocusSub(i: str):
3580
3571
def cFontSubset (font_info ):
3581
3572
global extlist , v_subdir , s_subdir , rmAssIn , rmAttach , fontload , \
3582
3573
mkvout , assout , fontout , matchStrict , no_mkvm , notfont , warningStop , errorStop , ignoreLost , char_compatible , \
3583
- insteadFF , noRequestFont
3574
+ insteadFF , noRequestFont , rudeSubN2L
3584
3575
leave = True
3585
3576
while leave :
3586
3577
cls ()
@@ -3593,31 +3584,31 @@ def cFontSubset(font_info):
3593
3584
showFF = '子集化并封装(FFmpeg)'
3594
3585
elif not insteadFF :
3595
3586
showFF = '子集化并封装(mkvmerge)'
3596
- print ('''ASFMKV & ASFMKV-FontSubset
3587
+ print (f '''ASFMKV & ASFMKV-FontSubset
3597
3588
选择功能:
3598
3589
[A] 子集化字体
3599
3590
[B] 子集化并封装(ASS/SSA内嵌)
3600
- [C] {13 }
3591
+ [C] { showFF }
3601
3592
[L] 回到上级菜单
3602
3593
切换开关:
3603
3594
[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 } ' )
3621
3612
3622
3613
if work == 2 and (no_mkvm and not insteadFF ):
3623
3614
@@ -3641,40 +3632,21 @@ def cFontSubset(font_info):
3641
3632
print ('没有检测到mkvmerge,无法输出语言编码列表' )
3642
3633
elif work == 4 :
3643
3634
# [2] 搜索子目录(视频)
3644
- if v_subdir :
3645
- v_subdir = False
3646
- else :
3647
- v_subdir = True
3635
+ v_subdir = not v_subdir
3648
3636
elif work == 5 :
3649
3637
# [3] 搜索子目录(字幕)
3650
- if s_subdir :
3651
- s_subdir = False
3652
- else :
3653
- s_subdir = True
3638
+ s_subdir = not s_subdir
3654
3639
elif work == 6 :
3655
3640
# [4] (封装)移除内挂字幕
3656
- if rmAssIn :
3657
- rmAssIn = False
3658
- else :
3659
- rmAssIn = True
3641
+ rmAssIn = not rmAssIn
3660
3642
elif work == 7 :
3661
3643
# [5] (封装)移除原有附件
3662
- if rmAttach :
3663
- rmAttach = False
3664
- else :
3665
- rmAttach = True
3644
+ rmAttach = not rmAttach
3666
3645
elif work == 8 :
3667
3646
# [6] (封装)不封装字体
3668
- if notfont :
3669
- notfont = False
3670
- else :
3671
- notfont = True
3672
- elif work == 9 :
3647
+ notfont = not notfont
3673
3648
# [7] 严格字幕匹配
3674
- if matchStrict :
3675
- matchStrict = False
3676
- else :
3677
- matchStrict = True
3649
+ matchStrict = not matchStrict
3678
3650
elif work in [10 , 11 , 12 ]:
3679
3651
# [8/9/10] 输出文件夹
3680
3652
cls ()
@@ -3688,30 +3660,18 @@ def cFontSubset(font_info):
3688
3660
fontout = checkOutPath (input (), fontout )
3689
3661
elif work == 13 :
3690
3662
# [U] 广兼容性子集化
3691
- if char_compatible :
3692
- char_compatible = False
3693
- else :
3694
- char_compatible = True
3663
+ char_compatible = not char_compatible
3695
3664
elif work == 14 :
3696
- # [W] 忽略字体所缺字
3697
- if ignoreLost :
3698
- ignoreLost = False
3699
- else :
3700
- ignoreLost = True
3665
+ # [V] 忽略字体所缺字
3666
+ ignoreLost = not ignoreLost
3701
3667
elif work == 15 :
3702
- # [X] 子集化失败中断
3703
- if errorStop :
3704
- errorStop = False
3705
- else :
3706
- errorStop = True
3668
+ # [W] 子集化失败中断
3669
+ errorStop = not errorStop
3707
3670
elif work == 16 :
3708
- # [Y] 忽略字幕缺少字体
3709
- if noRequestFont :
3710
- noRequestFont = False
3711
- else :
3712
- noRequestFont = True
3671
+ # [X] 忽略字幕缺少字体
3672
+ noRequestFont = not noRequestFont
3713
3673
elif work == 17 :
3714
- # [Z ] 使用工作目录字体
3674
+ # [Y ] 使用工作目录字体
3715
3675
if not o_fontload :
3716
3676
if fontload :
3717
3677
fontload = False
@@ -3721,8 +3681,10 @@ def cFontSubset(font_info):
3721
3681
cls ()
3722
3682
print ('在禁用系统字体源的情况下,fontload必须为True' )
3723
3683
os .system ('pause' )
3684
+ elif work == 18 :
3685
+ rudeSubN2L = not rudeSubN2L
3724
3686
3725
- elif work in [1 , 2 , 19 , 20 ]:
3687
+ elif work in [1 , 2 , 20 , 21 ]:
3726
3688
cls ()
3727
3689
if work == 1 :
3728
3690
print ('''子集化字体
@@ -3767,7 +3729,7 @@ def cFontSubset(font_info):
3767
3729
testext = path .splitext (cpath )[1 ][1 :].lower ()
3768
3730
if testext in extlist :
3769
3731
directout = False
3770
- elif testext in ['ass' , 'ssa' ] and work in [1 , 19 ]:
3732
+ elif testext in ['ass' , 'ssa' ] and work in [1 , 20 ]:
3771
3733
directout = False
3772
3734
subonly = True
3773
3735
else :
@@ -3786,11 +3748,11 @@ def cFontSubset(font_info):
3786
3748
subonlyp = [(path .splitext (path .basename (cpath ))[0 ], cpath )]
3787
3749
cpath = path .dirname (cpath )
3788
3750
else :
3789
- if work != 19 : medias = getFileList (cpath , extlist , v_subdir )
3751
+ if work != 20 : medias = getFileList (cpath , extlist , v_subdir )
3790
3752
else : medias = []
3791
3753
if len (medias ) == 0 :
3792
3754
subonlyp = getFileList (cpath , ['ass' , 'ssa' ], s_subdir )
3793
- if work == 19 :
3755
+ if work == 20 :
3794
3756
subonly = True
3795
3757
elif len (subonlyp ) > 0 :
3796
3758
cls ()
@@ -3827,7 +3789,7 @@ def cFontSubset(font_info):
3827
3789
mkvout_cache = mkvout
3828
3790
3829
3791
domux = False
3830
- if work in [2 , 20 ]: domux = True
3792
+ if work in [2 , 21 ]: domux = True
3831
3793
3832
3794
if len (medias ) > 0 :
3833
3795
media_ass = getSubtitles (cpath , medias )
@@ -3843,9 +3805,9 @@ def cFontSubset(font_info):
3843
3805
sublangs = getSubsLangsV2 (media_ass )
3844
3806
forceSubTrack = getForceSub (media_ass )
3845
3807
# print(media_ass)
3846
- if work == 20 or (work == 2 and no_mkvm ):
3808
+ if work == 21 or (work == 2 and no_mkvm ):
3847
3809
muxer = 1
3848
- elif work == 19 :
3810
+ elif work == 20 :
3849
3811
muxer = 2
3850
3812
domux = False
3851
3813
for k in media_ass .keys ():
@@ -3874,7 +3836,7 @@ def cFontSubset(font_info):
3874
3836
else :
3875
3837
font_info2 = font_info
3876
3838
muxer = 0
3877
- if work == 19 :
3839
+ if work == 20 :
3878
3840
muxer = 2
3879
3841
for subp in subonlyp :
3880
3842
newasspaths , newfont_name , mkvr = main (font_info2 , [subp [1 ]],
@@ -3889,7 +3851,7 @@ def cFontSubset(font_info):
3889
3851
3890
3852
else :
3891
3853
leave = False
3892
- if work < 4 or work >= 19 :
3854
+ if work < 4 or work >= 20 :
3893
3855
os .system ('pause' )
3894
3856
3895
3857
0 commit comments