]> jfr.im git - yt-dlp.git/commitdiff
Fix bug in ae1035646a6be09c2aed3e22eb8910f341ddacfe
authorpukkandan <redacted>
Fri, 9 Sep 2022 17:44:20 +0000 (23:14 +0530)
committerpukkandan <redacted>
Fri, 9 Sep 2022 22:12:43 +0000 (03:42 +0530)
Closes #4881

yt_dlp/YoutubeDL.py
yt_dlp/utils.py

index 95fa5fb19a7831b64de512c29edf4bd806b19d07..83b5100eef884e36d7fcd65d986383263c008a49 100644 (file)
     get_domain,
     int_or_none,
     iri_to_uri,
+    is_path_like,
     join_nonempty,
     locked_file,
     make_archive_id,
@@ -725,7 +726,7 @@ def preload_download_archive(fn):
             archive = set()
             if fn is None:
                 return archive
-            elif not isinstance(fn, os.PathLike):
+            elif not is_path_like(fn):
                 return fn
 
             self.write_debug(f'Loading archive file {fn!r}')
index 06699341c926042ee53eb257e558d51e176d9285..a036e2233b260876bb7738f6951d6392100a223d 100644 (file)
@@ -1497,6 +1497,10 @@ def https_open(self, req):
             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 @@ def __init__(self, filename=None, *args, **kwargs):
     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: