feat(player): add explicit detection, inline audio preview, seeking scrubber, and stream endpoint
This commit is contained in:
1 parent
49bd123a03
commit
30ba67c707
5 files changed
+382
-20
No files matched your search
+34
@@ -79,6 +79,40 @@ async def direct_download(url: str = Query(...)):
|
||||
headers={"Content-Disposition": f"attachment; filename*=UTF-8''{encoded_filename}"}
|
||||
)
|
||||
|
||||
@app.get("/api/stream")
|
||||
async def stream_audio(url: str = Query(...)):
|
||||
"""Stream audio track for in-browser playback and seeking with HTTP Range support."""
|
||||
provider = sync_manager.get_provider(url)
|
||||
tracks = await provider.resolve(url)
|
||||
if not tracks:
|
||||
raise HTTPException(status_code=404, detail="Track not found")
|
||||
|
||||
track = tracks[0]
|
||||
dest_path = get_track_dest_path(
|
||||
settings.MUSIC_DIR,
|
||||
artist=track.artist,
|
||||
album=track.album or "Singles",
|
||||
track_num=track.track_number,
|
||||
title=track.title,
|
||||
ext="mp3"
|
||||
)
|
||||
|
||||
if not os.path.exists(dest_path):
|
||||
success = await provider.download_track(track, dest_path)
|
||||
if not success and track.service == "yandex":
|
||||
success = await sync_manager.universal_provider.download_track(track, dest_path)
|
||||
if not success:
|
||||
raise HTTPException(status_code=500, detail="Failed to fetch track audio")
|
||||
|
||||
return FileResponse(
|
||||
dest_path,
|
||||
media_type="audio/mpeg",
|
||||
headers={
|
||||
"Accept-Ranges": "bytes",
|
||||
"Content-Disposition": "inline"
|
||||
}
|
||||
)
|
||||
|
||||
@app.post("/api/sync/yandex-likes")
|
||||
async def sync_yandex_likes():
|
||||
if not settings.YANDEX_MUSIC_TOKEN:
|
||||
|
||||
Reference in new issue
Block a user