@@ -94,9 +94,9 @@ class DefaultOptions:
9494 PATH = "."
9595 KEEP = False
9696 REPEAT = 1000
97- DUR = None
97+ DURATION = None
9898 # Download defaults
99- CONNECT = 25
99+ CONNECTIONS = 25
100100 RETRIES = 5
101101 MAX_COUBS = None
102102 # Format defaults
@@ -113,11 +113,11 @@ class DefaultOptions:
113113 # Misc. defaults
114114 A_ONLY = False
115115 V_ONLY = False
116- OUT_FILE = None
117- ARCHIVE_PATH = None
116+ OUTPUT_LIST = None
117+ ARCHIVE = None
118118 # Output defaults
119119 MERGE_EXT = "mkv"
120- OUT_FORMAT = "%id%"
120+ NAME_TEMPLATE = "%id%"
121121 # Advanced defaults
122122 COUBS_PER_PAGE = 25
123123 TAG_SEP = "_"
@@ -161,8 +161,8 @@ def check_values(self):
161161 "PATH" : (lambda x : isinstance (x , str )),
162162 "KEEP" : (lambda x : isinstance (x , bool )),
163163 "REPEAT" : (lambda x : isinstance (x , int ) and x > 0 ),
164- "DUR " : (lambda x : isinstance (x , str ) or x is None ),
165- "CONNECT " : (lambda x : isinstance (x , int ) and x > 0 ),
164+ "DURATION " : (lambda x : isinstance (x , str ) or x is None ),
165+ "CONNECTIONS " : (lambda x : isinstance (x , int ) and x > 0 ),
166166 "RETRIES" : (lambda x : isinstance (x , int )),
167167 "MAX_COUBS" : (lambda x : isinstance (x , int ) and x > 0 or x is None ),
168168 "V_QUALITY" : (lambda x : x in [0 , - 1 ]),
@@ -175,10 +175,10 @@ def check_values(self):
175175 "PREVIEW" : (lambda x : isinstance (x , str ) or x is None ),
176176 "A_ONLY" : (lambda x : isinstance (x , bool )),
177177 "V_ONLY" : (lambda x : isinstance (x , bool )),
178- "OUT_FILE " : (lambda x : isinstance (x , str ) or x is None ),
179- "ARCHIVE_PATH " : (lambda x : isinstance (x , str ) or x is None ),
178+ "OUTPUT_LIST " : (lambda x : isinstance (x , str ) or x is None ),
179+ "ARCHIVE " : (lambda x : isinstance (x , str ) or x is None ),
180180 "MERGE_EXT" : (lambda x : x in ["mkv" , "mp4" , "asf" , "avi" , "flv" , "f4v" , "mov" ]),
181- "OUT_FORMAT " : (lambda x : isinstance (x , str ) or x is None ),
181+ "NAME_TEMPLATE " : (lambda x : isinstance (x , str ) or x is None ),
182182 "COUBS_PER_PAGE" : (lambda x : x in range (1 , 26 )),
183183 "TAG_SEP" : (lambda x : isinstance (x , str )),
184184 "WRITE_METHOD" : (lambda x : x in ["w" , "a" ]),
@@ -207,11 +207,11 @@ def guess_string_type(option, string):
207207 # Usually options which are supposed to ONLY take strings
208208 exceptions = [
209209 "PATH" ,
210- "DUR " ,
210+ "DURATION " ,
211211 "PREVIEW" ,
212- "OUT_FILE " ,
213- "ARCHIVE_PATH " ,
214- "OUT_FORMAT " ,
212+ "OUTPUT_LIST " ,
213+ "ARCHIVE " ,
214+ "NAME_TEMPLATE " ,
215215 "TAG_SEP" ,
216216 ]
217217
@@ -280,7 +280,7 @@ def format_help(self):
280280 -d, --duration TIME specify max. coub duration (FFmpeg syntax)
281281
282282 Download options:
283- --connections N max. number of connections (def: { self .get_default ("connect " )} )
283+ --connections N max. number of connections (def: { self .get_default ("connections " )} )
284284 --retries N number of retries when connection is lost (def: { self .get_default ("retries" )} )
285285 0 to disable, <0 to retry indefinitely
286286 --limit-num LIMIT limit max. number of downloaded coubs
@@ -316,7 +316,7 @@ def format_help(self):
316316 Output:
317317 --ext EXTENSION merge output with the given extension (def: { self .get_default ("merge_ext" )} )
318318 ignored if no merge is required
319- -o, --output FORMAT save output with the given template (def: { self .get_default ("out_format " )} )
319+ -o, --output FORMAT save output with the given template (def: { self .get_default ("name_template " )} )
320320
321321 Special strings:
322322 %id% - coub ID (identifier in the URL)
@@ -551,7 +551,7 @@ async def process(self, quantity=None):
551551 msg (f" { pages } out of { self .pages } pages" )
552552
553553 tout = aiohttp .ClientTimeout (total = None )
554- conn = aiohttp .TCPConnector (limit = opts .connect )
554+ conn = aiohttp .TCPConnector (limit = opts .connections )
555555 async with aiohttp .ClientSession (timeout = tout , connector = conn ) as session :
556556 tasks = [parse_page (req , session ) for req in requests ]
557557 links = await asyncio .gather (* tasks )
@@ -889,14 +889,14 @@ def check_existence(self):
889889 if self .erroneous ():
890890 return
891891
892- if opts .archive and self .id in opts .archive :
892+ if opts .archive_content and self .id in opts .archive_content :
893893 self .exists = True
894894 return
895895
896896 old_file = None
897897 # Existence of self.name indicates whether API request was already
898898 # made (i.e. if 1st or 2nd check)
899- if not opts .out_format :
899+ if not opts .name_template :
900900 if not self .name :
901901 old_file = exists (self .id )
902902 else :
@@ -1013,8 +1013,8 @@ def merge(self):
10131013 "-f" , "concat" , "-safe" , "0" ,
10141014 "-i" , f"file:{ t_name } " , "-i" , f"file:{ self .a_name } " ,
10151015 ]
1016- if opts .dur :
1017- command .extend (["-t" , opts .dur ])
1016+ if opts .duration :
1017+ command .extend (["-t" , opts .duration ])
10181018 command .extend (["-c" , "copy" , "-shortest" , f"file:temp_{ m_name } " ])
10191019
10201020 subprocess .run (command )
@@ -1037,7 +1037,7 @@ def archive(self):
10371037 if self .erroneous ():
10381038 return
10391039
1040- with open (opts .archive_path , "a" ) as f :
1040+ with open (opts .archive , "a" ) as f :
10411041 print (self .id , file = f )
10421042
10431043 def preview (self ):
@@ -1073,7 +1073,7 @@ async def process(self, session=None):
10731073
10741074 # 2nd existence check
10751075 # Handles custom names exclusively (slower since API request necessary)
1076- if opts .out_format :
1076+ if opts .name_template :
10771077 self .check_existence ()
10781078
10791079 # Download
@@ -1088,7 +1088,7 @@ async def process(self, session=None):
10881088 # of valid streams with special format options (e.g. --video-only)
10891089 self .done = True
10901090
1091- if opts .archive_path :
1091+ if opts .archive :
10921092 self .archive ()
10931093 if opts .preview :
10941094 self .preview ()
@@ -1419,11 +1419,11 @@ def parse_cli():
14191419 repeat .add_argument ("-r" , "--repeat" , type = positive_int , default = defaults .REPEAT )
14201420 parser .add_argument ("-p" , "--path" , type = os .path .abspath , default = defaults .PATH )
14211421 parser .add_argument ("-k" , "--keep" , action = "store_true" , default = defaults .KEEP )
1422- parser .add_argument ("-d" , "--duration" , dest = "dur" , type = valid_time ,
1423- default = defaults .DUR )
1422+ parser .add_argument ("-d" , "--duration" , type = valid_time ,
1423+ default = defaults .DURATION )
14241424 # Download Options
1425- parser .add_argument ("--connections" , dest = "connect" , type = positive_int ,
1426- default = defaults .CONNECT )
1425+ parser .add_argument ("--connections" , type = positive_int ,
1426+ default = defaults .CONNECTIONS )
14271427 parser .add_argument ("--retries" , type = int , default = defaults .RETRIES )
14281428 parser .add_argument ("--limit-num" , dest = "max_coubs" , type = positive_int ,
14291429 default = defaults .MAX_COUBS )
@@ -1466,15 +1466,15 @@ def parse_cli():
14661466 stream .add_argument ("--video-only" , dest = "v_only" , action = "store_true" ,
14671467 default = defaults .V_ONLY )
14681468 stream .add_argument ("--share" , action = "store_true" , default = defaults .SHARE )
1469- parser .add_argument ("--write-list" , dest = "out_file " , type = os .path .abspath ,
1470- default = defaults .OUT_FILE )
1471- parser .add_argument ("--use-archive" , dest = "archive_path " , type = valid_archive ,
1472- default = defaults .ARCHIVE_PATH )
1469+ parser .add_argument ("--write-list" , dest = "output_list " , type = os .path .abspath ,
1470+ default = defaults .OUTPUT_LIST )
1471+ parser .add_argument ("--use-archive" , dest = "archive " , type = valid_archive ,
1472+ default = defaults .ARCHIVE )
14731473 # Output
14741474 parser .add_argument ("--ext" , dest = "merge_ext" , default = defaults .MERGE_EXT ,
14751475 choices = ["mkv" , "mp4" , "asf" , "avi" , "flv" , "f4v" , "mov" ])
1476- parser .add_argument ("-o" , "--output" , dest = "out_format " ,
1477- default = defaults .OUT_FORMAT )
1476+ parser .add_argument ("-o" , "--output" , dest = "name_template " ,
1477+ default = defaults .NAME_TEMPLATE )
14781478
14791479 # Advanced Options
14801480 parser .set_defaults (
@@ -1496,15 +1496,15 @@ def parse_cli():
14961496 else :
14971497 args .input = args .raw_input
14981498 # Read archive content
1499- if args .archive_path and os .path .exists (args .archive_path ):
1500- with open (args .archive_path , "r" ) as f :
1501- args .archive = [l .strip () for l in f ]
1499+ if args .archive and os .path .exists (args .archive ):
1500+ with open (args .archive , "r" ) as f :
1501+ args .archive_content = [l .strip () for l in f ]
15021502 else :
1503- args .archive = None
1503+ args .archive_content = None
15041504 # The default naming scheme is the same as using %id%
15051505 # but internally the default value is None
1506- if args .out_format == "%id%" :
1507- args .out_format = None
1506+ if args .name_template == "%id%" :
1507+ args .name_template = None
15081508
15091509 return args
15101510
@@ -1611,19 +1611,19 @@ def parse_input(sources):
16111611
16121612def write_list (links ):
16131613 """Output parsed links to a list and exit."""
1614- with open (opts .out_file , opts .write_method ) as f :
1614+ with open (opts .output_list , opts .write_method ) as f :
16151615 for l in links :
16161616 print (l , file = f )
1617- msg (f"\n Parsed coubs written to '{ opts .out_file } '!" ,
1617+ msg (f"\n Parsed coubs written to '{ opts .output_list } '!" ,
16181618 color = fgcolors .SUCCESS )
16191619
16201620
16211621def get_name (req_json , c_id ):
16221622 """Assemble final output name of a given coub."""
1623- if not opts .out_format :
1623+ if not opts .name_template :
16241624 return c_id
16251625
1626- name = opts .out_format
1626+ name = opts .name_template
16271627
16281628 name = name .replace ("%id%" , c_id )
16291629 name = name .replace ("%title%" , req_json ['title' ])
@@ -1879,7 +1879,7 @@ async def process(coubs):
18791879 """Call the process function of all parsed coubs."""
18801880 if aio :
18811881 tout = aiohttp .ClientTimeout (total = None )
1882- conn = aiohttp .TCPConnector (limit = opts .connect )
1882+ conn = aiohttp .TCPConnector (limit = opts .connections )
18831883 try :
18841884 async with aiohttp .ClientSession (timeout = tout , connector = conn ) as session :
18851885 tasks = [c .process (session ) for c in coubs ]
@@ -1938,7 +1938,7 @@ def main():
19381938
19391939 msg ("\n ### Parse Input ###" )
19401940 links = parse_input (opts .input )
1941- if opts .out_file :
1941+ if opts .output_list :
19421942 write_list (links )
19431943 sys .exit (0 )
19441944 total = len (links )
0 commit comments