]> git.bitcoin.ninja Git - youtube-dl/commitdiff
New parameter --playlist-random to randomize playlist download order. Fixes #11889
authorThomas Christlieb <thomaschristlieb@hotmail.com>
Tue, 31 Jan 2017 09:03:31 +0000 (10:03 +0100)
committerThomas Christlieb <thomaschristlieb@hotmail.com>
Tue, 31 Jan 2017 09:03:31 +0000 (10:03 +0100)
youtube_dl/YoutubeDL.py
youtube_dl/__init__.py
youtube_dl/options.py

index c71e94518bd981edf682483c85aa059730368b40..a7bf5a1b06766094cc06e85fd40c6fa64c2cc64b 100755 (executable)
@@ -24,6 +24,7 @@ import sys
 import time
 import tokenize
 import traceback
+import random
 
 from .compat import (
     compat_basestring,
@@ -159,6 +160,7 @@ class YoutubeDL(object):
     playlistend:       Playlist item to end at.
     playlist_items:    Specific indices of playlist to download.
     playlistreverse:   Download playlist items in reverse order.
+    playlistrandom:    Download playlist items in random order.
     matchtitle:        Download only matching titles.
     rejecttitle:       Reject downloads for matching titles.
     logger:            Log messages to a logging.Logger instance.
@@ -842,6 +844,9 @@ class YoutubeDL(object):
             if self.params.get('playlistreverse', False):
                 entries = entries[::-1]
 
+            if self.params.get('playlistrandom', False):
+                random.shuffle(entries)
+
             for i, entry in enumerate(entries, 1):
                 self.to_screen('[download] Downloading video %s of %s' % (i, n_entries))
                 extra = {
index 2b156342ad3e9b81ed43618dd65b30216ed16b35..5c5b8094bc1b6cbc68b09eba85b06a63a2ee785d 100644 (file)
@@ -344,6 +344,7 @@ def _real_main(argv=None):
         'playliststart': opts.playliststart,
         'playlistend': opts.playlistend,
         'playlistreverse': opts.playlist_reverse,
+        'playlistrandom': opts.playlist_random,
         'noplaylist': opts.noplaylist,
         'logtostderr': opts.outtmpl == '-',
         'consoletitle': opts.consoletitle,
index 3abf621c090484139d393516bd2554b6651989fe..349f44778e799af0c58b249939f14958036080a1 100644 (file)
@@ -470,6 +470,10 @@ def parseOpts(overrideArguments=None):
         '--playlist-reverse',
         action='store_true',
         help='Download playlist videos in reverse order')
+    downloader.add_option(
+        '--playlist-random',
+        action='store_true',
+        help='Download playlist videos in random order')
     downloader.add_option(
         '--xattr-set-filesize',
         dest='xattr_set_filesize', action='store_true',