lora trigger sheet
This commit is contained in:
@@ -18,6 +18,7 @@ from pathlib import Path
|
|||||||
import hashlib
|
import hashlib
|
||||||
import time
|
import time
|
||||||
from urllib.error import HTTPError, URLError
|
from urllib.error import HTTPError, URLError
|
||||||
|
from urllib.parse import quote
|
||||||
from urllib.request import urlopen, Request
|
from urllib.request import urlopen, Request
|
||||||
|
|
||||||
|
|
||||||
@@ -177,8 +178,9 @@ def lookup_source(filepath, filename, cache):
|
|||||||
if cached:
|
if cached:
|
||||||
url = cached.get("url")
|
url = cached.get("url")
|
||||||
label = cached.get("label")
|
label = cached.get("label")
|
||||||
if url and (now - cached.get("last_checked", 0)) < 86400 * 30:
|
last = cached.get("last_checked", 0)
|
||||||
return url, label
|
if (now - last) < 86400 * 30:
|
||||||
|
return (url, label) if url else (None, None)
|
||||||
|
|
||||||
# CivitAI model-version lookup by BLAKE2b file hash
|
# CivitAI model-version lookup by BLAKE2b file hash
|
||||||
try:
|
try:
|
||||||
@@ -211,7 +213,7 @@ def lookup_source(filepath, filename, cache):
|
|||||||
)
|
)
|
||||||
data = _fetch_json(
|
data = _fetch_json(
|
||||||
"https://huggingface.co/api/models"
|
"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:
|
if isinstance(data, list) and len(data) > 0:
|
||||||
model_id = data[0].get("modelId", "")
|
model_id = data[0].get("modelId", "")
|
||||||
|
|||||||
Reference in New Issue
Block a user