aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2023-07-22 09:08:12 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2023-07-22 09:09:52 +0530
commit62b5c94cadaa5f596dc1a7083db9db12efe357be (patch)
tree4a1035e30da1d88345252118b5f4083284775833 /yt_dlp
parente0c4db04dc82a699bdabd9821ddc239ebe17d30a (diff)
downloadhypervideo-pre-62b5c94cadaa5f596dc1a7083db9db12efe357be.tar.lz
hypervideo-pre-62b5c94cadaa5f596dc1a7083db9db12efe357be.tar.xz
hypervideo-pre-62b5c94cadaa5f596dc1a7083db9db12efe357be.zip
[cleanup] Misc fixes
Closes #7528
Diffstat (limited to 'yt_dlp')
-rw-r--r--yt_dlp/YoutubeDL.py13
-rw-r--r--yt_dlp/compat/_legacy.py4
-rw-r--r--yt_dlp/cookies.py10
-rw-r--r--yt_dlp/downloader/external.py2
-rw-r--r--yt_dlp/networking/_urllib.py4
-rw-r--r--yt_dlp/networking/common.py2
6 files changed, 18 insertions, 17 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index dae29d9f9..c9cf07e53 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -572,7 +572,7 @@ class YoutubeDL:
'width', 'height', 'aspect_ratio', 'resolution', 'dynamic_range', 'tbr', 'abr', 'acodec', 'asr', 'audio_channels',
'vbr', 'fps', 'vcodec', 'container', 'filesize', 'filesize_approx', 'rows', 'columns',
'player_url', 'protocol', 'fragment_base_url', 'fragments', 'is_from_start',
- 'preference', 'language', 'language_preference', 'quality', 'source_preference',
+ 'preference', 'language', 'language_preference', 'quality', 'source_preference', 'cookies',
'http_headers', 'stretched_ratio', 'no_resume', 'has_drm', 'extra_param_to_segment_url', 'hls_aes', 'downloader_options',
'page_url', 'app', 'play_path', 'tc_url', 'flash_version', 'rtmp_live', 'rtmp_conn', 'rtmp_protocol', 'rtmp_real_time'
}
@@ -621,7 +621,8 @@ class YoutubeDL:
if self.params.get('no_color'):
if self.params.get('color') is not None:
- self.report_warning('Overwriting params from "color" with "no_color"')
+ self.params.setdefault('_warnings', []).append(
+ 'Overwriting params from "color" with "no_color"')
self.params['color'] = 'no_color'
term_allow_color = os.environ.get('TERM', '').lower() != 'dumb'
@@ -949,7 +950,7 @@ class YoutubeDL:
def save_cookies(self):
if self.params.get('cookiefile') is not None:
- self.cookiejar.save(ignore_discard=True, ignore_expires=True)
+ self.cookiejar.save()
def __exit__(self, *args):
self.restore_console_title()
@@ -3290,7 +3291,7 @@ class YoutubeDL:
fd, success = None, True
if info_dict.get('protocol') or info_dict.get('url'):
fd = get_suitable_downloader(info_dict, self.params, to_stdout=temp_filename == '-')
- if fd is not FFmpegFD and 'no-direct-merge' not in self.params['compat_opts'] and (
+ if fd != FFmpegFD and 'no-direct-merge' not in self.params['compat_opts'] and (
info_dict.get('section_start') or info_dict.get('section_end')):
msg = ('This format cannot be partially downloaded' if FFmpegFD.available()
else 'You have requested downloading the video partially, but ffmpeg is not installed')
@@ -3451,7 +3452,7 @@ class YoutubeDL:
postprocessed_by_ffmpeg = info_dict.get('requested_formats') or any((
isinstance(pp, FFmpegVideoConvertorPP)
and resolve_recode_mapping(ext, pp.mapping)[0] not in (ext, None)
- ) for pp in self._pps['post_process'])
+ ) for pp in self._pps['post_process']) or fd == FFmpegFD
if not postprocessed_by_ffmpeg:
ffmpeg_fixup(ext == 'm4a' and info_dict.get('container') == 'm4a_dash',
@@ -4031,7 +4032,7 @@ class YoutubeDL:
"""
Get a urllib OpenerDirector from the Urllib handler (deprecated).
"""
- self.deprecation_warning('YoutubeDL._opener() is deprecated, use YoutubeDL.urlopen()')
+ self.deprecation_warning('YoutubeDL._opener is deprecated, use YoutubeDL.urlopen()')
handler = self._request_director.handlers['Urllib']
return handler._get_instance(cookiejar=self.cookiejar, proxies=self.proxies)
diff --git a/yt_dlp/compat/_legacy.py b/yt_dlp/compat/_legacy.py
index 912907a02..90ccf0f14 100644
--- a/yt_dlp/compat/_legacy.py
+++ b/yt_dlp/compat/_legacy.py
@@ -16,12 +16,12 @@ import shlex
import shutil
import socket
import struct
+import subprocess
import tokenize
import urllib.error
import urllib.parse
import urllib.request
import xml.etree.ElementTree as etree
-from subprocess import DEVNULL
# isort: split
import asyncio # noqa: F401
@@ -85,7 +85,7 @@ compat_socket_create_connection = socket.create_connection
compat_Struct = struct.Struct
compat_struct_pack = struct.pack
compat_struct_unpack = struct.unpack
-compat_subprocess_get_DEVNULL = lambda: DEVNULL
+compat_subprocess_get_DEVNULL = lambda: subprocess.DEVNULL
compat_tokenize_tokenize = tokenize.tokenize
compat_urllib_error = urllib.error
compat_urllib_HTTPError = urllib.error.HTTPError
diff --git a/yt_dlp/cookies.py b/yt_dlp/cookies.py
index 16f1918e6..80428c747 100644
--- a/yt_dlp/cookies.py
+++ b/yt_dlp/cookies.py
@@ -97,7 +97,7 @@ def load_cookies(cookie_file, browser_specification, ydl):
jar = YoutubeDLCookieJar(cookie_file)
if not is_filename or os.access(cookie_file, os.R_OK):
- jar.load(ignore_discard=True, ignore_expires=True)
+ jar.load()
cookie_jars.append(jar)
return _merge_cookie_jars(cookie_jars)
@@ -1213,7 +1213,7 @@ class YoutubeDLCookieJar(http.cookiejar.MozillaCookieJar):
file.truncate(0)
yield file
- def _really_save(self, f, ignore_discard=False, ignore_expires=False):
+ def _really_save(self, f, ignore_discard, ignore_expires):
now = time.time()
for cookie in self:
if (not ignore_discard and cookie.discard
@@ -1234,7 +1234,7 @@ class YoutubeDLCookieJar(http.cookiejar.MozillaCookieJar):
name, value
)))
- def save(self, filename=None, *args, **kwargs):
+ def save(self, filename=None, ignore_discard=True, ignore_expires=True):
"""
Save cookies to a file.
Code is taken from CPython 3.6
@@ -1253,9 +1253,9 @@ class YoutubeDLCookieJar(http.cookiejar.MozillaCookieJar):
with self.open(filename, write=True) as f:
f.write(self._HEADER)
- self._really_save(f, *args, **kwargs)
+ self._really_save(f, ignore_discard, ignore_expires)
- def load(self, filename=None, ignore_discard=False, ignore_expires=False):
+ def load(self, filename=None, ignore_discard=True, ignore_expires=True):
"""Load cookies from a file."""
if filename is None:
if self.filename is not None:
diff --git a/yt_dlp/downloader/external.py b/yt_dlp/downloader/external.py
index d3c3eba88..4ce8a3bf7 100644
--- a/yt_dlp/downloader/external.py
+++ b/yt_dlp/downloader/external.py
@@ -137,7 +137,7 @@ class ExternalFD(FragmentFD):
self._cookies_tempfile = tmp_cookies.name
self.to_screen(f'[download] Writing temporary cookies file to "{self._cookies_tempfile}"')
# real_download resets _cookies_tempfile; if it's None then save() will write to cookiejar.filename
- self.ydl.cookiejar.save(self._cookies_tempfile, ignore_discard=True, ignore_expires=True)
+ self.ydl.cookiejar.save(self._cookies_tempfile)
return self.ydl.cookiejar.filename or self._cookies_tempfile
def _call_downloader(self, tmpfilename, info_dict):
diff --git a/yt_dlp/networking/_urllib.py b/yt_dlp/networking/_urllib.py
index 8a76676d9..ff3a22c8c 100644
--- a/yt_dlp/networking/_urllib.py
+++ b/yt_dlp/networking/_urllib.py
@@ -28,7 +28,7 @@ from ._helper import (
make_socks_proxy_opts,
select_proxy,
)
-from .common import Features, RequestHandler, Response, register
+from .common import Features, RequestHandler, Response, register_rh
from .exceptions import (
CertificateVerifyError,
HTTPError,
@@ -372,7 +372,7 @@ def handle_response_read_exceptions(e):
raise TransportError(cause=e) from e
-@register
+@register_rh
class UrllibRH(RequestHandler, InstanceStoreMixin):
_SUPPORTED_URL_SCHEMES = ('http', 'https', 'data', 'ftp')
_SUPPORTED_PROXY_SCHEMES = ('http', 'socks4', 'socks4a', 'socks5', 'socks5h')
diff --git a/yt_dlp/networking/common.py b/yt_dlp/networking/common.py
index 61196406d..7f7457978 100644
--- a/yt_dlp/networking/common.py
+++ b/yt_dlp/networking/common.py
@@ -105,7 +105,7 @@ class RequestDirector:
_REQUEST_HANDLERS = {}
-def register(handler):
+def register_rh(handler):
"""Register a RequestHandler class"""
assert issubclass(handler, RequestHandler), f'{handler} must be a subclass of RequestHandler'
assert handler.RH_KEY not in _REQUEST_HANDLERS, f'RequestHandler {handler.RH_KEY} already registered'