1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2025-05-10 15:47:30 +00:00

Merge 353c030b76ca3e4bcd12daf9ba7acb2632808a8e into 849edab8ec4fed42f131285b66235b26c78a2d1a

This commit is contained in:
GitHub Merge Button 2011-11-27 08:37:25 -08:00
commit ccb5001550

@ -701,7 +701,12 @@ class FileDownloader(object):
def process_info(self, info_dict):
"""Process a single dictionary returned by an InfoExtractor."""
filename = self.prepare_filename(info_dict)
# Stop downloading at max_downloads (negative means no limit)
if int(self.params.get('max_downloads', -1)) >= 0 and \
int(self._num_downloads) > int(self.params.get('max_downloads', -1)):
return
# Forced printings
if self.params.get('forcetitle', False):
print info_dict['title'].encode(preferredencoding(), 'xmlcharrefreplace')
@ -3996,6 +4001,8 @@ def parseOpts():
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('--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',
dest='username', metavar='USERNAME', help='account username')
@ -4076,7 +4083,6 @@ def parseOpts():
action='store_true', dest='writeinfojson',
help='write video metadata to a .info.json file', 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)')
postproc.add_option('--audio-format', metavar='FORMAT', dest='audioformat', default='best',
@ -4265,6 +4271,7 @@ def _real_main():
'writeinfojson': opts.writeinfojson,
'matchtitle': opts.matchtitle,
'rejecttitle': opts.rejecttitle,
'max_downloads': opts.max_downloads,
})
for extractor in extractors:
fd.add_info_extractor(extractor)