]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/__init__.py
Fix bug in 52efa4b31200119adaa8acf33e50b84fcb6948f0
[yt-dlp.git] / yt_dlp / __init__.py
index 0fc517b99605e9d04569850bc7a30b5a22033cec..a445d862128dcbe1e5d359858728309f5c9cc53d 100644 (file)
@@ -94,9 +94,9 @@ def print_extractor_information(opts, urls):
         for ie in list_extractors(opts.age_limit):
             if not ie.working():
                 continue
-            desc = getattr(ie, 'IE_DESC', ie.IE_NAME)
-            if desc is False:
+            if ie.IE_DESC is False:
                 continue
+            desc = ie.IE_DESC or ie.IE_NAME
             if getattr(ie, 'SEARCH_KEY', None) is not None:
                 _SEARCHES = ('cute kittens', 'slithering pythons', 'falling cat', 'angry poodle', 'purple fish', 'running tortoise', 'sleeping bunny', 'burping cow')
                 _COUNTS = ('', '5', '10', 'all')
@@ -198,10 +198,13 @@ def validate_minmax(min_val, max_val, min_name, max_name=None):
     validate_positive('requests sleep interval', opts.sleep_interval_requests)
     validate_positive('sleep interval', opts.sleep_interval)
     validate_positive('max sleep interval', opts.max_sleep_interval)
-    if opts.max_sleep_interval is not None:
+    if opts.sleep_interval is None:
         validate(
-            opts.sleep_interval is not None, 'min sleep interval',
+            opts.max_sleep_interval is None, 'min sleep interval',
             msg='{name} must be specified; use --min-sleep-interval')
+    elif opts.max_sleep_interval is None:
+        opts.max_sleep_interval = opts.sleep_interval
+    else:
         validate_minmax(opts.sleep_interval, opts.max_sleep_interval, 'sleep interval')
 
     if opts.wait_for_video is not None:
@@ -355,7 +358,6 @@ def metadataparser_actions(f):
             raise ValueError('unsupported geo-bypass country or ip-block')
 
     opts.match_filter = match_filter_func(opts.match_filter)
-    opts.date = DateRange.day(opts.date) if opts.date else DateRange(opts.dateafter, opts.datebefore)
 
     if opts.download_archive is not None:
         opts.download_archive = expand_path(opts.download_archive)
@@ -403,8 +405,8 @@ def report_conflict(arg1, opt1, arg2='--allow-unplayable-formats', opt2='allow_u
         setattr(opts, opt1, default)
 
     # Conflicting options
-    report_conflict('--date-after', 'dateafter', '--date', 'date', default=None)
-    report_conflict('--date-before', 'datebefore', '--date', 'date', default=None)
+    report_conflict('--dateafter', 'dateafter', '--date', 'date', default=None)
+    report_conflict('--datebefore', 'datebefore', '--date', 'date', default=None)
     report_conflict('--exec-before-download', 'exec_before_dl_cmd', '"--exec before_dl:"', 'exec_cmd', opts.exec_cmd.get('before_dl'))
     report_conflict('--id', 'useid', '--output', 'outtmpl', val2=opts.outtmpl.get('default'))
     report_conflict('--remux-video', 'remuxvideo', '--recode-video', 'recodevideo')
@@ -443,6 +445,8 @@ def report_deprecation(val, old, new=None):
     # report_deprecation(opts.writeannotations, '--write-annotations')  # It's just that no website has it
 
     # Dependent options
+    opts.date = DateRange.day(opts.date) if opts.date else DateRange(opts.dateafter, opts.datebefore)
+
     if opts.exec_before_dl_cmd:
         opts.exec_cmd['before_dl'] = opts.exec_before_dl_cmd
 
@@ -818,6 +822,7 @@ def _real_main(argv=None):
     if opts.dump_user_agent:
         ua = traverse_obj(opts.headers, 'User-Agent', casesense=False, default=std_headers['User-Agent'])
         write_string(f'{ua}\n', out=sys.stdout)
+        sys.exit(0)
 
     if print_extractor_information(opts, all_urls):
         sys.exit(0)