1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-22 18:22:21 +00:00

Rename max-files to max-downloads, improve handling of max_downloads

This commit is contained in:
Vladimir Berezhnoy 2011-11-27 20:36:27 +04:00
parent 1080820b50
commit 353c030b76

View file

@ -702,9 +702,9 @@ class FileDownloader(object):
"""Process a single dictionary returned by an InfoExtractor.""" """Process a single dictionary returned by an InfoExtractor."""
filename = self.prepare_filename(info_dict) filename = self.prepare_filename(info_dict)
# Stop downloading at max_files (0 means no limit) # Stop downloading at max_downloads (negative means no limit)
if int(self.params.get('max_files', 0)) != 0 and \ if int(self.params.get('max_downloads', -1)) >= 0 and \
(int(self._num_downloads) > int(self.params.get('max_files', 0))): int(self._num_downloads) > int(self.params.get('max_downloads', -1)):
return return
# Forced printings # Forced printings
@ -4001,6 +4001,8 @@ def parseOpts():
dest='playlistend', metavar='NUMBER', help='playlist video to end at (default is last)', default=-1) dest='playlistend', metavar='NUMBER', help='playlist video to end at (default is last)', default=-1)
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',
dest='max_downloads', help='Maximum number of files to download, -1 means no limit', default=-1)
authentication.add_option('-u', '--username', authentication.add_option('-u', '--username',
dest='username', metavar='USERNAME', help='account username') dest='username', metavar='USERNAME', help='account username')
@ -4080,9 +4082,6 @@ def parseOpts():
filesystem.add_option('--write-info-json', filesystem.add_option('--write-info-json',
action='store_true', dest='writeinfojson', action='store_true', dest='writeinfojson',
help='write video metadata to a .info.json file', default=False) help='write video metadata to a .info.json file', default=False)
filesystem.add_option('--max-files',
dest='max_files', help='Maximum number of files to download', default=0)
postproc.add_option('--extract-audio', action='store_true', dest='extractaudio', default=False, postproc.add_option('--extract-audio', action='store_true', dest='extractaudio', default=False,
help='convert video files to audio-only files (requires ffmpeg and ffprobe)') help='convert video files to audio-only files (requires ffmpeg and ffprobe)')
@ -4272,7 +4271,7 @@ def _real_main():
'writeinfojson': opts.writeinfojson, 'writeinfojson': opts.writeinfojson,
'matchtitle': opts.matchtitle, 'matchtitle': opts.matchtitle,
'rejecttitle': opts.rejecttitle, 'rejecttitle': opts.rejecttitle,
'max_files': opts.max_files, 'max_downloads': opts.max_downloads,
}) })
for extractor in extractors: for extractor in extractors:
fd.add_info_extractor(extractor) fd.add_info_extractor(extractor)