mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-05 01:44:33 +01:00
Simplify --playlist-start / --playlist-end interface
This commit is contained in:
parent
d66152a898
commit
a19fd00cc4
@ -557,16 +557,16 @@ class YoutubeDL(object):
|
|||||||
|
|
||||||
n_all_entries = len(ie_result['entries'])
|
n_all_entries = len(ie_result['entries'])
|
||||||
playliststart = self.params.get('playliststart', 1) - 1
|
playliststart = self.params.get('playliststart', 1) - 1
|
||||||
playlistend = self.params.get('playlistend', -1)
|
playlistend = self.params.get('playlistend', None)
|
||||||
|
# For backwards compatibility, interpret -1 as whole list
|
||||||
if playlistend == -1:
|
if playlistend == -1:
|
||||||
entries = ie_result['entries'][playliststart:]
|
playlistend = None
|
||||||
else:
|
|
||||||
entries = ie_result['entries'][playliststart:playlistend]
|
|
||||||
|
|
||||||
|
entries = ie_result['entries'][playliststart:playlistend]
|
||||||
n_entries = len(entries)
|
n_entries = len(entries)
|
||||||
|
|
||||||
self.to_screen(u"[%s] playlist '%s': Collected %d video ids (downloading %d of them)" %
|
self.to_screen(
|
||||||
|
u"[%s] playlist '%s': Collected %d video ids (downloading %d of them)" %
|
||||||
(ie_result['extractor'], playlist, n_all_entries, n_entries))
|
(ie_result['extractor'], playlist, n_all_entries, n_entries))
|
||||||
|
|
||||||
for i, entry in enumerate(entries, 1):
|
for i, entry in enumerate(entries, 1):
|
||||||
|
@ -198,10 +198,14 @@ def parseOpts(overrideArguments=None):
|
|||||||
help=u'Work around terminals that lack bidirectional text support. Requires fribidi executable in PATH')
|
help=u'Work around terminals that lack bidirectional text support. Requires fribidi executable in PATH')
|
||||||
|
|
||||||
|
|
||||||
selection.add_option('--playlist-start',
|
selection.add_option(
|
||||||
dest='playliststart', metavar='NUMBER', help='playlist video to start at (default is %default)', default=1)
|
'--playlist-start',
|
||||||
selection.add_option('--playlist-end',
|
dest='playliststart', metavar='NUMBER', default=1, type=int,
|
||||||
dest='playlistend', metavar='NUMBER', help='playlist video to end at (default is last)', default=-1)
|
help='playlist video to start at (default is %default)')
|
||||||
|
selection.add_option(
|
||||||
|
'--playlist-end',
|
||||||
|
dest='playlistend', metavar='NUMBER', default=None, type=int,
|
||||||
|
help='playlist video to end at (default is last)')
|
||||||
selection.add_option('--match-title', dest='matchtitle', metavar='REGEX',help='download only matching titles (regex or caseless sub-string)')
|
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('--reject-title', dest='rejecttitle', metavar='REGEX',help='skip download for matching titles (regex or caseless sub-string)')
|
||||||
selection.add_option('--max-downloads', metavar='NUMBER',
|
selection.add_option('--max-downloads', metavar='NUMBER',
|
||||||
@ -576,18 +580,10 @@ def _real_main(argv=None):
|
|||||||
if numeric_buffersize is None:
|
if numeric_buffersize is None:
|
||||||
parser.error(u'invalid buffer size specified')
|
parser.error(u'invalid buffer size specified')
|
||||||
opts.buffersize = numeric_buffersize
|
opts.buffersize = numeric_buffersize
|
||||||
try:
|
|
||||||
opts.playliststart = int(opts.playliststart)
|
|
||||||
if opts.playliststart <= 0:
|
if opts.playliststart <= 0:
|
||||||
raise ValueError(u'Playlist start must be positive')
|
raise ValueError(u'Playlist start must be positive')
|
||||||
except (TypeError, ValueError):
|
if opts.playlistend not in (-1, None) and opts.playlistend < opts.playliststart:
|
||||||
parser.error(u'invalid playlist start number specified')
|
|
||||||
try:
|
|
||||||
opts.playlistend = int(opts.playlistend)
|
|
||||||
if opts.playlistend != -1 and (opts.playlistend <= 0 or opts.playlistend < opts.playliststart):
|
|
||||||
raise ValueError(u'Playlist end must be greater than playlist start')
|
raise ValueError(u'Playlist end must be greater than playlist start')
|
||||||
except (TypeError, ValueError):
|
|
||||||
parser.error(u'invalid playlist end number specified')
|
|
||||||
if opts.extractaudio:
|
if opts.extractaudio:
|
||||||
if opts.audioformat not in ['best', 'aac', 'mp3', 'm4a', 'opus', 'vorbis', 'wav']:
|
if opts.audioformat not in ['best', 'aac', 'mp3', 'm4a', 'opus', 'vorbis', 'wav']:
|
||||||
parser.error(u'invalid audio format specified')
|
parser.error(u'invalid audio format specified')
|
||||||
|
Loading…
Reference in New Issue
Block a user