refactor: Update PlayerState to improve serialization structure for current sound and playlist
Some checks failed
Backend CI / test (push) Failing after 4m2s
Some checks failed
Backend CI / test (push) Failing after 4m2s
This commit is contained in:
@@ -64,18 +64,19 @@ class PlayerState:
|
|||||||
"status": self.status.value,
|
"status": self.status.value,
|
||||||
"mode": self.mode.value,
|
"mode": self.mode.value,
|
||||||
"volume": self.volume,
|
"volume": self.volume,
|
||||||
"current_sound_id": self.current_sound_id,
|
"position_ms": self.current_sound_position or 0,
|
||||||
"current_sound_index": self.current_sound_index,
|
"duration_ms": self.current_sound_duration,
|
||||||
"current_sound_position": self.current_sound_position,
|
"index": self.current_sound_index,
|
||||||
"current_sound_duration": self.current_sound_duration,
|
|
||||||
"current_sound": self._serialize_sound(self.current_sound),
|
"current_sound": self._serialize_sound(self.current_sound),
|
||||||
"playlist_id": self.playlist_id,
|
"playlist": {
|
||||||
"playlist_name": self.playlist_name,
|
"id": self.playlist_id,
|
||||||
"playlist_length": self.playlist_length,
|
"name": self.playlist_name,
|
||||||
"playlist_duration": self.playlist_duration,
|
"length": self.playlist_length,
|
||||||
"playlist_sounds": [
|
"duration": self.playlist_duration,
|
||||||
self._serialize_sound(sound) for sound in self.playlist_sounds
|
"sounds": [
|
||||||
],
|
self._serialize_sound(sound) for sound in self.playlist_sounds
|
||||||
|
],
|
||||||
|
} if self.playlist_id else None,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _serialize_sound(self, sound: Sound | None) -> dict[str, Any] | None:
|
def _serialize_sound(self, sound: Sound | None) -> dict[str, Any] | None:
|
||||||
|
|||||||
Reference in New Issue
Block a user