From 340368a22e82defe8ec843f957ef69925b04f2dd Mon Sep 17 00:00:00 2001 From: Arijit Basu Date: Sun, 16 Jul 2017 16:47:09 +0530 Subject: [PATCH 1/2] with index --- youtube_dl/__init__.py | 5 +++++ youtube_dl/options.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index c4589411e..04b3fea9a 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -231,6 +231,10 @@ def _real_main(argv=None): (opts.useid and '%(id)s.%(ext)s') or (opts.autonumber and '%(autonumber)s-%(id)s.%(ext)s') or DEFAULT_OUTTMPL) + + if opts.withindex: + outtmpl = '%(playlist_index)s. '+outtmpl + if not os.path.splitext(outtmpl)[1] and opts.extractaudio: parser.error('Cannot download a video and extract audio into the same' ' file! Use "{0}.%(ext)s" instead of "{0}" as the output' @@ -333,6 +337,7 @@ def _real_main(argv=None): 'format': opts.format, 'listformats': opts.listformats, 'outtmpl': outtmpl, + 'withindex': opts.withindex, 'autonumber_size': opts.autonumber_size, 'autonumber_start': opts.autonumber_start, 'restrictfilenames': opts.restrictfilenames, diff --git a/youtube_dl/options.py b/youtube_dl/options.py index 79e9fd12c..d560a2bfd 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -689,6 +689,9 @@ def parseOpts(overrideArguments=None): '--autonumber-start', dest='autonumber_start', metavar='NUMBER', default=1, type=int, help='Specify the start value for %(autonumber)s (default is %default)') + filesystem.add_option( + '--with-index', default=False, + action='store_true', dest='withindex', help='Add playlist index before filenames') filesystem.add_option( '--restrict-filenames', action='store_true', dest='restrictfilenames', default=False, From 76203c7a738bf94bb08af9bf0033cedc81a4850c Mon Sep 17 00:00:00 2001 From: Arijit Basu Date: Sun, 16 Jul 2017 16:50:51 +0530 Subject: [PATCH 2/2] with index --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fe2bebc2a..0bbe718e1 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,7 @@ Alternatively, refer to the [developer instructions](#developer-instructions) fo TEMPLATE" for all the info --autonumber-start NUMBER Specify the start value for %(autonumber)s (default is 1) + --with-index Add playlist index before filenames --restrict-filenames Restrict filenames to only ASCII characters, and avoid "&" and spaces in filenames