Refactor sound and extraction services to include user and timestamp fields
- Updated ExtractionInfo to include user_id, created_at, and updated_at fields. - Modified ExtractionService to return user and timestamp information in extraction responses. - Enhanced sound serialization in PlayerState to include extraction URL if available. - Adjusted PlaylistRepository to load sound extractions when retrieving playlist sounds. - Added tests for new fields in extraction and sound endpoints, ensuring proper response structure. - Created new test file endpoints for sound downloads and thumbnail retrievals, including success and error cases. - Refactored various test cases for consistency and clarity, ensuring proper mocking and assertions.
This commit is contained in:
@@ -87,6 +87,14 @@ class PlayerState:
|
||||
"""Serialize a sound object for JSON serialization."""
|
||||
if not sound:
|
||||
return None
|
||||
|
||||
# Get extraction URL if sound is linked to an extraction
|
||||
extract_url = None
|
||||
if hasattr(sound, "extractions") and sound.extractions:
|
||||
# Get the first extraction (there should only be one per sound)
|
||||
extraction = sound.extractions[0]
|
||||
extract_url = extraction.url
|
||||
|
||||
return {
|
||||
"id": sound.id,
|
||||
"name": sound.name,
|
||||
@@ -96,6 +104,7 @@ class PlayerState:
|
||||
"type": sound.type,
|
||||
"thumbnail": sound.thumbnail,
|
||||
"play_count": sound.play_count,
|
||||
"extract_url": extract_url,
|
||||
}
|
||||
|
||||
|
||||
@@ -585,7 +594,8 @@ class PlayerService:
|
||||
|
||||
# Check if track finished
|
||||
player_state = self._player.get_state()
|
||||
if hasattr(vlc, "State") and player_state == vlc.State.Ended:
|
||||
vlc_state_ended = 6 # vlc.State.Ended value
|
||||
if player_state == vlc_state_ended:
|
||||
# Track finished, handle auto-advance
|
||||
self._schedule_async_task(self._handle_track_finished())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user