77from .mkvtoolnix .mkv_utils import MKVUtils
88
99
10- def __parse_input_file (ass_input : list [Path ]) -> list [Path ]:
10+ def __parse_input_file (ass_input : Optional [list [Path ]]) -> list [Path ]:
11+ if ass_input is None :
12+ return []
1113
1214 ass_files_path = []
1315 for input in ass_input :
@@ -33,6 +35,7 @@ def parse_arguments() -> tuple[
3335 Path ,
3436 Union [Path , None ],
3537 bool ,
38+ bool ,
3639 Iterable [Path ],
3740 Iterable [Path ],
3841 bool ,
@@ -56,7 +59,6 @@ def parse_arguments() -> tuple[
5659 "-i" ,
5760 nargs = "+" ,
5861 type = Path ,
59- required = True ,
6062 help = """
6163 Subtitles file. Must be an ASS file/directory. You can specify more than one .ass file/path.
6264 """ ,
@@ -68,6 +70,14 @@ def parse_arguments() -> tuple[
6870 Video where the fonts will be merge. Must be a Matroska file.
6971 """ ,
7072 )
73+ parser .add_argument (
74+ "--use-ass-in-mkv" ,
75+ "-ass-mkv" ,
76+ action = "store_true" ,
77+ help = """
78+ If specified, it will use the .ass file muxed to the mkv and collect those fonts and mux them to the mkv. If not specified, it will do nothing.
79+ """ ,
80+ )
7181 parser .add_argument (
7282 "--output" ,
7383 "-o" ,
@@ -150,12 +160,9 @@ def parse_arguments() -> tuple[
150160
151161 # Parse args
152162 ass_files_path = __parse_input_file (args .input )
153-
154- if len (ass_files_path ) == 0 :
155- raise RuntimeError ("The specified file(s)/folder(s) doesn't exist or the folder(s) doesn't contains any .ass file." )
156-
157163 output_directory = args .output
158164 mkv_path = args .mkv
165+ use_ass_in_mkv = args .use_ass_in_mkv
159166 delete_fonts = args .delete_fonts
160167 additional_fonts = args .additional_fonts
161168 additional_fonts_recursive = args .additional_fonts_recursive
@@ -164,6 +171,12 @@ def parse_arguments() -> tuple[
164171 convert_variable_to_collection = args .dont_convert_variable_to_collection
165172 logging_file_path = args .logging
166173
174+ if len (ass_files_path ) == 0 and not use_ass_in_mkv :
175+ raise RuntimeError ("The specified file(s)/folder(s) doesn't exist or the folder(s) doesn't contains any .ass file." )
176+
177+ if use_ass_in_mkv and mkv_path is None :
178+ raise RuntimeError ("You need to add the flag `-mkv` to use the flag `--use-ass-in-mkv`." )
179+
167180 if args .mkvtoolnix :
168181 if not mkv_path :
169182 raise RuntimeError ("-mkvtoolnix requires --mkv option." )
@@ -173,6 +186,7 @@ def parse_arguments() -> tuple[
173186 ass_files_path ,
174187 output_directory ,
175188 mkv_path ,
189+ use_ass_in_mkv ,
176190 delete_fonts ,
177191 additional_fonts ,
178192 additional_fonts_recursive ,
0 commit comments