mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-02 01:02:48 +01:00
[cleanup] Add deprecation warnings
This commit is contained in:
parent
f304da8a29
commit
ee8dd27a73
@ -566,6 +566,8 @@ def check_deprecated(param, option, suggestion):
|
|||||||
|
|
||||||
for msg in self.params.get('_warnings', []):
|
for msg in self.params.get('_warnings', []):
|
||||||
self.report_warning(msg)
|
self.report_warning(msg)
|
||||||
|
for msg in self.params.get('_deprecation_warnings', []):
|
||||||
|
self.deprecation_warning(msg)
|
||||||
|
|
||||||
if 'list-formats' in self.params.get('compat_opts', []):
|
if 'list-formats' in self.params.get('compat_opts', []):
|
||||||
self.params['listformats_table'] = False
|
self.params['listformats_table'] = False
|
||||||
@ -886,6 +888,12 @@ def report_warning(self, message, only_once=False):
|
|||||||
return
|
return
|
||||||
self.to_stderr(f'{self._format_err("WARNING:", self.Styles.WARNING)} {message}', only_once)
|
self.to_stderr(f'{self._format_err("WARNING:", self.Styles.WARNING)} {message}', only_once)
|
||||||
|
|
||||||
|
def deprecation_warning(self, message):
|
||||||
|
if self.params.get('logger') is not None:
|
||||||
|
self.params['logger'].warning('DeprecationWarning: {message}')
|
||||||
|
else:
|
||||||
|
self.to_stderr(f'{self._format_err("DeprecationWarning:", self.Styles.ERROR)} {message}', True)
|
||||||
|
|
||||||
def report_error(self, message, tb=None):
|
def report_error(self, message, tb=None):
|
||||||
'''
|
'''
|
||||||
Do the same as trouble, but prefixes the message with 'ERROR:', colored
|
Do the same as trouble, but prefixes the message with 'ERROR:', colored
|
||||||
|
@ -71,7 +71,7 @@ def _real_main(argv=None):
|
|||||||
setproctitle('yt-dlp')
|
setproctitle('yt-dlp')
|
||||||
|
|
||||||
parser, opts, args = parseOpts(argv)
|
parser, opts, args = parseOpts(argv)
|
||||||
warnings = []
|
warnings, deprecation_warnings = [], []
|
||||||
|
|
||||||
# Set user agent
|
# Set user agent
|
||||||
if opts.user_agent is not None:
|
if opts.user_agent is not None:
|
||||||
@ -536,7 +536,7 @@ def report_unplayable_conflict(opt_name, arg, default=False, allowed=None):
|
|||||||
'add_metadata': opts.addmetadata,
|
'add_metadata': opts.addmetadata,
|
||||||
'add_infojson': opts.embed_infojson,
|
'add_infojson': opts.embed_infojson,
|
||||||
})
|
})
|
||||||
# Note: Deprecated
|
# Deprecated
|
||||||
# This should be above EmbedThumbnail since sponskrub removes the thumbnail attachment
|
# This should be above EmbedThumbnail since sponskrub removes the thumbnail attachment
|
||||||
# but must be below EmbedSubtitle and FFmpegMetadata
|
# but must be below EmbedSubtitle and FFmpegMetadata
|
||||||
# See https://github.com/yt-dlp/yt-dlp/issues/204 , https://github.com/faissaloo/SponSkrub/issues/29
|
# See https://github.com/yt-dlp/yt-dlp/issues/204 , https://github.com/faissaloo/SponSkrub/issues/29
|
||||||
@ -549,6 +549,7 @@ def report_unplayable_conflict(opt_name, arg, default=False, allowed=None):
|
|||||||
'cut': opts.sponskrub_cut,
|
'cut': opts.sponskrub_cut,
|
||||||
'force': opts.sponskrub_force,
|
'force': opts.sponskrub_force,
|
||||||
'ignoreerror': opts.sponskrub is None,
|
'ignoreerror': opts.sponskrub is None,
|
||||||
|
'_from_cli': True,
|
||||||
})
|
})
|
||||||
if opts.embedthumbnail:
|
if opts.embedthumbnail:
|
||||||
already_have_thumbnail = opts.writethumbnail or opts.write_all_thumbnails
|
already_have_thumbnail = opts.writethumbnail or opts.write_all_thumbnails
|
||||||
@ -588,6 +589,19 @@ def report_args_compat(arg, name):
|
|||||||
opts.postprocessor_args.setdefault('sponskrub', [])
|
opts.postprocessor_args.setdefault('sponskrub', [])
|
||||||
opts.postprocessor_args['default'] = opts.postprocessor_args['default-compat']
|
opts.postprocessor_args['default'] = opts.postprocessor_args['default-compat']
|
||||||
|
|
||||||
|
def report_deprecation(val, old, new=None):
|
||||||
|
if not val:
|
||||||
|
return
|
||||||
|
deprecation_warnings.append(
|
||||||
|
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')
|
||||||
|
|
||||||
|
report_deprecation(opts.sponskrub, '--sponskrub', '--sponsorblock-mark or --sponsorblock-remove')
|
||||||
|
report_deprecation(not opts.prefer_ffmpeg, '--prefer-avconv', 'ffmpeg')
|
||||||
|
report_deprecation(opts.include_ads, '--include-ads')
|
||||||
|
# report_deprecation(opts.call_home, '--call-home') # We may re-implement this in future
|
||||||
|
# report_deprecation(opts.writeannotations, '--write-annotations') # It's just that no website has it
|
||||||
|
|
||||||
final_ext = (
|
final_ext = (
|
||||||
opts.recodevideo if opts.recodevideo in FFmpegVideoConvertorPP.SUPPORTED_EXTS
|
opts.recodevideo if opts.recodevideo in FFmpegVideoConvertorPP.SUPPORTED_EXTS
|
||||||
else opts.remuxvideo if opts.remuxvideo in FFmpegVideoRemuxerPP.SUPPORTED_EXTS
|
else opts.remuxvideo if opts.remuxvideo in FFmpegVideoRemuxerPP.SUPPORTED_EXTS
|
||||||
@ -756,6 +770,7 @@ def report_args_compat(arg, name):
|
|||||||
'geo_bypass_country': opts.geo_bypass_country,
|
'geo_bypass_country': opts.geo_bypass_country,
|
||||||
'geo_bypass_ip_block': opts.geo_bypass_ip_block,
|
'geo_bypass_ip_block': opts.geo_bypass_ip_block,
|
||||||
'_warnings': warnings,
|
'_warnings': warnings,
|
||||||
|
'_deprecation_warnings': deprecation_warnings,
|
||||||
'compat_opts': compat_opts,
|
'compat_opts': compat_opts,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1586,7 +1586,7 @@ class FormatSort:
|
|||||||
'res': {'type': 'multiple', 'field': ('height', 'width'),
|
'res': {'type': 'multiple', 'field': ('height', 'width'),
|
||||||
'function': lambda it: (lambda l: min(l) if l else 0)(tuple(filter(None, it)))},
|
'function': lambda it: (lambda l: min(l) if l else 0)(tuple(filter(None, it)))},
|
||||||
|
|
||||||
# Most of these exist only for compatibility reasons
|
# Deprecated
|
||||||
'dimension': {'type': 'alias', 'field': 'res'},
|
'dimension': {'type': 'alias', 'field': 'res'},
|
||||||
'resolution': {'type': 'alias', 'field': 'res'},
|
'resolution': {'type': 'alias', 'field': 'res'},
|
||||||
'extension': {'type': 'alias', 'field': 'ext'},
|
'extension': {'type': 'alias', 'field': 'ext'},
|
||||||
@ -1595,7 +1595,7 @@ class FormatSort:
|
|||||||
'video_bitrate': {'type': 'alias', 'field': 'vbr'},
|
'video_bitrate': {'type': 'alias', 'field': 'vbr'},
|
||||||
'audio_bitrate': {'type': 'alias', 'field': 'abr'},
|
'audio_bitrate': {'type': 'alias', 'field': 'abr'},
|
||||||
'framerate': {'type': 'alias', 'field': 'fps'},
|
'framerate': {'type': 'alias', 'field': 'fps'},
|
||||||
'language_preference': {'type': 'alias', 'field': 'lang'}, # not named as 'language' because such a field exists
|
'language_preference': {'type': 'alias', 'field': 'lang'},
|
||||||
'protocol': {'type': 'alias', 'field': 'proto'},
|
'protocol': {'type': 'alias', 'field': 'proto'},
|
||||||
'source_preference': {'type': 'alias', 'field': 'source'},
|
'source_preference': {'type': 'alias', 'field': 'source'},
|
||||||
'filesize_approx': {'type': 'alias', 'field': 'fs_approx'},
|
'filesize_approx': {'type': 'alias', 'field': 'fs_approx'},
|
||||||
@ -1624,6 +1624,11 @@ def __init__(self, ie, field_preference):
|
|||||||
|
|
||||||
def _get_field_setting(self, field, key):
|
def _get_field_setting(self, field, key):
|
||||||
if field not in self.settings:
|
if field not in self.settings:
|
||||||
|
if key in ('forced', 'priority'):
|
||||||
|
return False
|
||||||
|
self.ydl.deprecation_warning(
|
||||||
|
f'Using arbitrary fields ({field}) for format sorting is deprecated '
|
||||||
|
'and may be removed in a future version')
|
||||||
self.settings[field] = {}
|
self.settings[field] = {}
|
||||||
propObj = self.settings[field]
|
propObj = self.settings[field]
|
||||||
if key not in propObj:
|
if key not in propObj:
|
||||||
@ -1706,7 +1711,10 @@ def add_item(field, reverse, closest, limit_text):
|
|||||||
if field is None:
|
if field is None:
|
||||||
continue
|
continue
|
||||||
if self._get_field_setting(field, 'type') == 'alias':
|
if self._get_field_setting(field, 'type') == 'alias':
|
||||||
field = self._get_field_setting(field, 'field')
|
alias, field = field, self._get_field_setting(field, 'field')
|
||||||
|
self.ydl.deprecation_warning(
|
||||||
|
f'Format sorting alias {alias} is deprecated '
|
||||||
|
f'and may be removed in a future version. Please use {field} instead')
|
||||||
reverse = match.group('reverse') is not None
|
reverse = match.group('reverse') is not None
|
||||||
closest = match.group('separator') == '~'
|
closest = match.group('separator') == '~'
|
||||||
limit_text = match.group('limit')
|
limit_text = match.group('limit')
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
_configuration_args,
|
_configuration_args,
|
||||||
encodeFilename,
|
encodeFilename,
|
||||||
PostProcessingError,
|
PostProcessingError,
|
||||||
|
write_string,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -74,6 +75,11 @@ def report_warning(self, text, *args, **kwargs):
|
|||||||
if self._downloader:
|
if self._downloader:
|
||||||
return self._downloader.report_warning(text, *args, **kwargs)
|
return self._downloader.report_warning(text, *args, **kwargs)
|
||||||
|
|
||||||
|
def deprecation_warning(self, text):
|
||||||
|
if self._downloader:
|
||||||
|
return self._downloader.deprecation_warning(text)
|
||||||
|
write_string(f'DeprecationWarning: {text}')
|
||||||
|
|
||||||
def report_error(self, text, *args, **kwargs):
|
def report_error(self, text, *args, **kwargs):
|
||||||
# Exists only for compatibility. Do not use
|
# Exists only for compatibility. Do not use
|
||||||
if self._downloader:
|
if self._downloader:
|
||||||
|
@ -38,5 +38,10 @@ def run(self, info):
|
|||||||
return [], info
|
return [], info
|
||||||
|
|
||||||
|
|
||||||
class ExecAfterDownloadPP(ExecPP): # for backward compatibility
|
# Deprecated
|
||||||
pass
|
class ExecAfterDownloadPP(ExecPP):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.deprecation_warning(
|
||||||
|
'yt_dlp.postprocessor.ExecAfterDownloadPP is deprecated '
|
||||||
|
'and may be removed in a future version. Use yt_dlp.postprocessor.ExecPP instead')
|
||||||
|
@ -167,6 +167,13 @@ def get_ffmpeg_version(path, prog):
|
|||||||
self.probe_basename = p
|
self.probe_basename = p
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if self.basename == 'avconv':
|
||||||
|
self.deprecation_warning(
|
||||||
|
'Support for avconv is deprecated and may be removed in a future version. Use ffmpeg instead')
|
||||||
|
if self.probe_basename == 'avprobe':
|
||||||
|
self.deprecation_warning(
|
||||||
|
'Support for avprobe is deprecated and may be removed in a future version. Use ffprobe instead')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self):
|
||||||
return self.basename is not None
|
return self.basename is not None
|
||||||
|
@ -96,6 +96,7 @@ def f(info):
|
|||||||
return f
|
return f
|
||||||
|
|
||||||
|
|
||||||
|
# Deprecated
|
||||||
class MetadataFromFieldPP(MetadataParserPP):
|
class MetadataFromFieldPP(MetadataParserPP):
|
||||||
@classmethod
|
@classmethod
|
||||||
def to_action(cls, f):
|
def to_action(cls, f):
|
||||||
@ -108,9 +109,16 @@ def to_action(cls, f):
|
|||||||
match.group('out'))
|
match.group('out'))
|
||||||
|
|
||||||
def __init__(self, downloader, formats):
|
def __init__(self, downloader, formats):
|
||||||
MetadataParserPP.__init__(self, downloader, [self.to_action(f) for f in formats])
|
super().__init__(self, downloader, [self.to_action(f) for f in formats])
|
||||||
|
self.deprecation_warning(
|
||||||
|
'yt_dlp.postprocessor.MetadataFromFieldPP is deprecated '
|
||||||
|
'and may be removed in a future version. Use yt_dlp.postprocessor.MetadataParserPP instead')
|
||||||
|
|
||||||
|
|
||||||
class MetadataFromTitlePP(MetadataParserPP): # for backward compatibility
|
# Deprecated
|
||||||
|
class MetadataFromTitlePP(MetadataParserPP):
|
||||||
def __init__(self, downloader, titleformat):
|
def __init__(self, downloader, titleformat):
|
||||||
MetadataParserPP.__init__(self, downloader, [(self.Actions.INTERPRET, 'title', titleformat)])
|
super().__init__(self, downloader, [(self.Actions.INTERPRET, 'title', titleformat)])
|
||||||
|
self.deprecation_warning(
|
||||||
|
'yt_dlp.postprocessor.MetadataFromTitlePP is deprecated '
|
||||||
|
'and may be removed in a future version. Use yt_dlp.postprocessor.MetadataParserPP instead')
|
||||||
|
@ -22,13 +22,18 @@ class SponSkrubPP(PostProcessor):
|
|||||||
_temp_ext = 'spons'
|
_temp_ext = 'spons'
|
||||||
_exe_name = 'sponskrub'
|
_exe_name = 'sponskrub'
|
||||||
|
|
||||||
def __init__(self, downloader, path='', args=None, ignoreerror=False, cut=False, force=False):
|
def __init__(self, downloader, path='', args=None, ignoreerror=False, cut=False, force=False, _from_cli=False):
|
||||||
PostProcessor.__init__(self, downloader)
|
PostProcessor.__init__(self, downloader)
|
||||||
self.force = force
|
self.force = force
|
||||||
self.cutout = cut
|
self.cutout = cut
|
||||||
self.args = str_or_none(args) or '' # For backward compatibility
|
self.args = str_or_none(args) or '' # For backward compatibility
|
||||||
self.path = self.get_exe(path)
|
self.path = self.get_exe(path)
|
||||||
|
|
||||||
|
if not _from_cli:
|
||||||
|
self.deprecation_warning(
|
||||||
|
'yt_dlp.postprocessor.SponSkrubPP support is deprecated and may be removed in a future version. '
|
||||||
|
'Use yt_dlp.postprocessor.SponsorBlock and yt_dlp.postprocessor.ModifyChaptersPP instead')
|
||||||
|
|
||||||
if not ignoreerror and self.path is None:
|
if not ignoreerror and self.path is None:
|
||||||
if path:
|
if path:
|
||||||
raise PostProcessingError('sponskrub not found in "%s"' % path)
|
raise PostProcessingError('sponskrub not found in "%s"' % path)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
from zipimport import zipimporter
|
from zipimport import zipimporter
|
||||||
|
|
||||||
from .compat import compat_realpath
|
from .compat import compat_realpath
|
||||||
from .utils import encode_compat_str, Popen
|
from .utils import encode_compat_str, Popen, write_string
|
||||||
|
|
||||||
from .version import __version__
|
from .version import __version__
|
||||||
|
|
||||||
@ -251,13 +251,13 @@ def print_notes(to_screen, versions, fromVersion=__version__):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
# Deprecated
|
||||||
def update_self(to_screen, verbose, opener):
|
def update_self(to_screen, verbose, opener):
|
||||||
''' Exists for backward compatibility '''
|
|
||||||
|
|
||||||
printfn = to_screen
|
printfn = to_screen
|
||||||
|
|
||||||
printfn(
|
write_string(
|
||||||
'WARNING: "yt_dlp.update.update_self" is deprecated and may be removed in a future version. '
|
'DeprecationWarning: "yt_dlp.update.update_self" is deprecated and may be removed in a future version. '
|
||||||
'Use "yt_dlp.update.run_update(ydl)" instead')
|
'Use "yt_dlp.update.run_update(ydl)" instead')
|
||||||
|
|
||||||
class FakeYDL():
|
class FakeYDL():
|
||||||
|
@ -6552,10 +6552,11 @@ def _traverse_obj(obj, path, _current_depth=0):
|
|||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
||||||
|
# Deprecated
|
||||||
def traverse_dict(dictn, keys, casesense=True):
|
def traverse_dict(dictn, keys, casesense=True):
|
||||||
''' For backward compatibility. Do not use '''
|
write_string('DeprecationWarning: yt_dlp.utils.traverse_dict is deprecated '
|
||||||
return traverse_obj(dictn, keys, casesense=casesense,
|
'and may be removed in a future version. Use yt_dlp.utils.traverse_obj instead')
|
||||||
is_user_input=True, traverse_string=True)
|
return traverse_obj(dictn, keys, casesense=casesense, is_user_input=True, traverse_string=True)
|
||||||
|
|
||||||
|
|
||||||
def variadic(x, allowed_types=(str, bytes)):
|
def variadic(x, allowed_types=(str, bytes)):
|
||||||
|
Loading…
Reference in New Issue
Block a user