Files
stripstream-librarian/infra/migrations/0064_add_torrent_downloads.sql
Froidefond Julien 4bb142d1dd feat: gestion des téléchargements qBittorrent avec import automatique
- Nouvelle table `torrent_downloads` pour suivre les téléchargements gérés
- API : endpoint POST /torrent-downloads/notify (webhook optionnel) et GET /torrent-downloads
- Poller background toutes les 30s qui interroge qBittorrent pour détecter
  les torrents terminés — aucune config "run external program" nécessaire
- Import automatique : déplacement des fichiers vers la série cible,
  renommage selon le pattern existant (détection de la largeur des digits),
  support packs multi-volumes, scan job déclenché après import
- Page /downloads dans le backoffice : filtres, auto-refresh, carte par download
- Toggle auto-import intégré dans la card qBittorrent des settings
- Erreurs de détection download affichées dans le détail des jobs
- Volume /downloads monté dans docker-compose

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 14:43:10 +01:00

31 lines
1.2 KiB
SQL

ALTER TABLE index_jobs
DROP CONSTRAINT IF EXISTS index_jobs_type_check,
ADD CONSTRAINT index_jobs_type_check
CHECK (type IN (
'scan', 'rebuild', 'full_rebuild', 'rescan',
'thumbnail_rebuild', 'thumbnail_regenerate',
'cbr_to_cbz',
'metadata_batch', 'metadata_refresh',
'reading_status_match', 'reading_status_push',
'download_detection',
'torrent_import'
));
CREATE TABLE torrent_downloads (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
library_id UUID NOT NULL REFERENCES libraries(id) ON DELETE CASCADE,
series_name TEXT NOT NULL,
expected_volumes INTEGER[] NOT NULL DEFAULT '{}',
qb_hash TEXT,
content_path TEXT,
status TEXT NOT NULL DEFAULT 'downloading'
CHECK (status IN ('downloading', 'completed', 'importing', 'imported', 'error')),
imported_files JSONB,
error_message TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX torrent_downloads_status_idx ON torrent_downloads(status);
CREATE INDEX torrent_downloads_qb_hash_idx ON torrent_downloads(qb_hash) WHERE qb_hash IS NOT NULL;