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