mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-26 09:11:25 +01:00
Compare commits
3 Commits
b525b65888
...
0e5df74a73
Author | SHA1 | Date | |
---|---|---|---|
|
0e5df74a73 | ||
|
0753efd8aa | ||
|
2a9eb9b3bc |
|
@ -304,13 +304,25 @@ banned-from = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.ruff.lint.flake8-tidy-imports.banned-api]
|
[tool.ruff.lint.flake8-tidy-imports.banned-api]
|
||||||
|
"yt_dlp.compat.compat_str".msg = "Use `str` instead."
|
||||||
|
"yt_dlp.compat.compat_b64decode".msg = "Use `base64.b64decode` instead."
|
||||||
|
"yt_dlp.compat.compat_urlparse".msg = "Use `urllib.parse` instead."
|
||||||
|
"yt_dlp.compat.compat_parse_qs".msg = "Use `urllib.parse.parse_qs` instead."
|
||||||
|
"yt_dlp.compat.compat_urllib_parse_unquote".msg = "Use `urllib.parse.unquote` instead."
|
||||||
|
"yt_dlp.compat.compat_urllib_parse_urlencode".msg = "Use `urllib.parse.urlencode` instead."
|
||||||
|
"yt_dlp.compat.compat_urllib_parse_urlparse".msg = "Use `urllib.parse.urlparse` instead."
|
||||||
|
"yt_dlp.compat.compat_shlex_quote".msg = "Use `yt_dlp.utils.shell_quote` instead."
|
||||||
|
"yt_dlp.utils.error_to_compat_str".msg = "Use `str` instead."
|
||||||
|
"yt_dlp.utils.bytes_to_intlist".msg = "Use `list` instead."
|
||||||
|
"yt_dlp.utils.intlist_to_bytes".msg = "Use `bytes` instead."
|
||||||
|
"yt_dlp.utils.decodeArgument".msg = "Do not use"
|
||||||
|
"yt_dlp.utils.decodeFilename".msg = "Do not use"
|
||||||
|
"yt_dlp.utils.encodeFilename".msg = "Do not use"
|
||||||
"yt_dlp.compat.compat_os_name".msg = "Use `os.name` instead."
|
"yt_dlp.compat.compat_os_name".msg = "Use `os.name` instead."
|
||||||
"yt_dlp.compat.compat_realpath".msg = "Use `os.path.realpath` instead."
|
"yt_dlp.compat.compat_realpath".msg = "Use `os.path.realpath` instead."
|
||||||
"yt_dlp.compat.compat_shlex_quote".msg = "Use `yt_dlp.utils.shell_quote` instead."
|
|
||||||
"yt_dlp.compat.functools".msg = "Use `functools` instead."
|
"yt_dlp.compat.functools".msg = "Use `functools` instead."
|
||||||
"yt_dlp.utils.bytes_to_intlist".msg = "Use `list` instead."
|
"yt_dlp.utils.decodeOption".msg = "Do not use"
|
||||||
"yt_dlp.utils.compiled_regex_type".msg = "Use `re.Pattern` instead."
|
"yt_dlp.utils.compiled_regex_type".msg = "Use `re.Pattern` instead."
|
||||||
"yt_dlp.utils.intlist_to_bytes".msg = "Use `bytes` instead."
|
|
||||||
|
|
||||||
[tool.autopep8]
|
[tool.autopep8]
|
||||||
max_line_length = 120
|
max_line_length = 120
|
||||||
|
|
|
@ -200,8 +200,6 @@ class UpdateInfo:
|
||||||
binary_name: str | None = _get_binary_name() # noqa: RUF009: Always returns the same value
|
binary_name: str | None = _get_binary_name() # noqa: RUF009: Always returns the same value
|
||||||
checksum: str | None = None
|
checksum: str | None = None
|
||||||
|
|
||||||
_has_update = True
|
|
||||||
|
|
||||||
|
|
||||||
class Updater:
|
class Updater:
|
||||||
# XXX: use class variables to simplify testing
|
# XXX: use class variables to simplify testing
|
||||||
|
@ -561,62 +559,14 @@ class Updater:
|
||||||
f'Unable to {action}{delim} visit '
|
f'Unable to {action}{delim} visit '
|
||||||
f'https://github.com/{self.requested_repo}/releases/{path}', True)
|
f'https://github.com/{self.requested_repo}/releases/{path}', True)
|
||||||
|
|
||||||
# XXX: Everything below this line in this class is deprecated / for compat only
|
|
||||||
@property
|
|
||||||
def _target_tag(self):
|
|
||||||
"""Deprecated; requested tag with 'tags/' prepended when necessary for API calls"""
|
|
||||||
return f'tags/{self.requested_tag}' if self.requested_tag != 'latest' else self.requested_tag
|
|
||||||
|
|
||||||
def _check_update(self):
|
|
||||||
"""Deprecated; report whether there is an update available"""
|
|
||||||
return bool(self.query_update(_output=True))
|
|
||||||
|
|
||||||
def __getattr__(self, attribute: str):
|
|
||||||
"""Compat getter function for deprecated attributes"""
|
|
||||||
deprecated_props_map = {
|
|
||||||
'check_update': '_check_update',
|
|
||||||
'target_tag': '_target_tag',
|
|
||||||
'target_channel': 'requested_channel',
|
|
||||||
}
|
|
||||||
update_info_props_map = {
|
|
||||||
'has_update': '_has_update',
|
|
||||||
'new_version': 'version',
|
|
||||||
'latest_version': 'requested_version',
|
|
||||||
'release_name': 'binary_name',
|
|
||||||
'release_hash': 'checksum',
|
|
||||||
}
|
|
||||||
|
|
||||||
if attribute not in deprecated_props_map and attribute not in update_info_props_map:
|
|
||||||
raise AttributeError(f'{type(self).__name__!r} object has no attribute {attribute!r}')
|
|
||||||
|
|
||||||
msg = f'{type(self).__name__}.{attribute} is deprecated and will be removed in a future version'
|
|
||||||
if attribute in deprecated_props_map:
|
|
||||||
source_name = deprecated_props_map[attribute]
|
|
||||||
if not source_name.startswith('_'):
|
|
||||||
msg += f'. Please use {source_name!r} instead'
|
|
||||||
source = self
|
|
||||||
mapping = deprecated_props_map
|
|
||||||
|
|
||||||
else: # attribute in update_info_props_map
|
|
||||||
msg += '. Please call query_update() instead'
|
|
||||||
source = self.query_update()
|
|
||||||
if source is None:
|
|
||||||
source = UpdateInfo('', None, None, None)
|
|
||||||
source._has_update = False
|
|
||||||
mapping = update_info_props_map
|
|
||||||
|
|
||||||
deprecation_warning(msg)
|
|
||||||
for target_name, source_name in mapping.items():
|
|
||||||
value = getattr(source, source_name)
|
|
||||||
setattr(self, target_name, value)
|
|
||||||
|
|
||||||
return getattr(self, attribute)
|
|
||||||
|
|
||||||
|
|
||||||
def run_update(ydl):
|
def run_update(ydl):
|
||||||
"""Update the program file with the latest version from the repository
|
"""Update the program file with the latest version from the repository
|
||||||
@returns Whether there was a successful update (No update = False)
|
@returns Whether there was a successful update (No update = False)
|
||||||
"""
|
"""
|
||||||
|
deprecation_warning(
|
||||||
|
'"yt_dlp.update.run_update(ydl)" is deprecated and may be removed in a future version. '
|
||||||
|
'Use "yt_dlp.update.Updater(ydl).update()" instead')
|
||||||
return Updater(ydl).update()
|
return Updater(ydl).update()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user