refactor: Remove unused playlist routes and related logic; clean up sound and stream models
This commit is contained in:
@@ -90,121 +90,3 @@ def add_url():
|
||||
except Exception as e:
|
||||
db.session.rollback()
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
@bp.route("/", methods=["GET"])
|
||||
@require_auth
|
||||
def list_streams():
|
||||
"""List all streams with optional filtering."""
|
||||
try:
|
||||
status = request.args.get("status")
|
||||
service = request.args.get("service")
|
||||
|
||||
query = Stream.query
|
||||
|
||||
if status:
|
||||
query = query.filter_by(status=status)
|
||||
if service:
|
||||
query = query.filter_by(service=service)
|
||||
|
||||
streams = query.order_by(Stream.created_at.desc()).all()
|
||||
|
||||
return (
|
||||
jsonify({"streams": [stream.to_dict() for stream in streams]}),
|
||||
200,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
@bp.route("/<int:stream_id>", methods=["GET"])
|
||||
@require_auth
|
||||
def get_stream(stream_id):
|
||||
"""Get a specific stream by ID."""
|
||||
try:
|
||||
stream = Stream.query.get_or_404(stream_id)
|
||||
return jsonify({"stream": stream.to_dict()}), 200
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
@bp.route("/<int:stream_id>", methods=["PUT"])
|
||||
@require_auth
|
||||
def update_stream(stream_id):
|
||||
"""Update stream metadata."""
|
||||
try:
|
||||
stream = Stream.query.get_or_404(stream_id)
|
||||
data = request.get_json()
|
||||
|
||||
if not data:
|
||||
return jsonify({"error": "No data provided"}), 400
|
||||
|
||||
# Update allowed fields
|
||||
updatable_fields = [
|
||||
"title",
|
||||
"track",
|
||||
"artist",
|
||||
"album",
|
||||
"genre",
|
||||
"status",
|
||||
]
|
||||
for field in updatable_fields:
|
||||
if field in data:
|
||||
setattr(stream, field, data[field])
|
||||
|
||||
db.session.commit()
|
||||
|
||||
return (
|
||||
jsonify(
|
||||
{
|
||||
"message": "Stream updated successfully",
|
||||
"stream": stream.to_dict(),
|
||||
}
|
||||
),
|
||||
200,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
db.session.rollback()
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
@bp.route("/<int:stream_id>", methods=["DELETE"])
|
||||
@require_auth
|
||||
def delete_stream(stream_id):
|
||||
"""Delete a stream."""
|
||||
try:
|
||||
stream = Stream.query.get_or_404(stream_id)
|
||||
|
||||
# If stream is being processed, mark for deletion instead
|
||||
if stream.status == "processing":
|
||||
stream.status = "cancelled"
|
||||
db.session.commit()
|
||||
return jsonify({"message": "Stream marked for cancellation"}), 200
|
||||
|
||||
db.session.delete(stream)
|
||||
db.session.commit()
|
||||
|
||||
return jsonify({"message": "Stream deleted successfully"}), 200
|
||||
|
||||
except Exception as e:
|
||||
db.session.rollback()
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
|
||||
@bp.route("/queue/status", methods=["GET"])
|
||||
@require_auth
|
||||
def queue_status():
|
||||
"""Get the current processing queue status."""
|
||||
try:
|
||||
from app.services.stream_processing_service import (
|
||||
StreamProcessingService,
|
||||
)
|
||||
|
||||
status = StreamProcessingService.get_queue_status()
|
||||
return jsonify(status), 200
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
Reference in New Issue
Block a user