Sign inSign up

kroeberd/alldebrid-client

By kroeberd

•Updated 5 days ago

Self-hosted torrent automation via AllDebrid — Web UI, aria2, Discord, PostgreSQL, FlexGet integra

Image
0

10K+

kroeberd/alldebrid-client repository overview

AllDebrid-Client Logo

⁠AllDebrid-Client

Self-hosted torrent automation via AllDebrid
Web UI · built-in aria2 · Sonarr/Radarr (qBit API) · Jackett search · SSE live updates · Discord · Prometheus · PostgreSQL

Website Release Docker Pulls Discord License Tests CI Docker Build


⁠What it does

AllDebrid-Client automates the full torrent lifecycle via your AllDebrid account:

  1. Add magnet links or .torrent files via web UI, Jackett search, watch folder, Sonarr/Radarr, or REST API
  2. Upload to AllDebrid and poll until ready (bulk API, token-bucket rate limiter, automatic retry on failure)
  3. Unlock download links and submit them to aria2 in FIFO order
  4. Monitor aria2 until all files complete, then mark done and remove from AllDebrid
  5. Notify via Discord, trigger Sonarr/Radarr import, run post-processing scripts

⁠Features

CategoryDetails
Sonarr / RadarrNative qBittorrent v4.3.2 API emulation at /api/v2/ — configure as a standard qBit download client, no webhook setup needed
Input sourcesWeb UI paste, Jackett search (multi-indexer, bulk add), watch folder (.torrent/.magnet), Sonarr/Radarr, REST API
Download clientBuilt-in aria2 (default, zero setup) or external aria2 instance via JSON-RPC
Live updatesServer-Sent Events (SSE) push status changes instantly — no polling delay
Access controlOptional HTTP Basic Auth (Settings → Access Control); health-check paths exempt
Disk space guardAbort download before start if free space below threshold
Post-processingShell script run after each completed download ({name}, {path}, {torrent_id} placeholders, 300 s timeout)
Auto-extraction.zip, .rar, .7z, .tar.* and more after download; configurable concurrency and Discord notification
Error recoveryAuto-retry Upload Failed (code 5) and No Peers (code 8); ⟳ Recover All button; stuck-download cleanup
Rate limitingToken-bucket rate limiter for AllDebrid API (configurable req/min) — not a concurrency semaphore
FIFO queueOldest torrents always processed first (ORDER BY id ASC throughout all dispatch paths)
Discord webhooksRich embeds per event type: added, complete, error, upload-failed, no-peers, extraction, stats
Jackett searchMulti-indexer chip UI, category filters, per-row Add, Add Selected checkbox, Add All button
Prowlarr searchModern Jackett alternative; — same result format as Jackett
FlexGet v3Schedule and trigger tasks from UI; per-event Discord notifications
StatisticsPeriod selector (1h–all-time), rolling snapshots, Discord summary reports, JSON export
Prometheus metricsGET /api/metrics — torrent counts by status, active downloads, errors, SSE subscribers, bytes downloaded
DatabaseSQLite (zero-config default) or external PostgreSQL; automatic schema migration; 8 performance indexes
BackupsScheduled JSON backups with configurable interval and retention
Event log TTLAutomatic pruning of old event log entries (default: 30 days); torrent rows never deleted
DiagnosticsGET /api/torrents/diagnose — status breakdown; POST /api/torrents/recover-all — one-click recovery
State machineFormal torrent lifecycle with validated transitions (services/torrent_state.py)
Rule EngineJSON-based pre-upload rules: set download path, priority, label, block or pause torrents by title/size/source
Download ProfilesNamed preset bundles (path + priority + label); one active at a time, overrideable by rules
Saved SearchesScheduled Jackett/Prowlarr queries with auto-add and configurable intervals
Priority QueueInteger priority field; ORDER BY priority DESC dispatch; drag-and-drop reordering in UI
Historical LearningTracks indexer success/failure rates; annotates Jackett results with trust score (0–100)
Webhook ActionsGeneric HTTP POST webhooks on torrent lifecycle events (added, complete, error); separate from Discord
Plex / JellyfinAutomatic library refresh after each completed download via Plex token or Jellyfin API key
AllDebrid orphan cleanupAuto-deletes error/no-peer magnets on AllDebrid that have no local DB row; manual trigger button
Extraction passwordsPer-archive password list (newline-separated); each tried in order for 7z and RAR
AnalyticsQueue analytics with hourly chart and configurable time windows (1h / 24h / 7d / 30d)
Smart SchedulerTime-window enforcement for download slots; configurable active hours

