From 27fe09dfcc9a1a5c036c50f4ad81fdbbb914ceb0 Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 26 Mar 2017 22:54:55 -0400 Subject: [PATCH] again --- youtube_dl/YoutubeDL.py | 7 +++++-- youtube_dl/options.py | 11 ++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 89663cc81..1836c58cd 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -922,7 +922,10 @@ class YoutubeDL(object): x_forwarded_for = ie_result.get('__x_forwarded_for_ip') - reliably_date_ordered_IEs = ('YoutubeChannelIE, YoutubeUserIE') + if self.params.get('date_playlist_order') == 'asc' and not self.params.get('start_from_earliest'): + entries.reverse() + if self.params.get('date_playlist_order') == 'desc' and self.params.get('start_from_earliest'): + entries.reverse() for i, entry in enumerate(entries, 1): self.to_screen('[download] Downloading video %s of %s' % (i, n_entries)) @@ -953,7 +956,7 @@ class YoutubeDL(object): entry_result_uploaddate = entry_result.get('upload_date') if entry_result_uploaddate: - if self.params.get('date_ordered_playlist') and entry_result_uploaddate not in self.params.get('daterange'): + if self.params.get('date_playlist_order') in ('desc', 'asc') and entry_result_uploaddate not in self.params.get('daterange'): break playlist_results.append(entry_result) diff --git a/youtube_dl/options.py b/youtube_dl/options.py index 9c7c1a795..918022a57 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -298,9 +298,14 @@ def parseOpts(overrideArguments=None): metavar='DATE', dest='dateafter', default=None, help='Download only videos uploaded on or after this date (i.e. inclusive)') selection.add_option( - '--date-ordered-playlist', - metavar='DATE', dest='date_ordered_playlist', default=None, action='store_true', - help='Playlist is known to be in chronologically descending order') + '--date-playlist-order', + metavar='ORDER', dest='date_playlist_order', default='none', + type='choice', choices=['asc', 'desc', 'none'], + help='Specify whether a playlist is known to be listed in chronological order. "Asc", "desc" or "none". Descending order is most recent to least, and is the most useful. Default is "none", and is like not using this option at all. Automatically stops after encountering the first video date outside of the date range configured by --date, --datebefore, and --dateafter.') + selection.add_option( + '--start-from-earliest', + metavar='FROM', dest='start_from_earliest', + action='store_true', help='In conjunction with --date-playlist-order, specify whether to start from the earliest videos or the latest. The default behavior is to start from the latest.') selection.add_option( '--min-views', metavar='COUNT', dest='min_views', default=None, type=int,