diff --git a/py/services/civitai_client.py b/py/services/civitai_client.py index 13fc55c6..32d027c6 100644 --- a/py/services/civitai_client.py +++ b/py/services/civitai_client.py @@ -76,9 +76,15 @@ class CivitaiClient: headers = self._get_request_headers() async with session.get(url, headers=headers, allow_redirects=True) as response: if response.status != 200: - # Handle early access 401 unauthorized responses + # Handle 401 unauthorized responses if response.status == 401: logger.warning(f"Unauthorized access to resource: {url} (Status 401)") + + # Check if this is an API key issue (has Set-Cookie headers) + if 'Set-Cookie' in response.headers: + return False, "Invalid or missing CivitAI API key. Please check your API key in settings." + + # Otherwise it's an early access restriction return False, "Early access restriction: You must purchase early access to download this LoRA." # Handle other client errors that might be permission-related @@ -251,4 +257,4 @@ class CivitaiClient: return None except Exception as e: logger.error(f"Error getting hash from Civitai: {e}") - return None \ No newline at end of file + return None diff --git a/py/services/download_manager.py b/py/services/download_manager.py index 5e6746f7..add2ce86 100644 --- a/py/services/download_manager.py +++ b/py/services/download_manager.py @@ -29,7 +29,7 @@ class DownloadManager: return {'success': False, 'error': 'Failed to fetch model metadata'} # Check if this is an early access LoRA - if 'earlyAccessEndsAt' in version_info: + if version_info.get('earlyAccessEndsAt'): early_access_date = version_info.get('earlyAccessEndsAt', '') # Convert to a readable date if possible try: