from fastapi import FastAPI, Query, HTTPException from fastapi.responses import JSONResponse from downloader import download_song from config import settings app = FastAPI(title="Tunedrop") @app.get("/download") def download(query: str = Query(..., description="Song name or YouTube search term")): try: result = download_song(query) return JSONResponse(content={"status": "success", **result}) except Exception as e: raise HTTPException(status_code=500, detail=str(e))