Files
Lycostorrent/app/plugins/torrent_clients/README.md
2026-03-23 20:59:26 +01:00

154 lines
4.1 KiB
Markdown

# Plugins Clients Torrent - Lycostorrent
Ce dossier contient les plugins pour les clients torrent.
## Plugins disponibles
| Plugin | Fichier | Description |
|--------|---------|-------------|
| qBittorrent | `qbittorrent.py` | Client qBittorrent via API Web |
## Créer un nouveau plugin
### 1. Créer le fichier
Créer un fichier `mon_client.py` dans ce dossier.
### 2. Implémenter la classe
```python
from .base import TorrentClientPlugin, TorrentClientConfig, TorrentInfo
from typing import Optional, List
class MonClientPlugin(TorrentClientPlugin):
"""Plugin pour MonClient."""
# Métadonnées (obligatoires)
PLUGIN_NAME = "MonClient"
PLUGIN_DESCRIPTION = "Support pour MonClient"
PLUGIN_VERSION = "1.0.0"
PLUGIN_AUTHOR = "VotreNom"
def connect(self) -> bool:
"""Établit la connexion."""
# Votre code ici
pass
def disconnect(self) -> None:
"""Ferme la connexion."""
pass
def is_connected(self) -> bool:
"""Vérifie la connexion."""
pass
def add_torrent_url(self, url: str, save_path: Optional[str] = None,
category: Optional[str] = None, paused: bool = False) -> bool:
"""Ajoute un torrent via URL."""
pass
def add_torrent_file(self, file_content: bytes, filename: str,
save_path: Optional[str] = None,
category: Optional[str] = None, paused: bool = False) -> bool:
"""Ajoute un torrent via fichier."""
pass
def get_torrents(self) -> List[TorrentInfo]:
"""Liste tous les torrents."""
pass
def get_torrent(self, torrent_hash: str) -> Optional[TorrentInfo]:
"""Récupère un torrent par son hash."""
pass
def pause_torrent(self, torrent_hash: str) -> bool:
"""Met en pause."""
pass
def resume_torrent(self, torrent_hash: str) -> bool:
"""Reprend le téléchargement."""
pass
def delete_torrent(self, torrent_hash: str, delete_files: bool = False) -> bool:
"""Supprime un torrent."""
pass
def get_categories(self) -> List[str]:
"""Liste les catégories."""
pass
# Important : exposer la classe pour l'auto-découverte
PLUGIN_CLASS = MonClientPlugin
```
### 3. Méthodes obligatoires
| Méthode | Description |
|---------|-------------|
| `connect()` | Connexion au client |
| `disconnect()` | Déconnexion |
| `is_connected()` | Vérifie la connexion |
| `add_torrent_url()` | Ajoute via magnet/URL |
| `add_torrent_file()` | Ajoute via fichier .torrent |
| `get_torrents()` | Liste les torrents |
| `get_torrent()` | Info d'un torrent |
| `pause_torrent()` | Pause |
| `resume_torrent()` | Reprise |
| `delete_torrent()` | Suppression |
| `get_categories()` | Liste catégories |
### 4. Structure TorrentInfo
```python
@dataclass
class TorrentInfo:
hash: str # Hash du torrent
name: str # Nom
size: int # Taille en bytes
progress: float # 0.0 à 1.0
status: str # downloading, seeding, paused, error, queued, checking
download_speed: int # bytes/s
upload_speed: int # bytes/s
seeds: int # Nombre de seeds
peers: int # Nombre de peers
save_path: str # Chemin de sauvegarde
```
### 5. Configuration
La configuration est passée via `TorrentClientConfig` :
```python
@dataclass
class TorrentClientConfig:
host: str # Adresse (ex: "192.168.1.100")
port: int # Port (ex: 8080)
username: str # Utilisateur
password: str # Mot de passe
use_ssl: bool # Utiliser HTTPS
```
## Plugins à créer
- [ ] Transmission (`transmission.py`)
- [ ] Deluge (`deluge.py`)
- [ ] ruTorrent (`rutorrent.py`)
- [ ] Vuze (`vuze.py`)
- [ ] µTorrent (`utorrent.py`)
## Test du plugin
```python
from plugins.torrent_clients import create_client
client = create_client('monclient', {
'host': 'localhost',
'port': 8080,
'username': 'admin',
'password': 'password'
})
result = client.test_connection()
print(result)
```