]> jfr.im git - yt-dlp.git/commitdiff
Don't imply `-s` for later stages of `-O`
authorpukkandan <redacted>
Tue, 19 Apr 2022 20:55:33 +0000 (02:25 +0530)
committerpukkandan <redacted>
Wed, 20 Apr 2022 15:31:34 +0000 (21:01 +0530)
README.md
yt_dlp/__init__.py
yt_dlp/options.py
yt_dlp/utils.py

index be713569cb31d00a4da08d348a14bc54c88238e3..d401acb21fde6288d9d472d2ad0a6e6138093e52 100644 (file)
--- a/README.md
+++ b/README.md
@@ -690,9 +690,10 @@ ## Verbosity and Simulation Options:
                                      print it, separated by a ":". Supported
                                      values of "WHEN" are the same as that of
                                      --use-postprocessor, and "video" (default).
-                                     Implies --quiet and --simulate (unless
-                                     --no-simulate is used). This option can be
-                                     used multiple times
+                                     Implies --quiet. Implies --simulate unless
+                                     --no-simulate or later stages of WHEN are
+                                     used. This option can be used multiple
+                                     times
     --print-to-file [WHEN:]TEMPLATE FILE
                                      Append given template to the file. The
                                      values of WHEN and TEMPLATE are same as
index 9ea13ad37a93b774741df7918bf3eba0306c8373..dc2f905c72298d1e22d13eaa8972f2b7a21205d5 100644 (file)
@@ -28,6 +28,7 @@
 from .update import run_update
 from .utils import (
     NO_DEFAULT,
+    POSTPROCESS_WHEN,
     DateRange,
     DownloadCancelled,
     DownloadError,
@@ -618,11 +619,11 @@ def parse_options(argv=None):
 
     postprocessors = list(get_postprocessors(opts))
 
-    any_getting = (any(opts.forceprint.values()) or opts.dumpjson or opts.dump_single_json
-                   or opts.geturl or opts.gettitle or opts.getid or opts.getthumbnail
-                   or opts.getdescription or opts.getfilename or opts.getformat or opts.getduration)
-
-    any_printing = opts.print_json
+    print_only = bool(opts.forceprint) and all(k not in opts.forceprint for k in POSTPROCESS_WHEN[2:])
+    any_getting = any(getattr(opts, k) for k in (
+        'dumpjson', 'dump_single_json', 'getdescription', 'getduration', 'getfilename',
+        'getformat', 'getid', 'getthumbnail', 'gettitle', 'geturl'
+    ))
 
     final_ext = (
         opts.recodevideo if opts.recodevideo in FFmpegVideoConvertorPP.SUPPORTED_EXTS
@@ -640,7 +641,7 @@ def parse_options(argv=None):
         'ap_mso': opts.ap_mso,
         'ap_username': opts.ap_username,
         'ap_password': opts.ap_password,
-        'quiet': (opts.quiet or any_getting or any_printing),
+        'quiet': opts.quiet or any_getting or opts.print_json or bool(opts.forceprint),
         'no_warnings': opts.no_warnings,
         'forceurl': opts.geturl,
         'forcetitle': opts.gettitle,
@@ -655,7 +656,7 @@ def parse_options(argv=None):
         'forcejson': opts.dumpjson or opts.print_json,
         'dump_single_json': opts.dump_single_json,
         'force_write_download_archive': opts.force_write_download_archive,
-        'simulate': (any_getting or None) if opts.simulate is None else opts.simulate,
+        'simulate': (print_only or any_getting or None) if opts.simulate is None else opts.simulate,
         'skip_download': opts.skip_download,
         'format': opts.format,
         'allow_unplayable_formats': opts.allow_unplayable_formats,
index 0c042caf4b39ccafc102f97fbe00df7b6ccd3a67..73bc88b8989da84af1b8491380b92c6486d85efb 100644 (file)
@@ -932,7 +932,8 @@ def _dict_from_options_callback(
         }, help=(
             'Field name or output template to print to screen, optionally prefixed with when to print it, separated by a ":". '
             'Supported values of "WHEN" are the same as that of --use-postprocessor, and "video" (default). '
-            'Implies --quiet and --simulate (unless --no-simulate is used). This option can be used multiple times'))
+            'Implies --quiet. Implies --simulate unless --no-simulate or later stages of WHEN are used. '
+            'This option can be used multiple times'))
     verbosity.add_option(
         '--print-to-file',
         metavar='[WHEN:]TEMPLATE FILE', dest='print_to_file', default={}, type='str', nargs=2,
index e1db7b868137110ff24b2760b20dfa6cb686bd2d..ccea3c4e69215a8095cb5c6f348b03b9e5200016 100644 (file)
@@ -3013,7 +3013,7 @@ def q(qid):
     return q
 
 
-POSTPROCESS_WHEN = {'pre_process', 'after_filter', 'before_dl', 'after_move', 'post_process', 'after_video', 'playlist'}
+POSTPROCESS_WHEN = ('pre_process', 'after_filter', 'before_dl', 'after_move', 'post_process', 'after_video', 'playlist')
 
 
 DEFAULT_OUTTMPL = {