from fastapi import APIRouter, Request, HTTPException from fastapi.responses import JSONResponse from app.services.tidal_wrapper import TidalWrapper router = APIRouter(prefix="/search", tags=["search"]) @router.get("/") async def search(query: str, type: str = "track"): wrapper = TidalWrapper() try: results = wrapper.search(query, type) return JSONResponse(results) except Exception as e: raise HTTPException(status_code=400, detail=str(e)) @router.get("/artist/{artist_id}/albums") async def get_artist_albums(artist_id: str): wrapper = TidalWrapper() try: albums = wrapper.get_artist_albums(artist_id) return JSONResponse(albums) except Exception as e: raise HTTPException(status_code=400, detail=str(e))