diff --git a/README.md b/README.md index dffdaa9dc..c034a8d36 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,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 diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 3dff723b8..332d25c34 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -114,6 +114,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. @@ -611,6 +612,8 @@ class YoutubeDL(object): if isinstance(ie_result['entries'], list): n_all_entries = len(ie_result['entries']) entries = ie_result['entries'][playliststart:playlistend] + if self.params.get('playlistreverse', False): + entries = entries[::-1] n_entries = len(entries) self.to_screen( "[%s] playlist %s: Collected %d video ids (downloading %d of them)" % diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 31ed63fcc..6c550870e 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -287,6 +287,10 @@ def parseOpts(overrideArguments=None): '--playlist-end', dest='playlistend', metavar='NUMBER', default=None, type=int, help='playlist video to end at (default is last)') + selection.add_option( + '--playlist-reverse', + action='store_true', + help='Download playlist videos in reverse order') selection.add_option('--match-title', dest='matchtitle', metavar='REGEX',help='download only matching titles (regex or caseless sub-string)') selection.add_option('--reject-title', dest='rejecttitle', metavar='REGEX',help='skip download for matching titles (regex or caseless sub-string)') selection.add_option('--max-downloads', metavar='NUMBER', @@ -757,6 +761,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,