aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYen Chi Hsuan <yan12125@gmail.com>2017-02-03 18:53:14 +0800
committerGitHub <noreply@github.com>2017-02-03 18:53:14 +0800
commit8939f784d92a8267f5bb1967e7953c2952ca243c (patch)
tree7cfa5b8c8433e0b4659a572a651bc4dfaeaff82c
parentdf0588a31f42010d4d43a428ca8a8d5908a960c9 (diff)
parent75822ca7909d7f7e15694f73b05b2bf0f1fa61f3 (diff)
Merge pull request #11901 from ThomasChr/randonplaylistorder
New parameter --playlist-random to randomize playlist download order. Fixes #11889
-rwxr-xr-xyoutube_dl/YoutubeDL.py5
-rw-r--r--youtube_dl/__init__.py1
-rw-r--r--youtube_dl/options.py4
3 files changed, 10 insertions, 0 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py
index c71e94518..a7bf5a1b0 100755
--- a/youtube_dl/YoutubeDL.py
+++ b/youtube_dl/YoutubeDL.py
@@ -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 = {
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py
index 2b156342a..5c5b8094b 100644
--- a/youtube_dl/__init__.py
+++ b/youtube_dl/__init__.py
@@ -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,
diff --git a/youtube_dl/options.py b/youtube_dl/options.py
index 3abf621c0..349f44778 100644
--- a/youtube_dl/options.py
+++ b/youtube_dl/options.py
@@ -471,6 +471,10 @@ def parseOpts(overrideArguments=None):
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',
help='Set file xattribute ytdl.filesize with expected file size (experimental)')