Browse Source

file:/// needs copy, too

they might well be a remote FUSE filesystem, thus depending on network,
so let's be sure and copy it
boyska 1 year ago
parent
commit
751111143e
1 changed files with 9 additions and 3 deletions
  1. 9 3
      feed

+ 9 - 3
feed

@@ -20,6 +20,7 @@ from bisect import bisect
 from collections import OrderedDict
 from subprocess import CalledProcessError, check_output
 from urllib.parse import unquote, urlparse
+import shutil
 
 import requests
 from lxml import html
@@ -492,20 +493,25 @@ def put(audio, copy=False):
         for url in audio.urls:
             print(url)
     else:
+        destdir = os.environ.get("TMPDIR", ".")
+        os.makedirs(destdir, exist_ok=True)
         for url in audio.urls:
             if url.split(":")[0] in ("http", "https"):
-                destdir = os.environ.get("TMPDIR", ".")
                 fname = posixpath.basename(urlparse(url).path)
                 # sanitize
                 fname = "".join(
                     c for c in fname if c.isalnum() or c in list("._-")
                 ).rstrip()
                 dest = os.path.join(destdir, fname)
-                os.makedirs(destdir, exist_ok=True)
                 downloader(url, dest)
                 print("file://%s" % os.path.realpath(dest))
+            elif url.startswith("file:///"):
+                src = url[len('file://'):]
+                dest = os.path.join(destdir, os.path.basename(src))
+                shutil.copy(src, dest)
+                print("file://%s" % os.path.realpath(dest))
             else:
-                # FIXME: file:// urls are just copied
+                # what's that? let's just copy it
                 print(url)