diff --git a/lora-trigger-sheet b/lora-trigger-sheet index 29a2839..b349453 100755 --- a/lora-trigger-sheet +++ b/lora-trigger-sheet @@ -18,6 +18,7 @@ from pathlib import Path import hashlib import time from urllib.error import HTTPError, URLError +from urllib.parse import quote from urllib.request import urlopen, Request @@ -177,8 +178,9 @@ def lookup_source(filepath, filename, cache): if cached: url = cached.get("url") label = cached.get("label") - if url and (now - cached.get("last_checked", 0)) < 86400 * 30: - return url, label + last = cached.get("last_checked", 0) + if (now - last) < 86400 * 30: + return (url, label) if url else (None, None) # CivitAI model-version lookup by BLAKE2b file hash try: @@ -211,7 +213,7 @@ def lookup_source(filepath, filename, cache): ) data = _fetch_json( "https://huggingface.co/api/models" - f"?search={q}&sort=downloads&direction=-1&limit=3" + f"?search={quote(q)}&sort=downloads&direction=-1&limit=3" ) if isinstance(data, list) and len(data) > 0: model_id = data[0].get("modelId", "")