Fix download script (#1373)

This commit is contained in:
Rudd-O 2023-04-19 16:02:32 +00:00 committed by GitHub
parent 49aa05054a
commit 69d50e2e86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,7 +81,7 @@ def sanitize_model_and_branch_names(model, branch):
def get_download_links_from_huggingface(model, branch, text_only=False):
base = "https://huggingface.co"
page = f"/api/models/{model}/tree/{branch}?cursor="
page = f"/api/models/{model}/tree/{branch}"
cursor = b""
links = []
@ -93,7 +93,10 @@ def get_download_links_from_huggingface(model, branch, text_only=False):
has_safetensors = False
is_lora = False
while True:
content = requests.get(f"{base}{page}{cursor.decode()}").content
url = f"{base}{page}" + (f"?cursor={cursor.decode()}" if cursor else "")
r = requests.get(url)
r.raise_for_status()
content = r.content
dict = json.loads(content)
if len(dict) == 0: