refactor: Remove unused playlist routes and related logic; clean up sound and stream models
This commit is contained in:
@@ -93,11 +93,14 @@ def seek():
|
||||
data = request.get_json()
|
||||
if not data or "position" not in data:
|
||||
return jsonify({"error": "Position required"}), 400
|
||||
|
||||
|
||||
position = float(data["position"])
|
||||
if not 0.0 <= position <= 1.0:
|
||||
return jsonify({"error": "Position must be between 0.0 and 1.0"}), 400
|
||||
|
||||
return (
|
||||
jsonify({"error": "Position must be between 0.0 and 1.0"}),
|
||||
400,
|
||||
)
|
||||
|
||||
success = music_player_service.seek(position)
|
||||
if success:
|
||||
return jsonify({"message": "Seek successful"}), 200
|
||||
@@ -116,11 +119,11 @@ def set_volume():
|
||||
data = request.get_json()
|
||||
if not data or "volume" not in data:
|
||||
return jsonify({"error": "Volume required"}), 400
|
||||
|
||||
|
||||
volume = int(data["volume"])
|
||||
if not 0 <= volume <= 100:
|
||||
return jsonify({"error": "Volume must be between 0 and 100"}), 400
|
||||
|
||||
|
||||
success = music_player_service.set_volume(volume)
|
||||
if success:
|
||||
return jsonify({"message": "Volume set successfully"}), 200
|
||||
@@ -139,12 +142,23 @@ def set_play_mode():
|
||||
data = request.get_json()
|
||||
if not data or "mode" not in data:
|
||||
return jsonify({"error": "Mode required"}), 400
|
||||
|
||||
|
||||
mode = data["mode"]
|
||||
valid_modes = ["continuous", "loop-playlist", "loop-one", "random", "single"]
|
||||
valid_modes = [
|
||||
"continuous",
|
||||
"loop-playlist",
|
||||
"loop-one",
|
||||
"random",
|
||||
"single",
|
||||
]
|
||||
if mode not in valid_modes:
|
||||
return jsonify({"error": f"Mode must be one of: {', '.join(valid_modes)}"}), 400
|
||||
|
||||
return (
|
||||
jsonify(
|
||||
{"error": f"Mode must be one of: {', '.join(valid_modes)}"}
|
||||
),
|
||||
400,
|
||||
)
|
||||
|
||||
success = music_player_service.set_play_mode(mode)
|
||||
if success:
|
||||
return jsonify({"message": "Play mode set successfully"}), 200
|
||||
@@ -161,7 +175,7 @@ def load_playlist():
|
||||
data = request.get_json()
|
||||
if not data or "playlist_id" not in data:
|
||||
return jsonify({"error": "Playlist ID required"}), 400
|
||||
|
||||
|
||||
playlist_id = int(data["playlist_id"])
|
||||
success = music_player_service.load_playlist(playlist_id)
|
||||
if success:
|
||||
@@ -181,7 +195,7 @@ def play_track():
|
||||
data = request.get_json()
|
||||
if not data or "index" not in data:
|
||||
return jsonify({"error": "Track index required"}), 400
|
||||
|
||||
|
||||
index = int(data["index"])
|
||||
success = music_player_service.play_track_at_index(index)
|
||||
if success:
|
||||
@@ -191,42 +205,3 @@ def play_track():
|
||||
return jsonify({"error": "Invalid track index"}), 400
|
||||
except Exception as e:
|
||||
return ErrorHandlingService.handle_generic_error(e)
|
||||
|
||||
|
||||
@bp.route("/start-instance", methods=["POST"])
|
||||
@require_auth
|
||||
def start_vlc_instance():
|
||||
"""Start the VLC player instance."""
|
||||
try:
|
||||
success = music_player_service.start_vlc_instance()
|
||||
if success:
|
||||
return jsonify({"message": "VLC instance started successfully"}), 200
|
||||
return jsonify({"error": "Failed to start VLC instance"}), 500
|
||||
except Exception as e:
|
||||
return ErrorHandlingService.handle_generic_error(e)
|
||||
|
||||
|
||||
@bp.route("/stop-instance", methods=["POST"])
|
||||
@require_auth
|
||||
def stop_vlc_instance():
|
||||
"""Stop the VLC player instance."""
|
||||
try:
|
||||
success = music_player_service.stop_vlc_instance()
|
||||
if success:
|
||||
return jsonify({"message": "VLC instance stopped successfully"}), 200
|
||||
return jsonify({"error": "Failed to stop VLC instance"}), 500
|
||||
except Exception as e:
|
||||
return ErrorHandlingService.handle_generic_error(e)
|
||||
|
||||
|
||||
|
||||
@bp.route("/test-emit", methods=["POST"])
|
||||
@require_auth
|
||||
def test_emit():
|
||||
"""Test SocketIO emission manually."""
|
||||
try:
|
||||
# Force emit player state
|
||||
music_player_service._emit_player_state()
|
||||
return jsonify({"message": "Test emission sent"}), 200
|
||||
except Exception as e:
|
||||
return ErrorHandlingService.handle_generic_error(e)
|
||||
Reference in New Issue
Block a user