2025-03-21 11:34:53 +00:00

32 lines
860 B
Python

from fastapi import APIRouter, HTTPException
playlists = [
{
"id": "playlist1",
"songs": [
{"id": "song1", "title": "Song One", "artist": "Artist A"},
{"id": "song2", "title": "Song Two", "artist": "Artist B"}
]
}
]
router = APIRouter()
@router.post("/playlist/songs")
async def get_playlist_songs(
playlist_id: str = "playlist1"
):
"""Fetch songs from a playlist"""
playlist = next((p for p in playlists if p["id"] == playlist_id), None)
if not playlist:
raise HTTPException(status_code=400, detail="Playlist not found")
return {
"message": "Songs fetched successfully",
"playlist_id": playlist_id,
"songs": playlist["songs"],
"features": {
"total_songs": len(playlist["songs"]),
"can_shuffle": True
}
}