⁠Quick Start

git clone https://github.com/kroeberd/alldebrid-client.git
cd alldebrid-client
docker compose up -d

Open http://localhost:8080⁠ → Settings → enter your AllDebrid API key.

⁠Docker run
docker run -d \
  --name alldebrid-client \
  --restart unless-stopped \
  -p 8080:8080 \
  -e PUID=99 \
  -e PGID=100 \
  -e TZ=Europe/Berlin \
  -v /path/to/config:/app/config \
  -v /path/to/downloads:/downloads \
  kroeberd/alldebrid-client:latest

File permissions: set PUID/PGID to the UID/GID of the user that runs your other media containers (Sonarr, Radarr, Plex, etc.). Run id on the host to find the right values.

⁠Unraid

Install AllDebrid-Client from the Community Apps store. All paths are pre-filled.


⁠Configuration

All settings are in the Settings page of the web UI. The most important ones to set after first start:

SettingWhereNotes
PUID / PGID env varsdocker-compose.ymlUID/GID for downloaded files
AllDebrid API keySettings → GeneralRequired
Download folderSettings → Download ClientMust be writable by the container
aria2 modeSettings → Download ClientBuilt-in (default) or External RPC
Discord webhookSettings → NotificationsOptional
Sonarr / Radarr URL + API keySettings → ServicesOptional
Auth username / passwordSettings → Access ControlOptional — leave either empty to disable
Min free disk space (GB)Settings → Download Client0 = disabled
log_level / log_pretty / log_formatconfig.jsonOptional Docker-safe logging controls; defaults are INFO, false, plain

See Help → Settings Reference in the web UI for a full description of every setting.


⁠Sonarr / Radarr Integration

AllDebrid-Client emulates the qBittorrent v4.3.2 Web API at /api/v2/. Configure it as a standard qBit download client:

Settings → Download Clients → + → qBittorrent
  Host:      your-server-ip
  Port:      8080  (or your mapped port)
  Category:  (any value — stored but not used for routing)
  Username:  (empty, or match Settings → Access Control)
  Password:  (empty, or match Settings → Access Control)

Click Test — it should show a green checkmark. See Help → Sonarr/Radarr in the web UI for the full status mapping table and troubleshooting guide.


  1. Install and run Jackett⁠
  2. In AllDebrid-Client Settings → Services → Jackett: enter URL and API key, enable, Save
  3. The Search view appears — search by title, filter by indexer
  4. Add individual results, use Add Selected (checkbox per row), or Add All

⁠Auto-Extraction

Enable in Settings → Auto-Extraction. Archives are extracted automatically after every successful download. Auto-extract uses the completed file list recorded by the downloader, so it does not recursively scan large media folders.

FormatExtension(s)Engine
ZIP.zipPython zipfile (built-in)
TAR (all compressions).tar, .tar.gz, .tgz, .tar.bz2, .tar.xz, .tar.zstPython tarfile (built-in)
Gzip / Bzip2 / XZ.gz, .bz2, .xzPython built-ins
7-Zip.7z7z binary (p7zip-full)
RAR / RAR5.rar, .r00, multi-part7z (primary) + unrar-free (fallback)

Both p7zip-full and unrar-free are included in the Docker image — no extra setup needed.


⁠Discord Webhooks

Set discord_webhook_url in Settings → Notifications. Per-event toggles control which events trigger a notification independently.

