From 13299df976afa7da32ce3469dc90b17b598ff001 Mon Sep 17 00:00:00 2001 From: JewsOfHazard Date: Thu, 1 Sep 2016 17:17:08 -0700 Subject: [PATCH] Added --autonumber-start [number] option --- youtube_dl/YoutubeDL.py | 5 ++++- youtube_dl/__init__.py | 1 + youtube_dl/options.py | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 805733fb7..596a06cf5 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -578,10 +578,13 @@ class YoutubeDL(object): template_dict['epoch'] = int(time.time()) autonumber_size = self.params.get('autonumber_size') + autonumber_start = self.params.get('autonumber_start') if autonumber_size is None: autonumber_size = 5 + if autonumber_start is None or autonumber_start < 1: + autonumber_start = 1 autonumber_templ = '%0' + str(autonumber_size) + 'd' - template_dict['autonumber'] = autonumber_templ % self._num_downloads + template_dict['autonumber'] = autonumber_templ % (self._num_downloads + int(autonumber_start)-1) if template_dict.get('playlist_index') is not None: template_dict['playlist_index'] = '%0*d' % (len(str(template_dict['n_entries'])), template_dict['playlist_index']) if template_dict.get('resolution') is None: diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index a9730292c..c405d2157 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -311,6 +311,7 @@ def _real_main(argv=None): 'listformats': opts.listformats, 'outtmpl': outtmpl, 'autonumber_size': opts.autonumber_size, + 'autonumber_start': opts.autonumber_start, 'restrictfilenames': opts.restrictfilenames, 'ignoreerrors': opts.ignoreerrors, 'force_generic_extractor': opts.force_generic_extractor, diff --git a/youtube_dl/options.py b/youtube_dl/options.py index 5d62deef4..652671b6c 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -633,6 +633,10 @@ def parseOpts(overrideArguments=None): '--autonumber-size', dest='autonumber_size', metavar='NUMBER', help='Specify the number of digits in %(autonumber)s when it is present in output filename template or --auto-number option is given') + filesystem.add_option( + '--autonumber-start', + dest='autonumber_start', metavar='NUMBER', default=0, + help='Starts %(autonumber)s at the passed number (positive numbers only).') filesystem.add_option( '--restrict-filenames', action='store_true', dest='restrictfilenames', default=False, @@ -700,6 +704,7 @@ def parseOpts(overrideArguments=None): action='store_true', dest='rm_cachedir', help='Delete all filesystem cache files') + thumbnail = optparse.OptionGroup(parser, 'Thumbnail images') thumbnail.add_option( '--write-thumbnail',