diff --git a/config/config.example.json b/config/config.example.json new file mode 100644 index 00000000..47c0a263 --- /dev/null +++ b/config/config.example.json @@ -0,0 +1,45 @@ +{ + "active_media_server": "plex", + "spotify": { + "client_id": "SpotifyClientID", + "client_secret": "SpotifyClientSecret" + }, + "tidal": { + "client_id": "TidalClientID", + "client_secret": "TidalClientSecret" + }, + "plex": { + "base_url": "http://192.168.86.36:32400", + "token": "PLEX_API_TOKEN", + "auto_detect": true + }, + "jellyfin": { + "base_url": "http://localhost:8096", + "api_key": "JELLYFIN_API_KEY", + "auto_detect": true + }, + "soulseek": { + "slskd_url": "http://localhost:5030", + "api_key": "SoulseekAPIKey", + "download_path": "./Downloads", + "transfer_path": "./Transfer" + }, + "logging": { + "path": "logs/app.log", + "level": "INFO" + }, + "settings": { + "audio_quality": "flac" + }, + "database": { + "path": "database/music_library.db", + "max_workers": 5 + }, + "metadata_enhancement": { + "enabled": true, + "embed_album_art": true + }, + "playlist_sync": { + "create_backup": true + } +} \ No newline at end of file diff --git a/core/soulseek_client.py b/core/soulseek_client.py index 9183a145..74515799 100644 --- a/core/soulseek_client.py +++ b/core/soulseek_client.py @@ -308,7 +308,13 @@ class SoulseekClient: else: return {} else: - logger.error(f"API request failed: {response.status} - {response_text}") + # Enhanced error logging for better debugging + error_detail = response_text if response_text.strip() else "No error details provided" + logger.error(f"API request failed: HTTP {response.status} ({response.reason}) - {error_detail}") + + # Log the specific endpoint and method for debugging + logger.debug(f"Failed request: {method} {url}") + return None except Exception as e: @@ -907,14 +913,29 @@ class SoulseekClient: return False try: - # Use correct slskd API format: DELETE /transfers/downloads/{username}/{download_id}?remove={true/false} - # remove=false: Cancel download but keep in transfer list - # remove=true: Remove download completely from transfer list - endpoint = f'transfers/downloads/{username}/{download_id}?remove={str(remove).lower()}' + # Try multiple API formats as slskd API may vary between versions + endpoints_to_try = [ + # Format 1: With username and remove parameter (original format) + f'transfers/downloads/{username}/{download_id}?remove={str(remove).lower()}', + # Format 2: Simple format with just download_id (used in sync.py) + f'transfers/downloads/{download_id}', + # Format 3: Alternative format without remove parameter + f'transfers/downloads/{username}/{download_id}' + ] + action = "Removing" if remove else "Cancelling" - logger.debug(f"{action} download with endpoint: {endpoint}") - response = await self._make_request('DELETE', endpoint) - return response is not None + + for i, endpoint in enumerate(endpoints_to_try): + logger.debug(f"{action} download (attempt {i+1}/3) with endpoint: {endpoint}") + response = await self._make_request('DELETE', endpoint) + if response is not None: + logger.info(f"✅ Successfully cancelled download using endpoint format {i+1}") + return True + else: + logger.debug(f"❌ Endpoint format {i+1} failed: {endpoint}") + + logger.error(f"❌ All cancel endpoint formats failed for download_id: {download_id}") + return False except Exception as e: logger.error(f"Error cancelling download: {e}")