mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-26 07:35:44 -03:00
feat: enhance model metadata fetching to include creator information
This commit is contained in:
@@ -267,7 +267,7 @@ class CivitaiClient:
|
|||||||
return None, error_msg
|
return None, error_msg
|
||||||
|
|
||||||
async def get_model_metadata(self, model_id: str) -> Tuple[Optional[Dict], int]:
|
async def get_model_metadata(self, model_id: str) -> Tuple[Optional[Dict], int]:
|
||||||
"""Fetch model metadata (description and tags) from Civitai API
|
"""Fetch model metadata (description, tags, and creator info) from Civitai API
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
model_id: The Civitai model ID
|
model_id: The Civitai model ID
|
||||||
@@ -294,10 +294,14 @@ class CivitaiClient:
|
|||||||
# Extract relevant metadata
|
# Extract relevant metadata
|
||||||
metadata = {
|
metadata = {
|
||||||
"description": data.get("description") or "No model description available",
|
"description": data.get("description") or "No model description available",
|
||||||
"tags": data.get("tags", [])
|
"tags": data.get("tags", []),
|
||||||
|
"creator": {
|
||||||
|
"username": data.get("creator", {}).get("username"),
|
||||||
|
"image": data.get("creator", {}).get("image")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if metadata["description"] or metadata["tags"]:
|
if metadata["description"] or metadata["tags"] or metadata["creator"]["username"]:
|
||||||
return metadata, status_code
|
return metadata, status_code
|
||||||
else:
|
else:
|
||||||
logger.warning(f"No metadata found for model {model_id}")
|
logger.warning(f"No metadata found for model {model_id}")
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ class DownloadManager:
|
|||||||
metadata = LoraMetadata.from_civitai_info(version_info, file_info, save_path)
|
metadata = LoraMetadata.from_civitai_info(version_info, file_info, save_path)
|
||||||
logger.info(f"Creating LoraMetadata for {file_name}")
|
logger.info(f"Creating LoraMetadata for {file_name}")
|
||||||
|
|
||||||
# 5.1 Get and update model tags and description
|
# 5.1 Get and update model tags, description and creator info
|
||||||
model_id = version_info.get('modelId')
|
model_id = version_info.get('modelId')
|
||||||
if model_id:
|
if model_id:
|
||||||
model_metadata, _ = await civitai_client.get_model_metadata(str(model_id))
|
model_metadata, _ = await civitai_client.get_model_metadata(str(model_id))
|
||||||
@@ -163,6 +163,8 @@ class DownloadManager:
|
|||||||
metadata.tags = model_metadata.get("tags", [])
|
metadata.tags = model_metadata.get("tags", [])
|
||||||
if model_metadata.get("description"):
|
if model_metadata.get("description"):
|
||||||
metadata.modelDescription = model_metadata.get("description", "")
|
metadata.modelDescription = model_metadata.get("description", "")
|
||||||
|
if model_metadata.get("creator"):
|
||||||
|
metadata.civitai["creator"] = model_metadata.get("creator")
|
||||||
|
|
||||||
# 6. Start download process
|
# 6. Start download process
|
||||||
result = await self._execute_download(
|
result = await self._execute_download(
|
||||||
|
|||||||
Reference in New Issue
Block a user