easyrip 4.11.3__py3-none-any.whl → 4.13.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -862,3 +862,163 @@ class Ass:
862
862
  ),
863
863
  )
864
864
  return "\n\n".join(filter(bool, generator)) + "\n"
865
+
866
+ def get_font_info(
867
+ self,
868
+ *,
869
+ use_libass_spec: bool = True,
870
+ ):
871
+ """获取 ASS 中需要的字体,以及对应的字符"""
872
+ from .font import Font_type
873
+ from .subset import _bold_italic_to_font_type
874
+
875
+ DEFAULT_STYLE_NAME = "Default"
876
+
877
+ font_sign__str: dict[tuple[str, Font_type], str] = {}
878
+
879
+ # Styles
880
+ style__font_sign: dict[str, tuple[str, Font_type]] = {}
881
+ for style in self.styles.data:
882
+ _is_vertical: bool = style.Fontname[0] == "@"
883
+ _font_name: str = style.Fontname[1:] if _is_vertical else style.Fontname
884
+ # 获取
885
+ style__font_sign[style.Name] = (
886
+ _font_name,
887
+ _bold_italic_to_font_type(style.Bold, style.Italic),
888
+ )
889
+
890
+ # Events
891
+ for event in self.events.data:
892
+ if event.type != Event_type.Dialogue:
893
+ continue
894
+
895
+ default_font_sign: tuple[str, Font_type]
896
+
897
+ # 获取每行的默认字体
898
+ if event.Style not in style__font_sign:
899
+ if DEFAULT_STYLE_NAME in style__font_sign:
900
+ log.warning(
901
+ "The style '{}' not in Styles. Defaulting to the style '{}'",
902
+ event.Style,
903
+ DEFAULT_STYLE_NAME,
904
+ )
905
+ default_font_sign = style__font_sign[DEFAULT_STYLE_NAME]
906
+ else:
907
+ log.warning(
908
+ "The style '{}' and the style 'Default' not in Styles. Defaulting to no font",
909
+ event.Style,
910
+ )
911
+ default_font_sign = ("", Font_type.Regular)
912
+ else:
913
+ default_font_sign = style__font_sign[event.Style]
914
+
915
+ # 解析 Text
916
+ current_font_sign: tuple[str, Font_type] = default_font_sign
917
+ for is_tag, text in Event_data.parse_text(event.Text, use_libass_spec):
918
+ if is_tag:
919
+ tag_fn: str | None = None
920
+ tag_bold: str | None = None
921
+ tag_italic: str | None = None
922
+
923
+ for tag, value in re.findall(
924
+ r"\\\s*(fn|b(?![a-zA-Z])|i(?![a-zA-Z])|r)([^\\}]*)", text
925
+ ):
926
+ assert isinstance(tag, str) and isinstance(value, str)
927
+
928
+ proc_value = value.strip()
929
+ if proc_value.startswith("("):
930
+ proc_value = proc_value[1:]
931
+ if (_index := proc_value.find(")")) != -1:
932
+ proc_value = proc_value[:_index]
933
+ proc_value = proc_value.strip()
934
+
935
+ match tag:
936
+ case "fn":
937
+ tag_fn = proc_value
938
+ case "b":
939
+ tag_bold = proc_value
940
+ case "i":
941
+ tag_italic = proc_value
942
+ case "r":
943
+ r_value = proc_value if "(" in value else value.rstrip()
944
+ if r_value in style__font_sign:
945
+ current_font_sign = style__font_sign[r_value]
946
+ else:
947
+ # 空为还原样式, 非样式表内样式名效果同空, 但发出不规范警告
948
+ current_font_sign = default_font_sign
949
+ if r_value != "":
950
+ log.warning(
951
+ "The \\r style '{}' not in Styles", r_value
952
+ )
953
+
954
+ new_fontname: str = current_font_sign[0]
955
+ new_bold: bool
956
+ new_italic: bool
957
+ new_bold, new_italic = current_font_sign[1].value
958
+
959
+ if tag_fn is not None:
960
+ match tag_fn:
961
+ case "":
962
+ new_fontname = default_font_sign[0]
963
+ case _:
964
+ _is_vertical: bool = tag_fn.startswith("@")
965
+ new_fontname = tag_fn[1:] if _is_vertical else tag_fn
966
+
967
+ if tag_bold is not None:
968
+ match tag_bold:
969
+ case "":
970
+ new_bold = default_font_sign[1].value[0]
971
+ case "0":
972
+ new_bold = False
973
+ case "1":
974
+ new_bold = True
975
+ case _:
976
+ log.error(
977
+ "Illegal format: '{}' in line: {}",
978
+ f"\\b{tag_bold}",
979
+ event.Text,
980
+ )
981
+
982
+ if tag_italic is not None:
983
+ match tag_italic:
984
+ case "":
985
+ new_italic = default_font_sign[1].value[1]
986
+ case "0":
987
+ new_italic = False
988
+ case "1":
989
+ new_italic = True
990
+ case _:
991
+ log.error(
992
+ "Illegal format: '{}' in line: {}",
993
+ f"\\i{tag_italic}",
994
+ event.Text,
995
+ )
996
+
997
+ current_font_sign = (
998
+ new_fontname,
999
+ Font_type((new_bold, new_italic)),
1000
+ )
1001
+
1002
+ elif current_font_sign[0]: # 空字符串为不使用字体
1003
+ add_text = re.sub(r"\\[nN]", "", text).replace("\\h", "\u00a0")
1004
+
1005
+ if current_font_sign not in font_sign__str:
1006
+ font_sign__str[current_font_sign] = ""
1007
+
1008
+ font_sign__str[current_font_sign] += add_text
1009
+
1010
+ return {font_sign: set(s) for font_sign, s in font_sign__str.items()}
1011
+
1012
+ @classmethod
1013
+ def analysis_font_info(
1014
+ cls,
1015
+ ass: Self | Path | str,
1016
+ /,
1017
+ *,
1018
+ use_libass_spec: bool = True,
1019
+ ):
1020
+ if isinstance(ass, str):
1021
+ ass = Path(ass)
1022
+ if isinstance(ass, Path):
1023
+ ass = cls(ass)
1024
+ return ass.get_font_info(use_libass_spec=use_libass_spec)
@@ -33,7 +33,7 @@ def subset(
33
33
  *,
34
34
  font_in_sub: bool = False,
35
35
  use_win_font: bool = False,
36
- use_libass_spec: bool = False,
36
+ use_libass_spec: bool = True,
37
37
  drop_non_render: bool = True,
38
38
  drop_unkow_data: bool = True,
39
39
  strict: bool = False,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: easyrip
3
- Version: 4.11.3
3
+ Version: 4.13.0
4
4
  Author: op200
5
5
  License-Expression: AGPL-3.0-or-later
6
6
  Project-URL: Homepage, https://github.com/op200/EasyRip
@@ -0,0 +1,32 @@
1
+ easyrip/__init__.py,sha256=DULQoFEAEHYk7dS8Zxky56so7qDPqHm7jUc_Zop1eXw,616
2
+ easyrip/__main__.py,sha256=wvMAp5i5-Pjv5dkEtPyoTs12QFq48B4u8lujYkcpy9I,5065
3
+ easyrip/easyrip_command.py,sha256=AifME_dEPHzUAGJVFqwdIDE6RItOk2TO8QsKYV1kLYQ,29920
4
+ easyrip/easyrip_log.py,sha256=R-dM3CWUBFITtG7GSD1zy4X4MhZqxkoiBPjlIpI76cY,15573
5
+ easyrip/easyrip_main.py,sha256=LnMRaUC0qZm4cN5aSoUOVPZ6QvCqjRQZI9khzF5vf_s,46980
6
+ easyrip/easyrip_prompt.py,sha256=3or0Vt4s6L53MCJtQmSylrTADZIIjX5gvpSb-JRe2P4,4844
7
+ easyrip/global_val.py,sha256=ssyn2FzwuHU3Gh7KLhczmYJiiYjPocVBDxD485zjXDA,866
8
+ easyrip/utils.py,sha256=N1rMF1MyoC-YFBgy10_u29cFoowfhR-5Viea93O7wQ4,8750
9
+ easyrip/easyrip_config/config.py,sha256=KWXZMEYxdXYUGLQ-MR0A7nnOwR6QZdVrWBopfb2QZSA,9869
10
+ easyrip/easyrip_config/config_key.py,sha256=_jjdKOunskUoG7UUWOz3QZK-s4LF_x6hmM9MKttyS2Q,766
11
+ easyrip/easyrip_mlang/__init__.py,sha256=QqnL0kgV_trGPeLF5gawP1qAlj0GXUadLNhMSdKrRmk,1765
12
+ easyrip/easyrip_mlang/global_lang_val.py,sha256=pG9DxPl6vUOZoFHYQKCM-AM0TYWbd8L4S65CUQFPRh4,4998
13
+ easyrip/easyrip_mlang/lang_en.py,sha256=fTM9ejuPW6gEfSMbnMEW-LzlUfvj0YGfoUfmHZpRzms,121
14
+ easyrip/easyrip_mlang/lang_tag_val.py,sha256=Ec-U0XglpSYvmkHlcEBueSj8ocTLSTH3cacElAkmYVU,5184
15
+ easyrip/easyrip_mlang/lang_zh_Hans_CN.py,sha256=uW6esedtSYi6Y4R4MA4Xkd2y3f-2O5-ywJFgogk1O7Y,19031
16
+ easyrip/easyrip_mlang/translator.py,sha256=jlgZYSPHvwv1Pps3akKkSgVsGcLtV2psKaXyZH4QCbA,5870
17
+ easyrip/easyrip_web/__init__.py,sha256=tMyEeaSGeEJjND7MF0MBv9aDiDgaO3MOnppwxA70U2c,177
18
+ easyrip/easyrip_web/http_server.py,sha256=iyulCAFQrJlz86Lrr-Dm3fhOnNCf79Bp6fVHhr0ephY,8350
19
+ easyrip/easyrip_web/third_party_api.py,sha256=GhP6LmR1sVMeLLbnj82r-QYjoUdSnyaU9xp0LRnRLsw,4623
20
+ easyrip/ripper/media_info.py,sha256=mQq_vbQ7S9fWpb39HLkoZlAL-pqNfwxewv6X776Nf50,5078
21
+ easyrip/ripper/param.py,sha256=PfJzJz9LPCB5hAM9G4GjPxdn_EZRgAz-vxYzuHGQLp8,13084
22
+ easyrip/ripper/ripper.py,sha256=IE06YXABiD6qNBwMWaAuKOAxRL54YkuF_Mo1FeGwzjQ,52638
23
+ easyrip/ripper/sub_and_font/__init__.py,sha256=cBT7mxL7RRFaJXFPXuZ7RT-YK6FbnanaU5v6U9BOquw,153
24
+ easyrip/ripper/sub_and_font/ass.py,sha256=EhDkVY5JXU77euWPId7H2v85j444m8ZLm7wUid7TYd8,35307
25
+ easyrip/ripper/sub_and_font/font.py,sha256=X2dPcPzbwQf3fv_g_mxO-zY7puVAX9Nv-9QHn88q4oA,7745
26
+ easyrip/ripper/sub_and_font/subset.py,sha256=--rAA3VH1rm_jBOC3yMs3rOJpn3tPuvfXqkimbBtx3s,18653
27
+ easyrip-4.13.0.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
28
+ easyrip-4.13.0.dist-info/METADATA,sha256=juILJNQR8a6vMK8JXbVAJ3krrlL8n8Fz-4aH14Ag6pI,3507
29
+ easyrip-4.13.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
+ easyrip-4.13.0.dist-info/entry_points.txt,sha256=D6GBMMTzZ-apgX76KyZ6jxMmIFqGYwU9neeLLni_qKI,49
31
+ easyrip-4.13.0.dist-info/top_level.txt,sha256=kuEteBXm-Gf90jRQgH3-fTo-Z-Q6czSuUEqY158H4Ww,8
32
+ easyrip-4.13.0.dist-info/RECORD,,
@@ -1,31 +0,0 @@
1
- easyrip/__init__.py,sha256=PIvSPDgswsIkWL4dsCe87knnxKmtvcrWYzmqAwZix_M,765
2
- easyrip/__main__.py,sha256=bPVlHqJb3BG-qZOY4JlJdKj7MKeRb_3EfoMbfoNN-gU,4943
3
- easyrip/easyrip_command.py,sha256=U5fe33YqRghpuOY3xmjTxErZzjG_ykJMTWyU-GAJlsY,29315
4
- easyrip/easyrip_log.py,sha256=R-dM3CWUBFITtG7GSD1zy4X4MhZqxkoiBPjlIpI76cY,15573
5
- easyrip/easyrip_main.py,sha256=l_LMkM0EDpY0N9Ib5O1wSho6k9JG7JIh62ajU622XHE,44710
6
- easyrip/easyrip_prompt.py,sha256=3or0Vt4s6L53MCJtQmSylrTADZIIjX5gvpSb-JRe2P4,4844
7
- easyrip/global_val.py,sha256=YU7OKCDpWi3ez6Z28xy4txjWKEWSTFyPiO-doO5Jh48,866
8
- easyrip/utils.py,sha256=N1rMF1MyoC-YFBgy10_u29cFoowfhR-5Viea93O7wQ4,8750
9
- easyrip/easyrip_config/config.py,sha256=KWXZMEYxdXYUGLQ-MR0A7nnOwR6QZdVrWBopfb2QZSA,9869
10
- easyrip/easyrip_config/config_key.py,sha256=_jjdKOunskUoG7UUWOz3QZK-s4LF_x6hmM9MKttyS2Q,766
11
- easyrip/easyrip_mlang/__init__.py,sha256=QHZt4BYJFkJuaPkN89pt_zkM2grifJakyRZbeyfH8f4,1893
12
- easyrip/easyrip_mlang/global_lang_val.py,sha256=Un20KGMVVMQbOaV_7VaHg3E1dvK2Y7kI1cPzq_sFWKY,9984
13
- easyrip/easyrip_mlang/lang_en.py,sha256=heUSPeVtY1Nf9eDhrjPM28N3PLsu62op3llbXAfXvAs,140
14
- easyrip/easyrip_mlang/lang_zh_Hans_CN.py,sha256=N--5dJI9FS3bjZkVVI5htNBvOprvAtkIYjNoTTlvn-Y,18642
15
- easyrip/easyrip_mlang/translator.py,sha256=iTKIOXWmdZ-iOyjmVjMsxx5Q0Vud2y9sqZ_CrUZBG2Q,5944
16
- easyrip/easyrip_web/__init__.py,sha256=tMyEeaSGeEJjND7MF0MBv9aDiDgaO3MOnppwxA70U2c,177
17
- easyrip/easyrip_web/http_server.py,sha256=iyulCAFQrJlz86Lrr-Dm3fhOnNCf79Bp6fVHhr0ephY,8350
18
- easyrip/easyrip_web/third_party_api.py,sha256=GhP6LmR1sVMeLLbnj82r-QYjoUdSnyaU9xp0LRnRLsw,4623
19
- easyrip/ripper/media_info.py,sha256=mQq_vbQ7S9fWpb39HLkoZlAL-pqNfwxewv6X776Nf50,5078
20
- easyrip/ripper/param.py,sha256=PYUCfrXtGKaUxQCLWiDK99jih_JSRxtLsi5udzsZZUQ,11980
21
- easyrip/ripper/ripper.py,sha256=jjQKDepCAPDCnNEk3RQ-r7py-cFDBT5g7pdZMIR60WY,50515
22
- easyrip/ripper/sub_and_font/__init__.py,sha256=cBT7mxL7RRFaJXFPXuZ7RT-YK6FbnanaU5v6U9BOquw,153
23
- easyrip/ripper/sub_and_font/ass.py,sha256=hJhVN7CqehN9xW1W295gmkPnG-somqlxnwXzRidbA2M,28645
24
- easyrip/ripper/sub_and_font/font.py,sha256=X2dPcPzbwQf3fv_g_mxO-zY7puVAX9Nv-9QHn88q4oA,7745
25
- easyrip/ripper/sub_and_font/subset.py,sha256=qGH3H26nHnyGFfFwvktEIKncHpm086DqxYjVhNoVDdM,18654
26
- easyrip-4.11.3.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
27
- easyrip-4.11.3.dist-info/METADATA,sha256=7jXHv8WOOGUm90wHDqG650tJdjSfej0NMsAIqJACimo,3507
28
- easyrip-4.11.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
- easyrip-4.11.3.dist-info/entry_points.txt,sha256=D6GBMMTzZ-apgX76KyZ6jxMmIFqGYwU9neeLLni_qKI,49
30
- easyrip-4.11.3.dist-info/top_level.txt,sha256=kuEteBXm-Gf90jRQgH3-fTo-Z-Q6czSuUEqY158H4Ww,8
31
- easyrip-4.11.3.dist-info/RECORD,,