Merge 4f87c8b95e
into d65d89183f
This commit is contained in:
commit
1f976680d7
|
@ -978,6 +978,7 @@ class YoutubeDL(object):
|
|||
|
||||
x_forwarded_for = ie_result.get('__x_forwarded_for_ip')
|
||||
|
||||
has_seen_withinrange_vid = False
|
||||
for i, entry in enumerate(entries, 1):
|
||||
self.to_screen('[download] Downloading video %s of %s' % (i, n_entries))
|
||||
# This __x_forwarded_for_ip thing is a bit ugly but requires
|
||||
|
@ -1006,7 +1007,24 @@ class YoutubeDL(object):
|
|||
entry_result = self.process_ie_result(entry,
|
||||
download=download,
|
||||
extra_info=extra)
|
||||
|
||||
entry_result_uploaddate = date_from_str(entry_result.get('upload_date'))
|
||||
date_playlist_order = self.params.get('date_playlist_order')
|
||||
daterangeobj = self.params.get('daterange')
|
||||
dateafter = daterangeobj.start
|
||||
datebefore = daterangeobj.end
|
||||
if entry_result and entry_result_uploaddate and date_playlist_order in ('desc', 'asc'):
|
||||
if not has_seen_withinrange_vid:
|
||||
if entry_result_uploaddate in daterangeobj:
|
||||
has_seen_withinrange_vid = True
|
||||
elif ((date_playlist_order == 'desc' and entry_result_uploaddate < dateafter) or
|
||||
(date_playlist_order == 'asc' and entry_result_uploaddate > datebefore)):
|
||||
break
|
||||
elif has_seen_withinrange_vid and entry_result_uploaddate not in daterangeobj:
|
||||
break
|
||||
|
||||
playlist_results.append(entry_result)
|
||||
|
||||
ie_result['entries'] = playlist_results
|
||||
self.to_screen('[download] Finished downloading playlist: %s' % playlist)
|
||||
return ie_result
|
||||
|
|
|
@ -361,6 +361,7 @@ def _real_main(argv=None):
|
|||
'playlistend': opts.playlistend,
|
||||
'playlistreverse': opts.playlist_reverse,
|
||||
'playlistrandom': opts.playlist_random,
|
||||
'date_playlist_order': opts.date_playlist_order,
|
||||
'noplaylist': opts.noplaylist,
|
||||
'logtostderr': opts.outtmpl == '-',
|
||||
'consoletitle': opts.consoletitle,
|
||||
|
|
|
@ -299,6 +299,13 @@ 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-playlist-order',
|
||||
metavar='ORDER', dest='date_playlist_order', default='none',
|
||||
type='choice', choices=['asc', 'desc', 'none'],
|
||||
help='The playlist is known to be sorted in chronological order. '
|
||||
'One of desc (most recent first), asc (least recent first), or none (no effect, the default). '
|
||||
'Causes youtube-dl to stop downloading the playlist after encountering a video outside the specified date restrictions.')
|
||||
selection.add_option(
|
||||
'--min-views',
|
||||
metavar='COUNT', dest='min_views', default=None, type=int,
|
||||
|
|
Loading…
Reference in New Issue