allow multiple --reject-title and --match-title options
This commit is contained in:
parent
4c6b4764f0
commit
2c72a8b489
@ -596,12 +596,15 @@ class YoutubeDL(object):
|
||||
title = info_dict['title']
|
||||
matchtitle = self.params.get('matchtitle', False)
|
||||
if matchtitle:
|
||||
if not re.search(matchtitle, title, re.IGNORECASE):
|
||||
return '"' + title + '" title did not match pattern "' + matchtitle + '"'
|
||||
rejecttitle = self.params.get('rejecttitle', False)
|
||||
if rejecttitle:
|
||||
if re.search(rejecttitle, title, re.IGNORECASE):
|
||||
return '"' + title + '" title matched reject pattern "' + rejecttitle + '"'
|
||||
for pattern in matchtitle:
|
||||
if re.search(patten, title, re.IGNORECASE):
|
||||
break
|
||||
else:
|
||||
return '"' + title + '" title did not match patterns "' + ', '.join(matchtitle) + '"'
|
||||
rejecttitle = self.params.get('rejecttitle', [])
|
||||
for pattern in rejecttitle:
|
||||
if re.search(pattern, title, re.IGNORECASE):
|
||||
return '"' + title + '" title matched reject pattern "' + pattern + '"'
|
||||
date = info_dict.get('upload_date', None)
|
||||
if date is not None:
|
||||
dateRange = self.params.get('daterange', DateRange())
|
||||
|
@ -25,6 +25,7 @@ from .compat import (
|
||||
from .utils import (
|
||||
DateRange,
|
||||
decodeOption,
|
||||
decodeOptions,
|
||||
DEFAULT_OUTTMPL,
|
||||
DownloadError,
|
||||
match_filter_func,
|
||||
@ -324,8 +325,8 @@ def _real_main(argv=None):
|
||||
'listsubtitles': opts.listsubtitles,
|
||||
'subtitlesformat': opts.subtitlesformat,
|
||||
'subtitleslangs': opts.subtitleslangs,
|
||||
'matchtitle': decodeOption(opts.matchtitle),
|
||||
'rejecttitle': decodeOption(opts.rejecttitle),
|
||||
'matchtitle': decodeOptions(opts.matchtitle),
|
||||
'rejecttitle': decodeOptions(opts.rejecttitle),
|
||||
'max_downloads': opts.max_downloads,
|
||||
'prefer_free_formats': opts.prefer_free_formats,
|
||||
'verbose': opts.verbose,
|
||||
|
@ -222,11 +222,11 @@ def parseOpts(overrideArguments=None):
|
||||
help='Playlist video items to download. Specify indices of the videos in the playlist separated by commas like: "--playlist-items 1,2,5,8" if you want to download videos indexed 1, 2, 5, 8 in the playlist. You can specify range: "--playlist-items 1-3,7,10-13", it will download the videos at index 1, 2, 3, 7, 10, 11, 12 and 13.')
|
||||
selection.add_option(
|
||||
'--match-title',
|
||||
dest='matchtitle', metavar='REGEX',
|
||||
action='append', dest='matchtitle', metavar='REGEX',
|
||||
help='Download only matching titles (regex or caseless sub-string)')
|
||||
selection.add_option(
|
||||
'--reject-title',
|
||||
dest='rejecttitle', metavar='REGEX',
|
||||
action='append', dest='rejecttitle', metavar='REGEX',
|
||||
help='Skip download for matching titles (regex or caseless sub-string)')
|
||||
selection.add_option(
|
||||
'--max-downloads',
|
||||
|
@ -487,6 +487,10 @@ def decodeOption(optval):
|
||||
assert isinstance(optval, compat_str)
|
||||
return optval
|
||||
|
||||
def decodeOptions(optvals):
|
||||
if optvals is None:
|
||||
return optvals
|
||||
return list(filter(lambda o: o, map(decodeOption, optvals)))
|
||||
|
||||
def formatSeconds(secs):
|
||||
if secs > 3600:
|
||||
|
Loading…
x
Reference in New Issue
Block a user