fix download

This commit is contained in:
2025-10-30 19:56:22 +01:00
parent adfbdf56d0
commit 627f8b0cc4
7 changed files with 159 additions and 184 deletions

View File

@@ -341,12 +341,6 @@ class AddSeriesRequest(BaseModel):
name: str
class DownloadFoldersRequest(BaseModel):
"""Request model for downloading missing episodes from folders."""
folders: List[str]
def validate_search_query(query: str) -> str:
"""Validate and sanitize search query.
@@ -594,48 +588,6 @@ async def add_series(
) from exc
@router.post("/download")
async def download_folders(
request: DownloadFoldersRequest,
_auth: dict = Depends(require_auth),
series_app: Any = Depends(get_series_app),
) -> dict:
"""Start downloading missing episodes from the specified folders.
Args:
request: Request containing list of folder names
_auth: Ensures the caller is authenticated (value unused)
series_app: Core `SeriesApp` instance provided via dependency
Returns:
Dict[str, Any]: Status payload with success message
Raises:
HTTPException: If download initiation fails
"""
try:
if not hasattr(series_app, "Download"):
raise HTTPException(
status_code=status.HTTP_501_NOT_IMPLEMENTED,
detail="Download functionality not available",
)
# Call Download with the folders and a no-op callback
series_app.Download(request.folders, lambda *args, **kwargs: None)
return {
"status": "success",
"message": f"Download started for {len(request.folders)} series"
}
except HTTPException:
raise
except Exception as exc:
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=f"Failed to start download: {str(exc)}",
) from exc
@router.get("/{anime_id}", response_model=AnimeDetail)
async def get_anime(
anime_id: str,