From 6cab71147e9f434e63f121f59610e9c66ca9cdca Mon Sep 17 00:00:00 2001 From: Ethan Muir Date: Mon, 27 Nov 2023 23:25:34 -0500 Subject: [PATCH] Added the Trim command line arg When the --trim command line arg is used, the file will download into a different folder called "trimmed_video" --- youtube_dl/YoutubeDL.py | 4 ++++ youtube_dl/__init__.py | 1 + youtube_dl/options.py | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 13a41928f..3b4753abe 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -1950,6 +1950,10 @@ class YoutubeDL(object): if filename is None: return + # ETHAN + if self.params.get('usetrim', False): + filename = "/trimmed_video/" + filename + def ensure_dir_exists(path): try: dn = os.path.dirname(path) diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index cc8285eba..e63170519 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -432,6 +432,7 @@ def _real_main(argv=None): 'geo_bypass': opts.geo_bypass, 'geo_bypass_country': opts.geo_bypass_country, 'geo_bypass_ip_block': opts.geo_bypass_ip_block, + 'usetrim': opts.usetrim, # just for deprecation check 'autonumber': opts.autonumber if opts.autonumber is True else None, 'usetitle': opts.usetitle if opts.usetitle is True else None, diff --git a/youtube_dl/options.py b/youtube_dl/options.py index 434f520d3..f5c427489 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -713,6 +713,10 @@ def parseOpts(overrideArguments=None): '-t', '--title', action='store_true', dest='usetitle', default=False, help=optparse.SUPPRESS_HELP) + filesystem.add_option( + '--trim', + action='store_true', dest='usetrim', default=False, + help=optparse.SUPPRESS_HELP) filesystem.add_option( '-l', '--literal', default=False, action='store_true', dest='usetitle',