Browse Source

Add --match-title and --reject-title (Closes #132)

rtmp_test
Anand Babu Periasamy 14 years ago
committed by Philipp Hagemeister
parent
commit
20e91e8375
1 changed files with 24 additions and 4 deletions
  1. +24
    -4
      youtube-dl

+ 24
- 4
youtube-dl View File

@ -438,6 +438,8 @@ class FileDownloader(object):
noprogress: Do not print the progress bar.
playliststart: Playlist item to start at.
playlistend: Playlist item to end at.
matchtitle: Download only matching titles.
rejecttitle: Reject downloads for matching titles.
logtostderr: Log messages to stderr instead of stdout.
consoletitle: Display progress in console window's titlebar.
nopart: Do not use temporary .part files.
@ -713,6 +715,17 @@ class FileDownloader(object):
if filename is None:
return
matchtitle=self.params.get('matchtitle',False)
rejecttitle=self.params.get('rejecttitle',False)
title=info_dict['title'].encode(preferredencoding(), 'xmlcharrefreplace')
if matchtitle and not re.search(matchtitle, title, re.IGNORECASE):
self.to_screen(u'[download] "%s" title did not match pattern "%s"' % (title, matchtitle))
return
if rejecttitle and re.search(rejecttitle, title, re.IGNORECASE):
self.to_screen(u'[download] "%s" title matched reject pattern "%s"' % (title, rejecttitle))
return
if self.params.get('nooverwrites', False) and os.path.exists(filename):
self.to_stderr(u'WARNING: file exists and will be skipped')
return
@ -3487,6 +3500,7 @@ def parseOpts():
# option groups
general = optparse.OptionGroup(parser, 'General Options')
selection = optparse.OptionGroup(parser, 'Video Selection')
authentication = optparse.OptionGroup(parser, 'Authentication Options')
video_format = optparse.OptionGroup(parser, 'Video Format Options')
postproc = optparse.OptionGroup(parser, 'Post-processing Options')
@ -3505,14 +3519,17 @@ def parseOpts():
dest='ratelimit', metavar='LIMIT', help='download rate limit (e.g. 50k or 44.6m)')
general.add_option('-R', '--retries',
dest='retries', metavar='RETRIES', help='number of retries (default is 10)', default=10)
general.add_option('--playlist-start',
dest='playliststart', metavar='NUMBER', help='playlist video to start at (default is 1)', default=1)
general.add_option('--playlist-end',
dest='playlistend', metavar='NUMBER', help='playlist video to end at (default is last)', default=-1)
general.add_option('--dump-user-agent',
action='store_true', dest='dump_user_agent',
help='display the current browser identification', default=False)
selection.add_option('--playlist-start',
dest='playliststart', metavar='NUMBER', help='playlist video to start at (default is 1)', default=1)
selection.add_option('--playlist-end',
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)')
authentication.add_option('-u', '--username',
dest='username', metavar='USERNAME', help='account username')
authentication.add_option('-p', '--password',
@ -3590,6 +3607,7 @@ def parseOpts():
parser.add_option_group(general)
parser.add_option_group(selection)
parser.add_option_group(filesystem)
parser.add_option_group(verbosity)
parser.add_option_group(video_format)
@ -3742,6 +3760,8 @@ def main():
'updatetime': opts.updatetime,
'writedescription': opts.writedescription,
'writeinfojson': opts.writeinfojson,
'matchtitle': opts.matchtitle,
'rejecttitle': opts.rejecttitle,
})
for extractor in extractors:
fd.add_info_extractor(extractor)


Loading…
Cancel
Save