EventTrigger
📥 Torrent AddedMagnet/torrent accepted by AllDebrid
✅ Download CompleteAll files downloaded successfully
❌ Download ErrorOne or more files failed
⚠️ Upload FailedAllDebrid returned code 5 (auto-retry in progress)
🔗 No PeersAllDebrid returned code 8 (auto-retry or manual re-add needed)
⚠️ PartialSome files filtered/blocked, rest downloaded
🌿 FlexGetRun started / task result / run finished
📊 Stats ReportPeriodic summary webhook

⁠Prometheus Metrics

# prometheus.yml
- job_name: alldebrid
  static_configs:
    - targets: [your-host:8080]
  metrics_path: /api/metrics

Available metrics: alldebrid_torrents_by_status, alldebrid_active_downloads, alldebrid_completed_downloads, alldebrid_error_torrents, alldebrid_pending_files, alldebrid_sse_subscribers, alldebrid_downloaded_bytes_total.


⁠REST API

⁠Core
MethodPathDescription
GET/api/torrentsList torrents (status filter, search, pagination)
POST/api/torrents/add-magnetAdd magnet link
POST/api/torrents/check-duplicateRead-only duplicate preview before adding
POST/api/torrents/import-existingImport all AllDebrid magnets not yet in local DB
POST/api/torrents/recover-allReset stuck torrents and dispatch all ready AllDebrid magnets
GET/api/torrents/diagnoseStatus breakdown and sample of non-terminal torrents
GET/api/torrents/{id}Single torrent detail
DELETE/api/torrents/{id}Delete torrent
POST/api/torrents/{id}/retryRetry failed torrent (re-uploads magnet if stored)
GET/api/statsAggregate statistics
GET/api/settingsCurrent settings
PUT/api/settingsUpdate settings
⁠SSE
MethodPathDescription
GET/api/events/streamSSE stream (connected, ping, torrent_updated, stats_changed)
GET/api/events/subscriber-countActive SSE connection count
⁠qBittorrent API emulation (/api/v2/)
MethodPathDescription
POST/api/v2/auth/loginAccept credentials
GET/api/v2/app/versionReturns v4.3.2
GET/api/v2/torrents/infoTorrent list with qBit state mapping
POST/api/v2/torrents/addAdd via magnet or .torrent upload
GET/api/v2/torrents/filesPer-file progress
GET/api/v2/torrents/propertiesExtended torrent properties
POST/api/v2/torrents/deleteDelete torrent(s)
POST/api/v2/torrents/pause / resumePause / resume
GET/api/v2/transfer/infoDownload speed
GET/api/v2/sync/maindataFull state snapshot
⁠Observability & Admin
MethodPathDescription
GET/api/metricsPrometheus-compatible metrics
GET/api/versionClient version
POST/api/admin/full-syncFull AllDebrid reconciliation
POST/api/admin/deep-syncaria2 filesystem reconciliation
POST/api/admin/database/backupCreate a database backup
POST/api/admin/migrateSQLite ↔ PostgreSQL migration
POST/api/admin/database/wipeWipe the database (guarded)

⁠FlexGet

flexget web gentoken   # generate API token

Enter the token in Settings → Services → FlexGet. Tasks are executed via the FlexGet v3 REST API.


⁠Development

# Backend (Python 3.12+)
cd backend
pip install -r requirements.txt
uvicorn main:app --reload --port 8080

# Tests
python -m pytest tests -v
⁠Project structure
backend/
  api/
    routes.py          # FastAPI endpoints (71 routes)
    qbit.py            # qBittorrent v4.3.2 API emulation (28 routes)
  core/
    config.py          # Settings model (Pydantic, ~65 settings)
    scheduler.py       # Poll loops: AllDebrid, aria2, FlexGet, Stats, Events TTL
  db/
    database.py        # SQLite/PostgreSQL abstraction + 8 performance indexes
    migration.py       # Bidirectional SQLite ↔ PostgreSQL migration
  services/
    alldebrid.py       # AllDebrid API client (token-bucket rate limited)
    aria2.py           # aria2 JSON-RPC client (serialised, rate-limited)
    aria2_runtime.py   # Built-in aria2 process manager
    extractor.py       # Auto-extraction (zip/7z/rar/tar)
    flexget.py         # FlexGet v3 REST client
    jackett.py         # Jackett search proxy
    manager_v2.py      # Core orchestration (TorrentManager)
    notifications.py   # Discord webhook service
    stats.py           # Statistics and reporting
    backup.py          # Automatic backups
    db_maintenance.py  # Events TTL cleanup
    integrations.py    # Sonarr/Radarr import webhooks
    torrent_state.py   # Formal state machine: TorrentStatus enum + VALID_TRANSITIONS
  tests/               # 228 tests (pytest + pytest-asyncio)
