mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-07-10 07:18:33 +00:00
update
This commit is contained in:
parent
37a3bc2a4a
commit
8e39820adc
@ -49,7 +49,7 @@ def cookie_jar_to_list(cookie_jar):
|
|||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def _temp_file(content, *, mode='wt', encoding='utf-8', suffix=None, close=True):
|
def _temp_file(content, *, mode='wt', encoding='utf-8', suffix=None, close=True):
|
||||||
if 'r' in mode:
|
if 'b' in mode:
|
||||||
encoding = None
|
encoding = None
|
||||||
temp_file_handle = tempfile.NamedTemporaryFile(mode, encoding=encoding, suffix=suffix, delete=False)
|
temp_file_handle = tempfile.NamedTemporaryFile(mode, encoding=encoding, suffix=suffix, delete=False)
|
||||||
try:
|
try:
|
||||||
@ -62,6 +62,26 @@ def _temp_file(content, *, mode='wt', encoding='utf-8', suffix=None, close=True)
|
|||||||
os.remove(temp_file_handle.name)
|
os.remove(temp_file_handle.name)
|
||||||
|
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def _tempfile_context():
|
||||||
|
handles = []
|
||||||
|
|
||||||
|
def _creater(content, *, mode='wt', encoding='utf-8', suffix=None, close=True):
|
||||||
|
encoding = None if 'b' in mode else encoding
|
||||||
|
handle = tempfile.NamedTemporaryFile(mode, encoding=encoding, suffix=suffix, delete=False)
|
||||||
|
handles.append(handle)
|
||||||
|
handle.write(content)
|
||||||
|
if close:
|
||||||
|
handle.close()
|
||||||
|
return handle
|
||||||
|
try:
|
||||||
|
yield _creater
|
||||||
|
finally:
|
||||||
|
for handle in handles:
|
||||||
|
with contextlib.suppress(OSError):
|
||||||
|
os.remove(handle.name)
|
||||||
|
|
||||||
|
|
||||||
class ExternalJSI:
|
class ExternalJSI:
|
||||||
@classproperty(cache=True)
|
@classproperty(cache=True)
|
||||||
def version(cls):
|
def version(cls):
|
||||||
|
Loading…
Reference in New Issue
Block a user