feat(server): route URL/playlist /fetch to download jobs
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,21 @@ def fetch(q: str = Query(..., min_length=1),
|
||||
source: str = Query("auto")):
|
||||
if quality not in mf.QUALITY_CHOICES:
|
||||
raise HTTPException(status_code=422, detail=f"Invalid quality '{quality}'.")
|
||||
|
||||
if mf.is_url(q):
|
||||
kind = "playlist" if mf.is_playlist_url(q) else "track"
|
||||
syn = mf.Hit(source="youtube", kind=kind, title="", artist="")
|
||||
job = jobs.create_job(hit=syn, message=actions.url_started_message(kind))
|
||||
response = _job_public(job)
|
||||
done_msg = actions.playlist_done_message if kind == "playlist" else actions.url_done_message
|
||||
jobs.run_job(
|
||||
job.id,
|
||||
lambda: actions.perform_url_fetch(q, quality, ROOT),
|
||||
done_message=done_msg,
|
||||
fail_message="Download failed.",
|
||||
)
|
||||
return response
|
||||
|
||||
if source not in ("auto", "lidarr", "youtube"):
|
||||
raise HTTPException(status_code=422, detail=f"Invalid source '{source}'.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user