fix: download status

This commit is contained in:
Lukas 2025-11-20 19:02:04 +01:00
parent cf503c8d77
commit 57da1f1272
4 changed files with 23 additions and 30 deletions

View File

@ -1,25 +1,5 @@
{
"pending": [
{
"id": "c1e7e4d3-fabd-4436-86de-89a612562ec7",
"serie_id": "highschool-dxd",
"serie_folder": "Highschool DxD",
"serie_name": "Highschool DxD",
"episode": {
"season": 1,
"episode": 1,
"title": null
},
"status": "pending",
"priority": "NORMAL",
"added_at": "2025-11-20T17:12:34.485109Z",
"started_at": null,
"completed_at": null,
"progress": null,
"error": null,
"retry_count": 0,
"source_url": null
},
{
"id": "1c4ade94-0a9f-4b75-8ed7-ceb8995c6865",
"serie_id": "highschool-dxd",
@ -983,5 +963,5 @@
],
"active": [],
"failed": [],
"timestamp": "2025-11-20T17:12:34.486863+00:00"
"timestamp": "2025-11-20T17:54:12.722000+00:00"
}

View File

@ -33,6 +33,7 @@ class DownloadStatusEventArgs:
error: Optional[Exception] = None,
eta: Optional[int] = None,
mbper_sec: Optional[float] = None,
item_id: Optional[str] = None,
):
"""
Initialize download status event arguments.
@ -47,6 +48,7 @@ class DownloadStatusEventArgs:
error: Optional error if status is "failed"
eta: Estimated time remaining in seconds
mbper_sec: Download speed in MB/s
item_id: Optional download queue item ID for tracking
"""
self.serie_folder = serie_folder
self.season = season
@ -57,6 +59,7 @@ class DownloadStatusEventArgs:
self.error = error
self.eta = eta
self.mbper_sec = mbper_sec
self.item_id = item_id
class ScanStatusEventArgs:
"""Event arguments for scan status events."""
@ -203,6 +206,7 @@ class SeriesApp:
episode: int,
key: str,
language: str = "German Dub",
item_id: Optional[str] = None,
) -> bool:
"""
Download an episode (async).
@ -213,6 +217,7 @@ class SeriesApp:
episode: Episode number
key: Serie key
language: Language preference
item_id: Optional download queue item ID for progress tracking
Returns:
True if download succeeded, False otherwise
@ -227,6 +232,7 @@ class SeriesApp:
episode=episode,
status="started",
message="Download started",
item_id=item_id,
)
)
@ -282,6 +288,7 @@ class SeriesApp:
status="completed",
progress=1.0,
message="Download completed successfully",
item_id=item_id,
)
)
else:
@ -297,6 +304,7 @@ class SeriesApp:
episode=episode,
status="failed",
message="Download failed",
item_id=item_id,
)
)
@ -321,6 +329,7 @@ class SeriesApp:
status="failed",
error=e,
message=f"Download error: {str(e)}",
item_id=item_id,
)
)

View File

@ -65,36 +65,45 @@ class AnimeService:
)
return
# Use item_id if available, otherwise fallback to constructing ID
progress_id = (
args.item_id
if args.item_id
else f"download_{args.serie_folder}_{args.season}_{args.episode}"
)
# Map SeriesApp download events to progress service
if args.status == "started":
loop.create_task(
self._progress_service.start_progress(
progress_id=f"download_{args.serie_folder}_{args.season}_{args.episode}", # noqa: E501
progress_id=progress_id,
progress_type=ProgressType.DOWNLOAD,
title=f"Downloading {args.serie_folder}",
message=f"S{args.season:02d}E{args.episode:02d}",
metadata={"item_id": args.item_id} if args.item_id else None,
)
)
elif args.status == "progress":
loop.create_task(
self._progress_service.update_progress(
progress_id=f"download_{args.serie_folder}_{args.season}_{args.episode}", # noqa: E501
progress_id=progress_id,
current=int(args.progress),
total=100,
message=args.message or "Downloading...",
metadata={"item_id": args.item_id} if args.item_id else None,
)
)
elif args.status == "completed":
loop.create_task(
self._progress_service.complete_progress(
progress_id=f"download_{args.serie_folder}_{args.season}_{args.episode}", # noqa: E501
progress_id=progress_id,
message="Download completed",
)
)
elif args.status == "failed":
loop.create_task(
self._progress_service.fail_progress(
progress_id=f"download_{args.serie_folder}_{args.season}_{args.episode}", # noqa: E501
progress_id=progress_id,
error_message=args.message or str(args.error),
)
)

View File

@ -236,12 +236,10 @@ class QueueManager {
try {
const response = await this.makeAuthenticatedRequest('/api/queue/status');
if (!response) {
console.warn('No response from queue status API');
return;
}
const data = await response.json();
console.log('Raw API response:', data);
// API returns nested structure with 'status' and 'statistics'
// Transform it to the expected flat structure
@ -250,9 +248,6 @@ class QueueManager {
statistics: data.statistics
};
console.log('Transformed queue data:', queueData);
console.log('Pending queue length:', queueData.pending_queue?.length);
this.updateQueueDisplay(queueData);
// Process any pending progress updates after queue is loaded