feat(stream): update stream route to /api/stream and add sound to main playlist upon creation
This commit is contained in:
@@ -95,7 +95,7 @@ def create_app():
|
|||||||
app.register_blueprint(admin.bp, url_prefix="/api/admin")
|
app.register_blueprint(admin.bp, url_prefix="/api/admin")
|
||||||
app.register_blueprint(admin_sounds.bp, url_prefix="/api/admin/sounds")
|
app.register_blueprint(admin_sounds.bp, url_prefix="/api/admin/sounds")
|
||||||
app.register_blueprint(soundboard.bp, url_prefix="/api/soundboard")
|
app.register_blueprint(soundboard.bp, url_prefix="/api/soundboard")
|
||||||
app.register_blueprint(stream.bp, url_prefix="/api/streams")
|
app.register_blueprint(stream.bp, url_prefix="/api/stream")
|
||||||
|
|
||||||
# Shutdown scheduler when app is torn down
|
# Shutdown scheduler when app is torn down
|
||||||
@app.teardown_appcontext
|
@app.teardown_appcontext
|
||||||
|
|||||||
@@ -451,6 +451,9 @@ class StreamProcessingService:
|
|||||||
db.session.add(sound)
|
db.session.add(sound)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
# Add sound to main playlist
|
||||||
|
cls._add_sound_to_main_playlist(sound)
|
||||||
|
|
||||||
return sound, None
|
return sound, None
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -519,6 +522,25 @@ class StreamProcessingService:
|
|||||||
|
|
||||||
return urlparse(url).path.split("/")[-1] or "unknown"
|
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
|
@classmethod
|
||||||
def _calculate_file_hash(cls, file_path: str) -> str:
|
def _calculate_file_hash(cls, file_path: str) -> str:
|
||||||
"""Calculate SHA256 hash of file."""
|
"""Calculate SHA256 hash of file."""
|
||||||
|
|||||||
Reference in New Issue
Block a user