diff --git a/py/services/download_manager.py b/py/services/download_manager.py index d30426ca..47d27d5b 100644 --- a/py/services/download_manager.py +++ b/py/services/download_manager.py @@ -88,16 +88,16 @@ class DownloadManager: version_info = None error_msg = None - if download_url: - # Extract version ID from download URL - version_id = download_url.split('/')[-1] - version_info, error_msg = await civitai_client.get_model_version_info(version_id) + if model_hash: + # Get model by hash + version_info = await civitai_client.get_model_by_hash(model_hash) elif model_version_id: # Use model version ID directly version_info, error_msg = await civitai_client.get_model_version_info(model_version_id) - elif model_hash: - # Get model by hash - version_info = await civitai_client.get_model_by_hash(model_hash) + elif download_url: + # Extract version ID from download URL + version_id = download_url.split('/')[-1] + version_info, error_msg = await civitai_client.get_model_version_info(version_id) if not version_info: diff --git a/py/utils/recipe_parsers.py b/py/utils/recipe_parsers.py index e9a1ea0c..9faded4a 100644 --- a/py/utils/recipe_parsers.py +++ b/py/utils/recipe_parsers.py @@ -97,8 +97,9 @@ class RecipeMetadataParser(ABC): # Process file information if available if 'files' in civitai_info: + # Find the primary model file (type="Model" and primary=true) in the files list model_file = next((file for file in civitai_info.get('files', []) - if file.get('type') == 'Model'), None) + if file.get('type') == 'Model' and file.get('primary') == True), None) if model_file: # Get size