Other approach

pull/13821/head
sepro 4 weeks ago
parent a51e9b1eee
commit d47f7ba5eb

@ -562,6 +562,14 @@ def validate_options(opts):
f'{old} is deprecated and may be removed in a future version. Use {new} instead' if new
else f'{old} is deprecated and may not work as expected')
if hasattr(opts, 'sponskrub_options'):
for opt_str in opts.sponskrub_options:
deprecation_warnings.append(
f'SponSkrub support has been removed from yt-dlp, but "{opt_str}" was passed.\n'
'Please use SponsorBlock instead and remove all SponSkrub-related options from your commands and config files.\n'
'These options will be removed in a future version, which will cause errors if not updated.')
del opts.sponskrub_options
report_deprecation(not opts.prefer_ffmpeg, '--prefer-avconv', 'ffmpeg')
# report_deprecation(opts.include_ads, '--include-ads') # We may re-implement this in future
# report_deprecation(opts.call_home, '--call-home') # We may re-implement this in future

@ -1901,21 +1901,20 @@ def create_parser():
help='SponsorBlock API location, defaults to %default')
sponskrub_switches = [
'--sponskrub', '--no-sponskrub', '--sponskrub-cut', '--sponskrub-force', '--no-sponskrub-force']
'--sponskrub', '--no-sponskrub', '--sponskrub-cut', '--no-sponskrub-cut',
'--sponskrub-force', '--no-sponskrub-force']
sponskrub_arguments = ['--sponskrub-location', '--sponskrub-args']
def sponskrub_deprecation(option, opt_str, value, parser):
deprecation_warning(
f'SponSkrub support has been removed from yt-dlp, but "{opt_str}" was passed.\n'
'Please use SponsorBlock instead and remove all SponSkrub-related options from your commands and config files.\n'
'These options will be removed in a future version, which will cause errors if not updated.\n', expected=True)
def _sponskrub_deprecation(option, opt_str, value, parser):
current = getattr(parser.values, 'sponskrub_options', [])
parser.values.sponskrub_options = [*current, opt_str]
for switch in sponskrub_switches:
sponsorblock.add_option(
switch, action='callback', callback=sponskrub_deprecation, help=optparse.SUPPRESS_HELP)
switch, action='callback', callback=_sponskrub_deprecation, help=optparse.SUPPRESS_HELP)
for opt in sponskrub_arguments:
sponsorblock.add_option(
opt, action='callback', type='str', callback=sponskrub_deprecation, help=optparse.SUPPRESS_HELP)
opt, action='callback', type='str', callback=_sponskrub_deprecation, help=optparse.SUPPRESS_HELP)
extractor = optparse.OptionGroup(parser, 'Extractor Options')
extractor.add_option(

@ -1487,15 +1487,14 @@ def write_string(s, out=None, encoding=None):
# TODO: Use global logger
def deprecation_warning(msg, *, printer=None, stacklevel=0, expected=False, **kwargs):
def deprecation_warning(msg, *, printer=None, stacklevel=0, **kwargs):
if IN_CLI.value:
if msg in deprecation_warning._cache:
return
deprecation_warning._cache.add(msg)
full_message = f'{msg}{"" if expected else bug_reports_message()}'
if printer:
return printer(f'{full_message}', **kwargs)
return write_string(f'ERROR: {full_message}\n', **kwargs)
return printer(f'{msg}{bug_reports_message()}', **kwargs)
return write_string(f'ERROR: {msg}{bug_reports_message()}\n', **kwargs)
else:
import warnings
warnings.warn(DeprecationWarning(msg), stacklevel=stacklevel + 3)

Loading…
Cancel
Save