mirror of
https://github.com/l1ving/youtube-dl
synced 2025-01-24 14:32:54 +08:00
Added new parameters --match-uploader and --reject-uploader
This commit is contained in:
parent
3021cf83b7
commit
acd37b0bc5
@ -163,6 +163,8 @@ class YoutubeDL(object):
|
|||||||
playlistrandom: Download playlist items in random order.
|
playlistrandom: Download playlist items in random order.
|
||||||
matchtitle: Download only matching titles.
|
matchtitle: Download only matching titles.
|
||||||
rejecttitle: Reject downloads for matching titles.
|
rejecttitle: Reject downloads for matching titles.
|
||||||
|
matchuploader: Download only matchin uploader.
|
||||||
|
rejectuploader: Reject downloads for matching uploader.
|
||||||
logger: Log messages to a logging.Logger instance.
|
logger: Log messages to a logging.Logger instance.
|
||||||
logtostderr: Log messages to stderr instead of stdout.
|
logtostderr: Log messages to stderr instead of stdout.
|
||||||
writedescription: Write the video description to a .description file
|
writedescription: Write the video description to a .description file
|
||||||
@ -620,7 +622,7 @@ class YoutubeDL(object):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def _match_entry(self, info_dict, incomplete):
|
def _match_entry(self, info_dict, incomplete):
|
||||||
""" Returns None iff the file should be downloaded """
|
""" Returns None if the file should be downloaded """
|
||||||
|
|
||||||
video_title = info_dict.get('title', info_dict.get('id', 'video'))
|
video_title = info_dict.get('title', info_dict.get('id', 'video'))
|
||||||
if 'title' in info_dict:
|
if 'title' in info_dict:
|
||||||
@ -634,11 +636,25 @@ class YoutubeDL(object):
|
|||||||
if rejecttitle:
|
if rejecttitle:
|
||||||
if re.search(rejecttitle, title, re.IGNORECASE):
|
if re.search(rejecttitle, title, re.IGNORECASE):
|
||||||
return '"' + title + '" title matched reject pattern "' + rejecttitle + '"'
|
return '"' + title + '" title matched reject pattern "' + rejecttitle + '"'
|
||||||
|
|
||||||
|
if 'uploader' in info_dict:
|
||||||
|
# This can happen when we're just evaluating the playlist
|
||||||
|
uploader = info_dict['uploader']
|
||||||
|
matchuploader = self.params.get('matchuploader', False)
|
||||||
|
if matchuploader:
|
||||||
|
if not re.search(matchuploader, uploader, re.IGNORECASE):
|
||||||
|
return '"' + uploader + '" uploader did not match pattern "' + matchuploader + '"'
|
||||||
|
rejectuploader = self.params.get('rejectuploader', False)
|
||||||
|
if rejectuploader:
|
||||||
|
if re.search(rejectuploader, uploader, re.IGNORECASE):
|
||||||
|
return '"' + uploader + '" uploader matched reject pattern "' + rejectuploader + '"'
|
||||||
|
|
||||||
date = info_dict.get('upload_date')
|
date = info_dict.get('upload_date')
|
||||||
if date is not None:
|
if date is not None:
|
||||||
dateRange = self.params.get('daterange', DateRange())
|
dateRange = self.params.get('daterange', DateRange())
|
||||||
if date not in dateRange:
|
if date not in dateRange:
|
||||||
return '%s upload date is not in range %s' % (date_from_str(date).isoformat(), dateRange)
|
return '%s upload date is not in range %s' % (date_from_str(date).isoformat(), dateRange)
|
||||||
|
|
||||||
view_count = info_dict.get('view_count')
|
view_count = info_dict.get('view_count')
|
||||||
if view_count is not None:
|
if view_count is not None:
|
||||||
min_views = self.params.get('min_views')
|
min_views = self.params.get('min_views')
|
||||||
@ -647,8 +663,10 @@ class YoutubeDL(object):
|
|||||||
max_views = self.params.get('max_views')
|
max_views = self.params.get('max_views')
|
||||||
if max_views is not None and view_count > max_views:
|
if max_views is not None and view_count > max_views:
|
||||||
return 'Skipping %s, because it has exceeded the maximum view count (%d/%d)' % (video_title, view_count, max_views)
|
return 'Skipping %s, because it has exceeded the maximum view count (%d/%d)' % (video_title, view_count, max_views)
|
||||||
|
|
||||||
if age_restricted(info_dict.get('age_limit'), self.params.get('age_limit')):
|
if age_restricted(info_dict.get('age_limit'), self.params.get('age_limit')):
|
||||||
return 'Skipping "%s" because it is age restricted' % video_title
|
return 'Skipping "%s" because it is age restricted' % video_title
|
||||||
|
|
||||||
if self.in_download_archive(info_dict):
|
if self.in_download_archive(info_dict):
|
||||||
return '%s has already been recorded in archive' % video_title
|
return '%s has already been recorded in archive' % video_title
|
||||||
|
|
||||||
|
@ -363,6 +363,8 @@ def _real_main(argv=None):
|
|||||||
'subtitleslangs': opts.subtitleslangs,
|
'subtitleslangs': opts.subtitleslangs,
|
||||||
'matchtitle': decodeOption(opts.matchtitle),
|
'matchtitle': decodeOption(opts.matchtitle),
|
||||||
'rejecttitle': decodeOption(opts.rejecttitle),
|
'rejecttitle': decodeOption(opts.rejecttitle),
|
||||||
|
'matchuploader': decodeOption(opts.matchuploader),
|
||||||
|
'rejectuploader': decodeOption(opts.rejectuploader),
|
||||||
'max_downloads': opts.max_downloads,
|
'max_downloads': opts.max_downloads,
|
||||||
'prefer_free_formats': opts.prefer_free_formats,
|
'prefer_free_formats': opts.prefer_free_formats,
|
||||||
'verbose': opts.verbose,
|
'verbose': opts.verbose,
|
||||||
|
@ -261,6 +261,14 @@ def parseOpts(overrideArguments=None):
|
|||||||
'--reject-title',
|
'--reject-title',
|
||||||
dest='rejecttitle', metavar='REGEX',
|
dest='rejecttitle', metavar='REGEX',
|
||||||
help='Skip download for matching titles (regex or caseless sub-string)')
|
help='Skip download for matching titles (regex or caseless sub-string)')
|
||||||
|
selection.add_option(
|
||||||
|
'--match-uploader',
|
||||||
|
dest='matchuploader', metavar='REGEX',
|
||||||
|
help='Download only matching uploader (regex or caseless sub-string)')
|
||||||
|
selection.add_option(
|
||||||
|
'--reject-uploader',
|
||||||
|
dest='rejectuploader', metavar='REGEX',
|
||||||
|
help='Skip download for matching uploader (regex or caseless sub-string)')
|
||||||
selection.add_option(
|
selection.add_option(
|
||||||
'--max-downloads',
|
'--max-downloads',
|
||||||
dest='max_downloads', metavar='NUMBER', type=int, default=None,
|
dest='max_downloads', metavar='NUMBER', type=int, default=None,
|
||||||
|
Loading…
Reference in New Issue
Block a user