diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index ab72bdd4f..29c010e68 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -757,15 +757,6 @@ class YoutubeDL(object): self.report_warning('The program functionality for this site has been marked as broken, ' 'and will probably not work.') - try: - if self.original_ie: - pass # self.original_ie already exists - except AttributeError: - try: - self.original_ie = re.search("\.([^\.]+)'>", str(type(ie))).group(1) - except: - self.original_ie = None - try: ie_result = ie.extract(url) if ie_result is None: # Finished already (backwards compatibility; listformats and friends should be moved here) @@ -960,19 +951,19 @@ class YoutubeDL(object): download=download, extra_info=extra) - try: - entry_result_date = entry_result['upload_date'] - entry_result_date_year = int(entry_result_date[0:4]) - entry_result_date_month = int(entry_result_date[4:6]) - entry_result_date_day = int(entry_result_date[6:8]) - entry_result_date = datetime.date(year=entry_result_date_year, month=entry_result_date_month, day=entry_result_date_day) - # if the entries originate with an info extractor known to return date-sorted results, simply break after we meet the first date out of range - if self.original_ie in reliably_date_ordered_IEs and entry_result_date not in self.params['daterange']: + # import pudb; pudb.set_trace() + entry_result_uploaddate = entry_result.get('upload_date') + if entry_result_uploaddate: + entry_result_uploaddate_dateobject = datetime.date( + year=int(entry_result_uploaddate[0:4]), + month=int(entry_result_uploaddate[4:6]), + day=int(entry_result_uploaddate[6:8]) + ) + + if self.params.get('date_ordered_playlist') and entry_result_uploaddate_dateobject not in self.params.get('daterange'): break - else: - playlist_results.append(entry_result) - except: # I don't really know what to expect, so in case of error just fall back to the previous, default, behavior - playlist_results.append(entry_result) + + playlist_results.append(entry_result) ie_result['entries'] = playlist_results self.to_screen('[download] Finished downloading playlist: %s' % playlist) diff --git a/youtube_dl/options.py b/youtube_dl/options.py index 6b811535f..9c7c1a795 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -297,6 +297,10 @@ def parseOpts(overrideArguments=None): '--dateafter', 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') selection.add_option( '--min-views', metavar='COUNT', dest='min_views', default=None, type=int,