From 8f15dc039d1d8726796633383ede9259bd0bfef3 Mon Sep 17 00:00:00 2001 From: Broque Thomas Date: Mon, 29 Dec 2025 14:54:28 -0800 Subject: [PATCH] Convert track duration to milliseconds in search results Updated the duration field in TrackResult to store duration in milliseconds instead of seconds, matching Spotify's expected format. This ensures consistency when integrating with services that use millisecond-based durations. --- core/soulseek_client.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/soulseek_client.py b/core/soulseek_client.py index 9c51f813..30a0766b 100644 --- a/core/soulseek_client.py +++ b/core/soulseek_client.py @@ -18,7 +18,7 @@ class SearchResult: filename: str size: int bitrate: Optional[int] - duration: Optional[int] + duration: Optional[int] # Duration in milliseconds (converted from slskd's seconds) quality: str free_upload_slots: int upload_speed: int @@ -429,12 +429,16 @@ class SoulseekClient: quality = file_ext if file_ext in ['flac', 'mp3', 'ogg', 'aac', 'wma'] else 'unknown' # Create TrackResult + # Convert duration from seconds to milliseconds (slskd returns seconds, Spotify uses ms) + raw_duration = file_data.get('length') + duration_ms = raw_duration * 1000 if raw_duration else None + track = TrackResult( username=username, filename=filename, size=size, bitrate=file_data.get('bitRate'), - duration=file_data.get('length'), + duration=duration_ms, quality=quality, free_upload_slots=response_data.get('freeUploadSlots', 0), upload_speed=response_data.get('uploadSpeed', 0),