expand_path,
match_filter_func,
MaxDownloadsReached,
+ parse_duration,
preferredencoding,
read_batch_urls,
RejectedVideoReached,
desc = getattr(ie, 'IE_DESC', ie.IE_NAME)
if desc is False:
continue
- if hasattr(ie, 'SEARCH_KEY'):
+ if getattr(ie, 'SEARCH_KEY', None) is not None:
_SEARCHES = ('cute kittens', 'slithering pythons', 'falling cat', 'angry poodle', 'purple fish', 'running tortoise', 'sleeping bunny', 'burping cow')
_COUNTS = ('', '5', '10', 'all')
- desc += ' (Example: "%s%s:%s" )' % (ie.SEARCH_KEY, random.choice(_COUNTS), random.choice(_SEARCHES))
+ desc += f'; "{ie.SEARCH_KEY}:" prefix (Example: "{ie.SEARCH_KEY}{random.choice(_COUNTS)}:{random.choice(_SEARCHES)}")'
write_string(desc + '\n', out=sys.stdout)
sys.exit(0)
if opts.ap_list_mso:
compat_opts = opts.compat_opts
+ def report_conflict(arg1, arg2):
+ warnings.append(f'{arg2} is ignored since {arg1} was given')
+
def _unused_compat_opt(name):
if name not in compat_opts:
return False
if _video_multistreams_set is False and _audio_multistreams_set is False:
_unused_compat_opt('multistreams')
outtmpl_default = opts.outtmpl.get('default')
+ if opts.useid:
+ if outtmpl_default is None:
+ outtmpl_default = opts.outtmpl['default'] = '%(id)s.%(ext)s'
+ else:
+ report_conflict('--output', '--id')
if 'filename' in compat_opts:
if outtmpl_default is None:
- outtmpl_default = '%(title)s-%(id)s.%(ext)s'
- opts.outtmpl.update({'default': outtmpl_default})
+ outtmpl_default = opts.outtmpl['default'] = '%(title)s-%(id)s.%(ext)s'
else:
_unused_compat_opt('filename')
parser.error('invalid %s %r: %s' % (msg, tmpl, error_to_compat_str(err)))
for k, tmpl in opts.outtmpl.items():
- validate_outtmpl(tmpl, '%s output template' % k)
+ validate_outtmpl(tmpl, f'{k} output template')
opts.forceprint = opts.forceprint or []
for tmpl in opts.forceprint or []:
validate_outtmpl(tmpl, 'print template')
validate_outtmpl(opts.sponsorblock_chapter_title, 'SponsorBlock chapter title')
+ for k, tmpl in opts.progress_template.items():
+ k = f'{k[:-6]} console title' if '-title' in k else f'{k} progress'
+ validate_outtmpl(tmpl, f'{k} template')
if opts.extractaudio and not opts.keepvideo and opts.format is None:
opts.format = 'bestaudio/best'
opts.addchapters = True
opts.remove_chapters = opts.remove_chapters or []
- def report_conflict(arg1, arg2):
- warnings.append('%s is ignored since %s was given' % (arg2, arg1))
-
if (opts.remove_chapters or sponsorblock_query) and opts.sponskrub is not False:
if opts.sponskrub:
if opts.remove_chapters:
opts.sponskrub = False
# PostProcessors
- postprocessors = []
+ postprocessors = list(opts.add_postprocessors)
if sponsorblock_query:
postprocessors.append({
'key': 'SponsorBlock',
if opts.allsubtitles and not opts.writeautomaticsub:
opts.writesubtitles = True
# ModifyChapters must run before FFmpegMetadataPP
- remove_chapters_patterns = []
+ remove_chapters_patterns, remove_ranges = [], []
for regex in opts.remove_chapters:
+ if regex.startswith('*'):
+ dur = list(map(parse_duration, regex[1:].split('-')))
+ if len(dur) == 2 and all(t is not None for t in dur):
+ remove_ranges.append(tuple(dur))
+ continue
+ parser.error(f'invalid --remove-chapters time range {regex!r}. Must be of the form ?start-end')
try:
remove_chapters_patterns.append(re.compile(regex))
except re.error as err:
'key': 'ModifyChapters',
'remove_chapters_patterns': remove_chapters_patterns,
'remove_sponsor_segments': opts.sponsorblock_remove,
+ 'remove_ranges': remove_ranges,
'sponsorblock_chapter_title': opts.sponsorblock_chapter_title,
'force_keyframes': opts.force_keyframes_at_cuts
})
'add_chapters': opts.addchapters,
'add_metadata': opts.addmetadata,
})
+ # Note: Deprecated
# This should be above EmbedThumbnail since sponskrub removes the thumbnail attachment
# but must be below EmbedSubtitle and FFmpegMetadata
# See https://github.com/yt-dlp/yt-dlp/issues/204 , https://github.com/faissaloo/SponSkrub/issues/29
})
if not already_have_thumbnail:
opts.writethumbnail = True
+ opts.outtmpl['pl_thumbnail'] = ''
if opts.split_chapters:
postprocessors.append({
'key': 'FFmpegSplitChapters',
'noresizebuffer': opts.noresizebuffer,
'http_chunk_size': opts.http_chunk_size,
'continuedl': opts.continue_dl,
- 'noprogress': opts.noprogress,
+ 'noprogress': opts.quiet if opts.noprogress is None else opts.noprogress,
'progress_with_newline': opts.progress_with_newline,
+ 'progress_template': opts.progress_template,
'playliststart': opts.playliststart,
'playlistend': opts.playlistend,
'playlistreverse': opts.playlist_reverse,
'geo_bypass': opts.geo_bypass,
'geo_bypass_country': opts.geo_bypass_country,
'geo_bypass_ip_block': opts.geo_bypass_ip_block,
- 'warnings': warnings,
+ '_warnings': warnings,
'compat_opts': compat_opts,
- # just for deprecation check
- 'autonumber': opts.autonumber or None,
- 'usetitle': opts.usetitle or None,
- 'useid': opts.useid or None,
}
with YoutubeDL(ydl_opts) as ydl: