aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/utils.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-09-09 23:14:20 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-09-10 03:42:43 +0530
commit941e881e1fe20ee8955f3b751ce26953d9e86656 (patch)
tree0c06e04e7a1ae891adc628d2cbf7dc61c2c5de67 /yt_dlp/utils.py
parent0cb0fdbbfe32a0e8bc03c3248b95ec473a98b5cc (diff)
downloadhypervideo-pre-941e881e1fe20ee8955f3b751ce26953d9e86656.tar.lz
hypervideo-pre-941e881e1fe20ee8955f3b751ce26953d9e86656.tar.xz
hypervideo-pre-941e881e1fe20ee8955f3b751ce26953d9e86656.zip
Fix bug in ae1035646a6be09c2aed3e22eb8910f341ddacfe
Closes #4881
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r--yt_dlp/utils.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index 06699341c..a036e2233 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -1497,6 +1497,10 @@ class YoutubeDLHTTPSHandler(urllib.request.HTTPSHandler):
raise
+def is_path_like(f):
+ return isinstance(f, (str, bytes, os.PathLike))
+
+
class YoutubeDLCookieJar(http.cookiejar.MozillaCookieJar):
"""
See [1] for cookie file format.
@@ -1515,7 +1519,7 @@ class YoutubeDLCookieJar(http.cookiejar.MozillaCookieJar):
def __init__(self, filename=None, *args, **kwargs):
super().__init__(None, *args, **kwargs)
- if self.is_path(filename):
+ if is_path_like(filename):
filename = os.fspath(filename)
self.filename = filename
@@ -1523,13 +1527,9 @@ class YoutubeDLCookieJar(http.cookiejar.MozillaCookieJar):
def _true_or_false(cndn):
return 'TRUE' if cndn else 'FALSE'
- @staticmethod
- def is_path(file):
- return isinstance(file, (str, bytes, os.PathLike))
-
@contextlib.contextmanager
def open(self, file, *, write=False):
- if self.is_path(file):
+ if is_path_like(file):
with open(file, 'w' if write else 'r', encoding='utf-8') as f:
yield f
else: