List Downloads
Display a paginated list of media downloads for the current user (or all users if admin).downloads
Middleware: auth, verified
Controller: MediaDownloadsController::index (app/Http/Controllers/MediaDownloadsController.php:30)
Query Parameters
Filter downloads by owner user IDs (admin only)
- Comma-separated list of user IDs
- Example:
"1,3,5" - Ignored for non-admin users
- Invalid IDs are filtered out
Response
Returns Inertia response renderingdownloads component.
Props:
Paginated collection of download references
- 10 items per page
- Ordered by
created_atDESC - Includes related media information
- For admins: includes owner details (id, name, email)
- Merged with live Aria2 download status
Available owner filter options (admin only)
- Array of user objects with id, name, email
- Only includes users who have downloads
Download Status Fields
Each download includes real-time status from Aria2:gid- Aria2 download identifierstatus- Download status (active, waiting, paused, error, complete, removed)totalLength- Total file size in bytescompletedLength- Downloaded bytesdownloadSpeed- Current download speed (bytes/sec)errorCode- Error code if failederrorMessage- Error description if faileddir- Download destination directoryfiles- Array of file information
User Filtering
Members: Only see their own downloadsExample
Edit Download
Perform an action on a download (pause, resume, retry, cancel, remove).downloads.edit
Middleware: auth, verified, can:download-operations,model
Controller: MediaDownloadsController::edit (app/Http/Controllers/MediaDownloadsController.php:79)
Path Parameters
Download reference ID
- Must be numeric
- User must have permission to modify this download
Request Body
Action to perform on the download
pause- Pause active downloadresume- Resume paused downloadretry- Retry failed downloadcancel- Cancel download and optionally delete partial fileremove- Remove download from list- Validated via
MediaDownloadActionenum
Whether to delete partial file when canceling
- Only applies when
actioniscancel - Default: false
Whether to restart download from beginning when retrying
- Only applies when
actionisretry - Default: false
Response
Returns redirect back to previous page. Success Messages:- “Download canceled successfully.”
- “Download retried successfully.”
- “Download status updated successfully.”
- “This download is already canceled and cannot be modified.”
- “Retry is temporarily unavailable while this download is cooling down.”
- “You cannot a download in status.”
- “Unsupported download action.”
- Aria2 error messages
Action Validation
Actions are validated against current download status:- Active downloads: can pause, cancel
- Paused downloads: can resume, cancel
- Error/Complete downloads: can retry, remove
- Waiting downloads: can cancel
Special Behaviors
Cancel Action:- Stops Aria2 download
- Optionally deletes partial file
- Marks download as canceled in database
- Sets
canceled_attimestamp
- Checks retry cooldown period
- Removes old Aria2 task
- Creates new download with same parameters
- Updates database record with new GID
- Can optionally restart from zero
- Sends command to Aria2
- Updates
desired_pausedflag in database - Maintains user’s pause preference
- Removes result from Aria2
- Deletes MediaDownloadRef record
Example
Delete Download
Cancel a download (shorthand for PATCH with cancel action).downloads.destroy
Middleware: auth, verified, can:download-operations,model
Controller: MediaDownloadsController::destroy (app/Http/Controllers/MediaDownloadsController.php:156)
Path Parameters
Download reference ID
- Must be numeric
- User must have permission to modify this download
Response
Returns redirect back to previous page. Success:- Aria2 error messages if cancellation fails
Behavior
This endpoint is a convenience wrapper that:- Calls
CancelDownload::run($model, false) - Does NOT delete partial file
- Cancels the Aria2 download
- Marks download as canceled
Example
Download Permissions
Thecan:download-operations,model middleware enforces ownership:
Permission Logic
Members:- Can only modify their own downloads
- Checked via
user_idmatching
- Can modify any user’s downloads
- No ownership restriction
Database Policy
Permissions are enforced through Laravel’s authorization gates, checking:MediaDownloadRef Model
Downloads are stored in theMediaDownloadRef model:
Key Fields:
id- Primary keygid- Aria2 download GID (unique)user_id- Owner user IDdownloadable_type- Media type (VodStream or Series)downloadable_id- Media ID (stream_id or series_id)episode_id- Episode ID (for series only)canceled_at- Cancellation timestampretry_next_at- Earliest retry time (cooldown)desired_paused- User’s pause preferencecreated_at- When download was created
owner- User who initiated downloadmedia- Polymorphic relation to VodStream or Series
Aria2 Integration
Downloads are managed through Aria2 JSON-RPC API:Status Retrieval
Download Operations
Pause:Error Handling
Aria2 errors are caught and returned to user:- GID not found
- Invalid status transition
- Network/connection issues
- Disk space issues
Download Actions
Actions are defined in theMediaDownloadAction enum:
Available Actions
Controller Reference: EditMediaDownloadData.php:7-18Download Creation Flow
Downloads are initiated from movie or series endpoints:Movie Download
- User accesses
GET /movies/{id}/download - System fetches movie info from Xtream Codes
- Checks for existing active downloads
- Creates Xtream Codes download URL
- Initiates Aria2 download with generated filename
- Creates MediaDownloadRef record
- Redirects to downloads page
Series Episode Download
- User accesses
GET /series/{id}/{season}/{episode}/download - System fetches series info from Xtream Codes
- Validates episode exists
- Checks for existing active downloads
- Creates Xtream Codes download URL
- Initiates Aria2 download with generated filename
- Creates MediaDownloadRef record
- Redirects to downloads page
Batch Episode Download
- User posts to
POST /series/{id}/downloadwith episode list - System validates all episodes exist
- Creates download URLs for all episodes
- Initiates batch download via Aria2
- Creates MediaDownloadRef records in transaction
- Redirects to downloads page
Next Steps
Movies API
Learn about movie download endpoints
Series API
Learn about series download endpoints
Authentication
Understand download permissions