This repository was archived by the owner on Apr 18, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 8989
9090# Validate "output" argument
9191if mode == "audio" or mode == "subs" :
92- output = args ['output' ] or ""
92+ output = args ['output' ]
93+ if output is None :
94+ output = ""
9395 if output != "" :
9496 if not os .path .isdir (output ):
9597 print ("Output directory {0} does not exist" .format (output ))
99101 output = output + "/"
100102elif mode == "mux" or mode == "shader" :
101103 output = args ['output' ] or "out.mkv"
104+ elif mode == "split" :
105+ output = args ['output' ]
102106
103107if mode == "audio" :
104108 extract_audio (fn , output )
113117elif mode == "split" :
114118 length = get_video_length (fn )
115119 split_by_seconds (filename = fn , split_length = args ['split_length' ],
116- video_length = length , split_dir = args [ ' output' ] )
120+ video_length = length , split_dir = output )
117121else :
118122 print ("Unknown option: {0}" .format (mode ))
Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ def genExt(codec):
1212 return "ass"
1313 elif "SRT" in codec or "SubRip" in codec :
1414 return "srt"
15+ elif "VobSub" in codec :
16+ return "idx"
17+ else :
18+ return None
1519
1620
1721def extract_subs (fn : str , out_dir : str ):
@@ -34,9 +38,13 @@ def extract_subs(fn: str, out_dir: str):
3438 for track in tracks :
3539 if track .track_type == 'subtitles' :
3640 ext = genExt (track ._track_codec )
41+ if ext is None :
42+ print ("WARNING: Skipping unknown subtitle with id={0}, codec={1}" .format (str (track ._track_id ), str (track ._track_codec or "Unknown" )))
43+ continue
3744 lang = track ._language
3845 id = str (track ._track_id )
3946
4047 subprocess .call (['mkvextract' , 'tracks' , fn ,
41- id + ':' + out_dir + lang + '_' + id + '.' + ext ])
48+ id + ':' + str (out_dir ) + str (
49+ lang ) + '_' + id + '.' + ext ])
4250 print ("Subtitle extraction end time: " + current_date ())
Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ def mux(fn: str, out: str):
8181 addSubs (mkv , "sup" )
8282 addSubs (mkv , "srt" )
8383 addSubs (mkv , "ass" )
84+ addSubs (mkv , "idx" )
8485
8586 print ("Mux start time: " + current_date ())
8687 mkv .mux (out )
@@ -101,4 +102,6 @@ def mux(fn: str, out: str):
101102 delete_by_extension ("sup" )
102103 delete_by_extension ("srt" )
103104 delete_by_extension ("ass" )
105+ delete_by_extension ("idx" )
106+ delete_by_extension ("sub" )
104107 print ("Cleaned!" )
Original file line number Diff line number Diff line change 22from datetime import datetime
33from shutil import which
44
5- __current_version__ = '1.0.0 '
5+ __current_version__ = '1.0.1 '
66
77
88def credz ():
You can’t perform that action at this time.
0 commit comments