mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-03-04 13:20:13 +00:00
[docs] Misc Cleanup (#8977)
Closes #8355, #8944 Authored by: bashonly, Grub4k, Arthurszzz, seproDev, pukkandan Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com> Co-authored-by: bashonly <bashonly@protonmail.com> Co-authored-by: Arthurszzz <minecraftgamerarthur@gmail.com> Co-authored-by: Simon Sawicki <accounts@grub4k.xyz> Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com>
This commit is contained in:
@@ -2227,7 +2227,7 @@ class YoutubeDL:
|
||||
selectors = []
|
||||
current_selector = None
|
||||
for type, string_, start, _, _ in tokens:
|
||||
# ENCODING is only defined in python 3.x
|
||||
# ENCODING is only defined in Python 3.x
|
||||
if type == getattr(tokenize, 'ENCODING', None):
|
||||
continue
|
||||
elif type in [tokenize.NAME, tokenize.NUMBER]:
|
||||
|
||||
@@ -4,7 +4,7 @@ if sys.version_info < (3, 8):
|
||||
raise ImportError(
|
||||
f'You are using an unsupported version of Python. Only Python versions 3.8 and above are supported by yt-dlp') # noqa: F541
|
||||
|
||||
__license__ = 'Public Domain'
|
||||
__license__ = 'The Unlicense'
|
||||
|
||||
import collections
|
||||
import getpass
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Execute with
|
||||
# $ python -m yt_dlp
|
||||
# $ python3 -m yt_dlp
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ def pycryptodome_module():
|
||||
try:
|
||||
import Crypto # noqa: F401
|
||||
print('WARNING: Using Crypto since Cryptodome is not available. '
|
||||
'Install with: pip install pycryptodomex', file=sys.stderr)
|
||||
'Install with: python3 -m pip install pycryptodomex', file=sys.stderr)
|
||||
return 'Crypto'
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -10,10 +10,10 @@ del passthrough_module
|
||||
from .. import compat_os_name
|
||||
|
||||
if compat_os_name == 'nt':
|
||||
# On older python versions, proxies are extracted from Windows registry erroneously. [1]
|
||||
# On older Python versions, proxies are extracted from Windows registry erroneously. [1]
|
||||
# If the https proxy in the registry does not have a scheme, urllib will incorrectly add https:// to it. [2]
|
||||
# It is unlikely that the user has actually set it to be https, so we should be fine to safely downgrade
|
||||
# it to http on these older python versions to avoid issues
|
||||
# it to http on these older Python versions to avoid issues
|
||||
# This also applies for ftp proxy type, as ftp:// proxy scheme is not supported.
|
||||
# 1: https://github.com/python/cpython/issues/86793
|
||||
# 2: https://github.com/python/cpython/blob/51f1ae5ceb0673316c4e4b0175384e892e33cc6e/Lib/urllib/request.py#L2683-L2698
|
||||
|
||||
@@ -121,7 +121,7 @@ def _extract_firefox_cookies(profile, container, logger):
|
||||
logger.info('Extracting cookies from firefox')
|
||||
if not sqlite3:
|
||||
logger.warning('Cannot extract cookies from firefox without sqlite3 support. '
|
||||
'Please use a python interpreter compiled with sqlite3 support')
|
||||
'Please use a Python interpreter compiled with sqlite3 support')
|
||||
return YoutubeDLCookieJar()
|
||||
|
||||
if profile is None:
|
||||
@@ -264,7 +264,7 @@ def _extract_chrome_cookies(browser_name, profile, keyring, logger):
|
||||
|
||||
if not sqlite3:
|
||||
logger.warning(f'Cannot extract cookies from {browser_name} without sqlite3 support. '
|
||||
'Please use a python interpreter compiled with sqlite3 support')
|
||||
'Please use a Python interpreter compiled with sqlite3 support')
|
||||
return YoutubeDLCookieJar()
|
||||
|
||||
config = _get_chromium_based_browser_settings(browser_name)
|
||||
|
||||
@@ -46,7 +46,7 @@ try:
|
||||
# We need to get the underlying `sqlite` version, see https://github.com/yt-dlp/yt-dlp/issues/8152
|
||||
sqlite3._yt_dlp__version = sqlite3.sqlite_version
|
||||
except ImportError:
|
||||
# although sqlite3 is part of the standard library, it is possible to compile python without
|
||||
# although sqlite3 is part of the standard library, it is possible to compile Python without
|
||||
# sqlite support. See: https://github.com/yt-dlp/yt-dlp/issues/544
|
||||
sqlite3 = None
|
||||
|
||||
@@ -54,7 +54,7 @@ except ImportError:
|
||||
try:
|
||||
import websockets
|
||||
except (ImportError, SyntaxError):
|
||||
# websockets 3.10 on python 3.6 causes SyntaxError
|
||||
# websockets 3.10 on Python 3.6 causes SyntaxError
|
||||
# See https://github.com/yt-dlp/yt-dlp/issues/2633
|
||||
websockets = None
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class KnownDRMIE(UnsupportedInfoExtractor):
|
||||
|
||||
Add to this list only if:
|
||||
* You are reasonably certain that the site uses DRM for ALL their videos
|
||||
* Multiple users have asked about this site on github/reddit/discord
|
||||
* Multiple users have asked about this site on github/discord
|
||||
"""
|
||||
|
||||
URLS = (
|
||||
|
||||
@@ -167,7 +167,7 @@ class HTTPHandler(urllib.request.AbstractHTTPHandler):
|
||||
if 300 <= resp.code < 400:
|
||||
location = resp.headers.get('Location')
|
||||
if location:
|
||||
# As of RFC 2616 default charset is iso-8859-1 that is respected by python 3
|
||||
# As of RFC 2616 default charset is iso-8859-1 that is respected by Python 3
|
||||
location = location.encode('iso-8859-1').decode()
|
||||
location_escaped = normalize_url(location)
|
||||
if location != location_escaped:
|
||||
|
||||
@@ -446,7 +446,7 @@ class Request:
|
||||
|
||||
@headers.setter
|
||||
def headers(self, new_headers: Mapping):
|
||||
"""Replaces headers of the request. If not a CaseInsensitiveDict, it will be converted to one."""
|
||||
"""Replaces headers of the request. If not a HTTPHeaderDict, it will be converted to one."""
|
||||
if isinstance(new_headers, HTTPHeaderDict):
|
||||
self._headers = new_headers
|
||||
elif isinstance(new_headers, Mapping):
|
||||
|
||||
@@ -151,7 +151,7 @@ class _YoutubeDLHelpFormatter(optparse.IndentedHelpFormatter):
|
||||
|
||||
|
||||
class _YoutubeDLOptionParser(optparse.OptionParser):
|
||||
# optparse is deprecated since python 3.2. So assume a stable interface even for private methods
|
||||
# optparse is deprecated since Python 3.2. So assume a stable interface even for private methods
|
||||
ALIAS_DEST = '_triggered_aliases'
|
||||
ALIAS_TRIGGER_LIMIT = 100
|
||||
|
||||
@@ -393,7 +393,7 @@ def create_parser():
|
||||
'--ignore-config', '--no-config',
|
||||
action='store_true', dest='ignoreconfig',
|
||||
help=(
|
||||
'Don\'t load any more configuration files except those given by --config-locations. '
|
||||
'Don\'t load any more configuration files except those given to --config-locations. '
|
||||
'For backward compatibility, if this option is found inside the system configuration file, the user configuration is not loaded. '
|
||||
'(Alias: --no-config)'))
|
||||
general.add_option(
|
||||
@@ -1193,7 +1193,9 @@ def create_parser():
|
||||
verbosity.add_option(
|
||||
'-j', '--dump-json',
|
||||
action='store_true', dest='dumpjson', default=False,
|
||||
help='Quiet, but print JSON information for each video. Simulate unless --no-simulate is used. See "OUTPUT TEMPLATE" for a description of available keys')
|
||||
help=(
|
||||
'Quiet, but print JSON information for each video. Simulate unless --no-simulate is used. '
|
||||
'See "OUTPUT TEMPLATE" for a description of available keys'))
|
||||
verbosity.add_option(
|
||||
'-J', '--dump-single-json',
|
||||
action='store_true', dest='dump_single_json', default=False,
|
||||
@@ -1315,7 +1317,7 @@ def create_parser():
|
||||
filesystem.add_option(
|
||||
'--output-na-placeholder',
|
||||
dest='outtmpl_na_placeholder', metavar='TEXT', default='NA',
|
||||
help=('Placeholder for unavailable fields in "OUTPUT TEMPLATE" (default: "%default")'))
|
||||
help=('Placeholder for unavailable fields in --output (default: "%default")'))
|
||||
filesystem.add_option(
|
||||
'--autonumber-size',
|
||||
dest='autonumber_size', metavar='NUMBER', type=int,
|
||||
|
||||
@@ -190,7 +190,7 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
|
||||
|
||||
elif info['ext'] in ['ogg', 'opus', 'flac']:
|
||||
if not mutagen:
|
||||
raise EmbedThumbnailPPError('module mutagen was not found. Please install using `python -m pip install mutagen`')
|
||||
raise EmbedThumbnailPPError('module mutagen was not found. Please install using `python3 -m pip install mutagen`')
|
||||
|
||||
self._report_run('mutagen', filename)
|
||||
f = {'opus': OggOpus, 'flac': FLAC, 'ogg': OggVorbis}[info['ext']](filename)
|
||||
|
||||
@@ -177,19 +177,19 @@ class UpdateInfo:
|
||||
Can be created by `query_update()` or manually.
|
||||
|
||||
Attributes:
|
||||
tag The release tag that will be updated to. If from query_update,
|
||||
the value is after API resolution and update spec processing.
|
||||
The only property that is required.
|
||||
version The actual numeric version (if available) of the binary to be updated to,
|
||||
after API resolution and update spec processing. (default: None)
|
||||
requested_version Numeric version of the binary being requested (if available),
|
||||
after API resolution only. (default: None)
|
||||
commit Commit hash (if available) of the binary to be updated to,
|
||||
after API resolution and update spec processing. (default: None)
|
||||
This value will only match the RELEASE_GIT_HEAD of prerelease builds.
|
||||
binary_name Filename of the binary to be updated to. (default: current binary name)
|
||||
checksum Expected checksum (if available) of the binary to be
|
||||
updated to. (default: None)
|
||||
tag The release tag that will be updated to. If from query_update,
|
||||
the value is after API resolution and update spec processing.
|
||||
The only property that is required.
|
||||
version The actual numeric version (if available) of the binary to be updated to,
|
||||
after API resolution and update spec processing. (default: None)
|
||||
requested_version Numeric version of the binary being requested (if available),
|
||||
after API resolution only. (default: None)
|
||||
commit Commit hash (if available) of the binary to be updated to,
|
||||
after API resolution and update spec processing. (default: None)
|
||||
This value will only match the RELEASE_GIT_HEAD of prerelease builds.
|
||||
binary_name Filename of the binary to be updated to. (default: current binary name)
|
||||
checksum Expected checksum (if available) of the binary to be
|
||||
updated to. (default: None)
|
||||
"""
|
||||
tag: str
|
||||
version: str | None = None
|
||||
@@ -351,7 +351,9 @@ class Updater:
|
||||
return a == b
|
||||
|
||||
def query_update(self, *, _output=False) -> UpdateInfo | None:
|
||||
"""Fetches and returns info about the available update"""
|
||||
"""Fetches info about the available update
|
||||
@returns An `UpdateInfo` if there is an update available, else None
|
||||
"""
|
||||
if not self.requested_repo:
|
||||
self._report_error('No target repository could be determined from input')
|
||||
return None
|
||||
@@ -429,7 +431,9 @@ class Updater:
|
||||
checksum=checksum)
|
||||
|
||||
def update(self, update_info=NO_DEFAULT):
|
||||
"""Update yt-dlp executable to the latest version"""
|
||||
"""Update yt-dlp executable to the latest version
|
||||
@param update_info `UpdateInfo | None` as returned by query_update()
|
||||
"""
|
||||
if update_info is NO_DEFAULT:
|
||||
update_info = self.query_update(_output=True)
|
||||
if not update_info:
|
||||
|
||||
@@ -90,7 +90,7 @@ class WebSocketsWrapper:
|
||||
for task in to_cancel:
|
||||
task.cancel()
|
||||
|
||||
# XXX: "loop" is removed in python 3.10+
|
||||
# XXX: "loop" is removed in Python 3.10+
|
||||
loop.run_until_complete(
|
||||
asyncio.gather(*to_cancel, loop=loop, return_exceptions=True))
|
||||
|
||||
|
||||
@@ -4468,7 +4468,7 @@ def write_xattr(path, key, value):
|
||||
else 'xattr' if check_executable('xattr', ['-h']) else None)
|
||||
if not exe:
|
||||
raise XAttrUnavailableError(
|
||||
'Couldn\'t find a tool to set the xattrs. Install either the python "xattr" or "pyxattr" modules or the '
|
||||
'Couldn\'t find a tool to set the xattrs. Install either the "xattr" or "pyxattr" Python modules or the '
|
||||
+ ('"xattr" binary' if sys.platform != 'linux' else 'GNU "attr" package (which contains the "setfattr" tool)'))
|
||||
|
||||
value = value.decode()
|
||||
|
||||
Reference in New Issue
Block a user