John6666 commited on
Commit
353ca6c
·
verified ·
1 Parent(s): 3b36f8d

Upload utils.py

Browse files
Files changed (1) hide show
  1. utils.py +4 -4
utils.py CHANGED
@@ -130,7 +130,7 @@ def download_thing(directory, url, civitai_api_key="", progress=gr.Progress(trac
130
  if "drive.google.com" in url:
131
  original_dir = os.getcwd()
132
  os.chdir(directory)
133
- subprocess.run(f"gdown --fuzzy '{url}'", shell=True)
134
  os.chdir(original_dir)
135
  elif "huggingface.co" in url:
136
  url = url.replace("?download=true", "")
@@ -138,13 +138,13 @@ def download_thing(directory, url, civitai_api_key="", progress=gr.Progress(trac
138
  download_hf_file(directory, url)
139
  elif "civitai.com" in url:
140
  if civitai_api_key:
141
- url = url + f"&token={civitai_api_key}" if "?" in url else url + f"?token={civitai_api_key}"
142
  print(f"Downloading {url}")
143
- subprocess.run(f"aria2c --console-log-level=error --summary-interval=10 -c -x 16 -k 1M -s 16 -d {directory} '{url}'", shell=True)
144
  else:
145
  print("You need an API key to download Civitai models.")
146
  else:
147
- os.system(f"aria2c --console-log-level=error --summary-interval=10 -c -x 16 -k 1M -s 16 -d {directory} '{url}'")
148
  except Exception as e:
149
  print(f"Failed to download: {e}")
150
 
 
130
  if "drive.google.com" in url:
131
  original_dir = os.getcwd()
132
  os.chdir(directory)
133
+ subprocess.run(f"gdown --fuzzy {url}", shell=True)
134
  os.chdir(original_dir)
135
  elif "huggingface.co" in url:
136
  url = url.replace("?download=true", "")
 
138
  download_hf_file(directory, url)
139
  elif "civitai.com" in url:
140
  if civitai_api_key:
141
+ url = f"'{url}&token={civitai_api_key}'" if "?" in url else f"{url}?token={civitai_api_key}"
142
  print(f"Downloading {url}")
143
+ subprocess.run(f"aria2c --console-log-level=error --summary-interval=10 -c -x 16 -k 1M -s 16 -d {directory} {url}", shell=True)
144
  else:
145
  print("You need an API key to download Civitai models.")
146
  else:
147
+ os.system(f"aria2c --console-log-level=error --summary-interval=10 -c -x 16 -k 1M -s 16 -d {directory} {url}")
148
  except Exception as e:
149
  print(f"Failed to download: {e}")
150