This is a simple Flask api server for managing torrent downloads using the libtorrent library.
TORRENT_SERVER_API
: Set the port for the Flask API. Default is5000
.TORRENT_SERVER_DEBUG
: Set toTrue
for Flask debug mode, orFalse
(default) otherwise.TORRENT_SERVER_CONFIG
: Path to the configuration file. Default isconfig.yaml
.
download_dir: "./downloads"
default_upload_speed: 1000
default_download_speed: 1000
`download_dir`: The directory where downloaded torrents will be saved.
`default_upload_speed`: Default upload speed for new torrents in KB/s.
`default_download_speed`: Default download speed for new torrents in KB/s.
## API Documentation
### Add a Torrent
**Endpoint:**
POST /api/v1/torrent
**Request Body:**
```json
{
"magnet_link": "magnet:?xt=urn:btih:..."
}
Response:
{
"message": "Torrent added successfully",
"torrent_id": "1"
}
Endpoint:
GET /api/v1/torrent
Response:
{
"torrent_ids": ["1", "2"]
}
Endpoint:
DELETE /api/v1/torrent/<torrent_id>
Response:
{
"message": "Torrent deleted successfully"
}
Endpoint:
GET /api/v1/torrent/<torrent_id>
Response:
{
"progress": 50,
"state": "Downloading",
"download_rate": 1024,
"upload_rate": 512,
"num_peers": 5
}
Endpoint:
POST /api/v1/torrent/<torrent_id>/pause
Response:
{
"message": "Torrent download paused"
}
Endpoint:
POST /api/v1/torrent/<torrent_id>/play
Response:
{
"message": "Torrent download resumed"
}
Endpoint:
GET /api/v1/torrent/<torrent_id>/progress
Response:
{
"progress": 75
}
Just use docker and Vagrant