- Concert Finder: Bandsintown API integration to find upcoming shows for recommended artists, with expandable tour dates section on recommendation cards - Rabbit Hole: Multi-step guided discovery journey where each song connects to the next through a shared musical quality (producer, influence, tone, etc.) - New /rabbit-hole route with seed input, step count selector, and vertical chain visualization of connected songs - Added concerts endpoint, rabbit hole endpoint, and corresponding frontend API functions and navigation
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
from urllib.parse import quote
|
|
|
|
import httpx
|
|
from fastapi import APIRouter, Depends, Query
|
|
|
|
from app.core.security import get_current_user
|
|
from app.models.user import User
|
|
|
|
router = APIRouter(prefix="/concerts", tags=["concerts"])
|
|
|
|
|
|
@router.get("")
|
|
async def find_concerts(
|
|
artist: str = Query(...),
|
|
user: User = Depends(get_current_user),
|
|
):
|
|
"""Find upcoming concerts for an artist using Bandsintown API."""
|
|
url = f"https://rest.bandsintown.com/artists/{quote(artist)}/events"
|
|
async with httpx.AsyncClient(timeout=10) as client:
|
|
resp = await client.get(url, params={"app_id": "vynl", "date": "upcoming"})
|
|
|
|
if resp.status_code != 200:
|
|
return {"events": []}
|
|
|
|
events = resp.json()
|
|
if not isinstance(events, list):
|
|
return {"events": []}
|
|
|
|
return {
|
|
"artist": artist,
|
|
"events": [
|
|
{
|
|
"date": e.get("datetime", ""),
|
|
"venue": e.get("venue", {}).get("name", ""),
|
|
"city": e.get("venue", {}).get("city", ""),
|
|
"region": e.get("venue", {}).get("region", ""),
|
|
"country": e.get("venue", {}).get("country", ""),
|
|
"url": e.get("url", ""),
|
|
}
|
|
for e in events[:10]
|
|
],
|
|
}
|