Spaces:
Running
on
Zero
Running
on
Zero
Fix Huggingface header parsing
Browse files- utils/download_utils.py +8 -4
utils/download_utils.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
def download_things(
|
| 2 |
directory: str,
|
| 3 |
url: str,
|
| 4 |
-
|
| 5 |
civitai_api_key: str = ""):
|
| 6 |
"""
|
| 7 |
:param directory: String, directory to save the downloaded file
|
|
@@ -22,9 +22,13 @@ def download_things(
|
|
| 22 |
# url = urllib.parse.quote(url, safe=':/') # fix encoding
|
| 23 |
if "/blob/" in url:
|
| 24 |
url = url.replace("/blob/", "/resolve/")
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
f"1M -s 16 {url} -d {directory} -o {url.split('/')[-1]}")
|
| 29 |
elif "civitai.com" in url:
|
| 30 |
if "?" in url:
|
|
|
|
| 1 |
def download_things(
|
| 2 |
directory: str,
|
| 3 |
url: str,
|
| 4 |
+
hf_token: str = "",
|
| 5 |
civitai_api_key: str = ""):
|
| 6 |
"""
|
| 7 |
:param directory: String, directory to save the downloaded file
|
|
|
|
| 22 |
# url = urllib.parse.quote(url, safe=':/') # fix encoding
|
| 23 |
if "/blob/" in url:
|
| 24 |
url = url.replace("/blob/", "/resolve/")
|
| 25 |
+
user_header = f"Authorization: Bearer {hf_token}"
|
| 26 |
+
if hf_token:
|
| 27 |
+
os.system(
|
| 28 |
+
f"aria2c --console-log-level=error --summary-interval=10 --header={user_header} -c -x 16 -k 1M -s 16 {url} -d {directory} -o {url.split('/')[-1]}")
|
| 29 |
+
else:
|
| 30 |
+
os.system(
|
| 31 |
+
f"aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -c -x 16 -k "
|
| 32 |
f"1M -s 16 {url} -d {directory} -o {url.split('/')[-1]}")
|
| 33 |
elif "civitai.com" in url:
|
| 34 |
if "?" in url:
|