feat(stream): update stream route to /api/stream and add sound to main playlist upon creation
This commit is contained in:
@@ -451,6 +451,9 @@ class StreamProcessingService:
|
||||
db.session.add(sound)
|
||||
db.session.commit()
|
||||
|
||||
# Add sound to main playlist
|
||||
cls._add_sound_to_main_playlist(sound)
|
||||
|
||||
return sound, None
|
||||
|
||||
except Exception as e:
|
||||
@@ -519,6 +522,25 @@ class StreamProcessingService:
|
||||
|
||||
return urlparse(url).path.split("/")[-1] or "unknown"
|
||||
|
||||
@classmethod
|
||||
def _add_sound_to_main_playlist(cls, sound: Sound) -> None:
|
||||
"""Add a sound to the main playlist."""
|
||||
try:
|
||||
from app.models.playlist import Playlist
|
||||
|
||||
# Find the main playlist
|
||||
main_playlist = Playlist.find_main_playlist()
|
||||
|
||||
if main_playlist:
|
||||
# Add sound to the main playlist
|
||||
main_playlist.add_sound(sound.id, commit=True)
|
||||
logger.info(f"Added sound {sound.id} to main playlist")
|
||||
else:
|
||||
logger.warning("Main playlist not found - sound not added to any playlist")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to add sound {sound.id} to main playlist: {e}")
|
||||
|
||||
@classmethod
|
||||
def _calculate_file_hash(cls, file_path: str) -> str:
|
||||
"""Calculate SHA256 hash of file."""
|
||||
|
||||
Reference in New Issue
Block a user