fix dict error on gui verison for manual searches
This commit is contained in:
parent
bb15cf8f9f
commit
9e3c64115b
1 changed files with 30 additions and 13 deletions
|
|
@ -629,10 +629,16 @@ class SoulseekClient:
|
||||||
logger.error("No response from search POST request")
|
logger.error("No response from search POST request")
|
||||||
return [], []
|
return [], []
|
||||||
|
|
||||||
search_id = response.get('id')
|
# Handle both dict and list responses from slskd API
|
||||||
|
search_id = None
|
||||||
|
if isinstance(response, dict):
|
||||||
|
search_id = response.get('id')
|
||||||
|
elif isinstance(response, list) and len(response) > 0:
|
||||||
|
search_id = response[0].get('id') if isinstance(response[0], dict) else None
|
||||||
|
|
||||||
if not search_id:
|
if not search_id:
|
||||||
logger.error("No search ID returned from POST request")
|
logger.error("No search ID returned from POST request")
|
||||||
logger.debug(f"Full response: {response}")
|
logger.debug(f"Full response (type: {type(response)}): {response}")
|
||||||
return [], []
|
return [], []
|
||||||
|
|
||||||
logger.info(f"Search initiated with ID: {search_id}")
|
logger.info(f"Search initiated with ID: {search_id}")
|
||||||
|
|
@ -845,16 +851,27 @@ class SoulseekClient:
|
||||||
if not response:
|
if not response:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# Handle both dict and list responses (slskd API can vary)
|
||||||
|
download_data = None
|
||||||
|
if isinstance(response, dict):
|
||||||
|
download_data = response
|
||||||
|
elif isinstance(response, list) and len(response) > 0 and isinstance(response[0], dict):
|
||||||
|
download_data = response[0]
|
||||||
|
|
||||||
|
if not download_data:
|
||||||
|
logger.error(f"Invalid response format for download status (type: {type(response)})")
|
||||||
|
return None
|
||||||
|
|
||||||
return DownloadStatus(
|
return DownloadStatus(
|
||||||
id=response.get('id', ''),
|
id=download_data.get('id', ''),
|
||||||
filename=response.get('filename', ''),
|
filename=download_data.get('filename', ''),
|
||||||
username=response.get('username', ''),
|
username=download_data.get('username', ''),
|
||||||
state=response.get('state', ''),
|
state=download_data.get('state', ''),
|
||||||
progress=response.get('percentComplete', 0.0),
|
progress=download_data.get('percentComplete', 0.0),
|
||||||
size=response.get('size', 0),
|
size=download_data.get('size', 0),
|
||||||
transferred=response.get('bytesTransferred', 0),
|
transferred=download_data.get('bytesTransferred', 0),
|
||||||
speed=response.get('averageSpeed', 0),
|
speed=download_data.get('averageSpeed', 0),
|
||||||
time_remaining=response.get('timeRemaining')
|
time_remaining=download_data.get('timeRemaining')
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue