feat(main): main

This commit is contained in:
2026-03-09 13:29:23 -04:00
parent f14454b4c8
commit b1a93161c0
22 changed files with 719 additions and 192 deletions

View File

@@ -176,3 +176,21 @@ def download_item(request, item_id: int):
except Exception as exc:
from ninja.errors import HttpError
raise HttpError(500, f"Download failed: {exc}")
@router.get("/{item_id}/progress", response=dict)
def download_progress(request, item_id: int):
"""
Return the current download progress string (e.g. '45.1%') from the yt-dlp hook.
"""
from django.core.cache import cache
item = get_object_or_404(MediaItem, id=item_id)
if not item.youtube_video_id:
from ninja.errors import HttpError
raise HttpError(400, "MediaItem is not a YouTube video.")
if item.cached_file_path:
return {"status": "finished", "progress": "100%"}
pct = cache.get(f"yt_progress_{item.youtube_video_id}")
return {"status": "downloading" if pct else "unknown", "progress": pct or "0%"}