Add track filtering, WS keepalive, and improve error handling
- Add track filtering by uploader (my tracks / all tracks) with UI tabs - Add WebSocket ping/pong keepalive (30s interval) to prevent disconnects - Add auto-reconnect on WebSocket close (3s delay) - Add request logging middleware with DATABASE_URL output on startup - Handle missing S3 files gracefully (return 404 instead of 500) - Add debug logging for audio ended event 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -19,8 +19,16 @@ router = APIRouter(prefix="/api/tracks", tags=["tracks"])
|
||||
|
||||
|
||||
@router.get("", response_model=list[TrackResponse])
|
||||
async def get_tracks(db: AsyncSession = Depends(get_db)):
|
||||
result = await db.execute(select(Track).order_by(Track.created_at.desc()))
|
||||
async def get_tracks(
|
||||
my: bool = False,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user)
|
||||
):
|
||||
query = select(Track)
|
||||
if my:
|
||||
query = query.where(Track.uploaded_by == current_user.id)
|
||||
query = query.order_by(Track.created_at.desc())
|
||||
result = await db.execute(query)
|
||||
return result.scalars().all()
|
||||
|
||||
|
||||
@@ -174,6 +182,8 @@ async def stream_track(track_id: uuid.UUID, request: Request, db: AsyncSession =
|
||||
|
||||
# Get file size from S3 (without downloading)
|
||||
file_size = get_file_size(track.s3_key)
|
||||
if file_size is None:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Track file not found in storage")
|
||||
|
||||
# Encode filename for non-ASCII characters
|
||||
encoded_filename = quote(f"{track.title}.mp3")
|
||||
|
||||
Reference in New Issue
Block a user