frontend/
  static/index.html    # Single-file web UI (vanilla JS, SSE, no build step)
docs/
  logo.svg / logo.png  # App logo
  postgresql.md        # PostgreSQL setup guide
  migration.md         # Migration guide
  discord-webhooks.md  # Discord configuration

⁠Changelog

See CHANGELOG.md⁠ for full release history.


⁠Performance Tuning

⁠aria2 Connections

The default split=16 and max-connection-per-server=16 are optimized for AllDebrid CDN links. If you are on a very slow NAS or constrained hardware, reduce these in Settings → Download → aria2 Live Downloads.

⁠Search Speed

Jackett searches return results as soon as Jackett responds. The client does a bulk hash-lookup against your existing queue — no per-result DB calls. Large Jackett indexer lists (20+) may still be slow due to Jackett itself; reduce active indexers or increase the Jackett search timeout in Settings.

⁠Memory Usage
  • aria2_disk_cache=64M is the default. Reduce to 0 or 16M on constrained systems.
  • aria2_max_download_result=20 keeps aria2's in-memory result history small.
  • MALLOC_ARENA_MAX=1 is set automatically for the built-in aria2 to prevent glibc arena growth.

⁠Troubleshooting

⁠Jackett is slow or times out
  • Increase the search timeout in Settings → Search / Indexers → Jackett
  • Check Jackett logs for indexer-specific errors (docker logs jackett)
  • Disable dead indexers in Jackett admin to reduce concurrent requests
⁠aria2 is not reachable
  • If using built-in aria2: check Settings → Download → aria2 mode is set to Built-in
  • If using external aria2: verify the JSON-RPC URL (e.g. http://aria2:6800/jsonrpc) and secret
  • Run POST /api/settings/test-aria2 or use the Test aria2 button in Settings
⁠Duplicate detection blocks a re-add
  • The same infohash cannot be added twice while the torrent is active
  • To force a re-add: delete the existing torrent, then add the magnet again
  • Check Settings → General → Duplicate Detection level
⁠Expired magnets ("Expired — files removed")
  • AllDebrid removes cached files after ~30 days of inactivity
  • The client detects statusCode 3 and automatically re-uploads the magnet if stored
  • If no magnet is stored, the torrent moves to error state — add the magnet again manually
⁠No-peer torrents not cleaning up
  • Use 🧹 Clean AD Orphans in the Torrents view to purge error magnets from AllDebrid
  • These are magnets added directly on AllDebrid outside the client
  • The client also runs cleanup_alldebrid_orphans() automatically every sync cycle
⁠PostgreSQL connection issues
  • Ensure DB_TYPE=postgres and all POSTGRES_* env vars are set correctly
  • Run POST /api/settings/test-postgres or use Test PostgreSQL in Settings → Database
  • Check container logs: docker logs alldebrid-client
⁠Permission errors (download folder, extraction)
  • Set PUID and PGID to match your host user (id -u / id -g)
  • Ensure the volume mounts exist and are writable by the PUID/PGID user
  • Example: -e PUID=1000 -e PGID=1000
⁠Docker networking (Jackett/aria2 unreachable)
  • All services should be on the same Docker network, or use host IPs
  • Use the container name as hostname: http://jackett:9117 (if on same bridge)
  • With network_mode: host, use 127.0.0.1 as the host

⁠License

MIT — see LICENSE⁠

Tag summary

Content type

Image

Digest

sha256:3b109bc3d…

Size

79.1 MB

Last updated

5 days ago

docker pull kroeberd/alldebrid-client