From c810f20e966380da73a8f938c49576ddef341c40 Mon Sep 17 00:00:00 2001 From: JewsOfHazard Date: Sun, 28 Aug 2016 02:02:16 -0700 Subject: [PATCH 1/2] Added --playlist-index-offset parameter --- youtube_dl/YoutubeDL.py | 2 +- youtube_dl/__init__.py | 1 + youtube_dl/options.py | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 805733fb7..582ea67f5 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -583,7 +583,7 @@ class YoutubeDL(object): autonumber_templ = '%0' + str(autonumber_size) + 'd' template_dict['autonumber'] = autonumber_templ % self._num_downloads 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']) + template_dict['playlist_index'] = '%0*d' % (len(str(template_dict['n_entries'])), (int(template_dict['playlist_index']) + int(self.params.get('playlist_index_offset')))) if template_dict.get('resolution') is None: if template_dict.get('width') and template_dict.get('height'): template_dict['resolution'] = '%dx%d' % (template_dict['width'], template_dict['height']) diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index a9730292c..deaa357c2 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -326,6 +326,7 @@ def _real_main(argv=None): 'playliststart': opts.playliststart, 'playlistend': opts.playlistend, 'playlistreverse': opts.playlist_reverse, + 'playlist_index_offset': opts.playlist_index_offset, 'noplaylist': opts.noplaylist, 'logtostderr': opts.outtmpl == '-', 'consoletitle': opts.consoletitle, diff --git a/youtube_dl/options.py b/youtube_dl/options.py index 5d62deef4..d78840f4d 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -699,6 +699,10 @@ def parseOpts(overrideArguments=None): '--rm-cache-dir', action='store_true', dest='rm_cachedir', help='Delete all filesystem cache files') + filesystem.add_option( + '--playlist-index-offset', + dest="playlist_index_offset", metavar='NUMBER', type=int, default=0, + help='Offsets %(playlist_index)s by the specified value.') thumbnail = optparse.OptionGroup(parser, 'Thumbnail images') thumbnail.add_option( From dcacbefc5a1228b66a8b2697658b0605368b9f9b Mon Sep 17 00:00:00 2001 From: JewsOfHazard Date: Sun, 28 Aug 2016 02:14:05 -0700 Subject: [PATCH 2/2] Removed useless typecast --- youtube_dl/YoutubeDL.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 582ea67f5..486985744 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -583,7 +583,7 @@ class YoutubeDL(object): autonumber_templ = '%0' + str(autonumber_size) + 'd' template_dict['autonumber'] = autonumber_templ % self._num_downloads if template_dict.get('playlist_index') is not None: - template_dict['playlist_index'] = '%0*d' % (len(str(template_dict['n_entries'])), (int(template_dict['playlist_index']) + int(self.params.get('playlist_index_offset')))) + template_dict['playlist_index'] = '%0*d' % (len(str(template_dict['n_entries'])), (template_dict['playlist_index'] + int(self.params.get('playlist_index_offset')))) if template_dict.get('resolution') is None: if template_dict.get('width') and template_dict.get('height'): template_dict['resolution'] = '%dx%d' % (template_dict['width'], template_dict['height'])