Download playlist items in reverse order
authorMark Schreiber <mark7@alumni.cmu.edu>
Fri, 11 Jul 2014 03:11:11 +0000 (20:11 -0700)
committerPhilipp Hagemeister <phihag@phihag.de>
Fri, 12 Dec 2014 15:56:29 +0000 (16:56 +0100)
Series of videos are typically uploaded to YouTube playlists in
chronological order.  By default, these videos are downloaded
latest-to-earliest; this is great for seeing the latest videos in a
series, but prevents streaming video in the order that the videos were
produced.  Add an option to download videos in reverse order,
earliest-to-latest.

Conflicts:
youtube_dl/YoutubeDL.py
youtube_dl/__init__.py

README.md
youtube_dl/YoutubeDL.py
youtube_dl/__init__.py
youtube_dl/options.py

index b3af18912bc69c5b1dcaf3d08c961b6e86ef0d88..e41ee89854c25157a43ac3f3303367aa03a1244d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -75,6 +75,7 @@ which means you can modify it, redistribute it or use it however you like.
 ## Video Selection:
     --playlist-start NUMBER          playlist video to start at (default is 1)
     --playlist-end NUMBER            playlist video to end at (default is last)
+    --playlist-reverse               Download playlist videos in reverse order
     --match-title REGEX              download only matching titles (regex or
                                      caseless sub-string)
     --reject-title REGEX             skip download for matching titles (regex or
index e7abb7e0b2f1a7e8794ac7e384e5441171abb385..578c8daf255048b90caaf6caa5f09825e1d2bfe6 100755 (executable)
@@ -124,6 +124,7 @@ class YoutubeDL(object):
     nooverwrites:      Prevent overwriting files.
     playliststart:     Playlist item to start at.
     playlistend:       Playlist item to end at.
+    playlistreverse:   Download playlist items in reverse order.
     matchtitle:        Download only matching titles.
     rejecttitle:       Reject downloads for matching titles.
     logger:            Log messages to a logging.Logger instance.
@@ -670,6 +671,9 @@ class YoutubeDL(object):
                     "[%s] playlist %s: Downloading %d videos" %
                     (ie_result['extractor'], playlist, n_entries))
 
+            if self.params.get('playlistreverse', False):
+                entries = entries[::-1]
+
             for i, entry in enumerate(entries, 1):
                 self.to_screen('[download] Downloading video #%s of %s' % (i, n_entries))
                 extra = {
index 77b3384a05fa45d6d4cada65decdb5588ade9100..70c4f25b161d5d7b158da52a64b22dedc4b1a9f8 100644 (file)
@@ -249,6 +249,7 @@ def _real_main(argv=None):
         'progress_with_newline': opts.progress_with_newline,
         'playliststart': opts.playliststart,
         'playlistend': opts.playlistend,
+        'playlistreverse': opts.playlist_reverse,
         'noplaylist': opts.noplaylist,
         'logtostderr': opts.outtmpl == '-',
         'consoletitle': opts.consoletitle,
index 041ca83d88612c2aa9f56b8fce1b9349b2d96ab8..7654d1a4ecbb4d357424fcdea68bbcaa51e80a9c 100644 (file)
@@ -349,6 +349,10 @@ def parseOpts(overrideArguments=None):
         '--test',
         action='store_true', dest='test', default=False,
         help=optparse.SUPPRESS_HELP)
+    downloader.add_option(
+        '--playlist-reverse',
+        action='store_true',
+        help='Download playlist videos in reverse order')
 
     workarounds = optparse.OptionGroup(parser, 'Workarounds')
     workarounds.add_option(