fix(civitai): recognize civitai.red URLs in parse_civitai_url
The URL parser previously required the hostname to contain "civitai.com", so CivitAI download links using the "civitai.red" domain were treated as non-CivitAI URLs and rejected. This extracts the host check into _is_civitai_host() and accepts both "civitai.com" and "civitai.red" base domains, so resolve/parse flows handle all CivitAI download links correctly.
This commit is contained in:
+11
-1
@@ -51,6 +51,16 @@ MAX_CIVITAI_CANDIDATE_LIMIT = 20
|
||||
MODEL_TITLE_MATCH_THRESHOLD = 82.0
|
||||
|
||||
|
||||
def _is_civitai_host(host: Optional[str]) -> bool:
|
||||
host = str(host or "").lower().strip(".")
|
||||
return (
|
||||
host == "civitai.com"
|
||||
or host.endswith(".civitai.com")
|
||||
or host == "civitai.red"
|
||||
or host.endswith(".civitai.red")
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -782,7 +792,7 @@ def parse_civitai_url(url: str) -> Optional[Dict[str, Any]]:
|
||||
if not isinstance(url, str) or not url.strip():
|
||||
return None
|
||||
parsed = urlparse(url)
|
||||
if "civitai.com" not in parsed.netloc:
|
||||
if not _is_civitai_host(parsed.hostname):
|
||||
return None
|
||||
|
||||
if "/api/download/models/" in parsed.path:
|
||||
|
||||
Reference in New Issue
Block a user