from fastapi import APIRouter, Depends, HTTPException from core.database import fake_users_db from typing import List, Optional router = APIRouter() @router.post("/api/v1/endpoint") async def get_playlist_songs( playlist_id: str, limit: Optional[int] = 50, offset: Optional[int] = 0 ): """Fetch songs from a playlist""" if not playlist_id: raise HTTPException(status_code=400, detail="Playlist ID is required") # Demo playlist data structure fake_playlists_db = { "playlist1": [ {"id": "1", "title": "Song 1", "artist": "Artist 1", "duration": "3:45"}, {"id": "2", "title": "Song 2", "artist": "Artist 2", "duration": "4:20"}, {"id": "3", "title": "Song 3", "artist": "Artist 3", "duration": "3:15"} ] } playlist = fake_playlists_db.get(playlist_id) if not playlist: raise HTTPException(status_code=404, detail="Playlist not found") paginated_songs = playlist[offset:offset + limit] return { "message": "Songs fetched successfully", "data": { "playlist_id": playlist_id, "songs": paginated_songs, "total_songs": len(playlist) }, "metadata": { "limit": limit, "offset": offset, "has_more": (offset + limit) < len(playlist) } }