Implemented the complete download flow from search results to qBittorrent:
- Extract magnet links from search results
- Pass magnet links to qBittorrent via API
- Track download status in monitored games
Added methods to add torrents:
async addMagnetLink(magnetUrl: string, options?: {...}): Promise<string>
async addTorrentUrl(torrentUrl: string, options?: {...}): Promise<void>Added wrapper method:
async addMagnetLink(magnetUrl: string, options?: {...}): Promise<string>- Added
qbittorrentServicedependency - Implemented
startDownload()method:- Validates game is monitored
- Extracts magnet/torrent URL from candidate
- Adds to qBittorrent with 'games' category
- Updates game status to 'downloading'
- Stores download hash for tracking
Updated to pass qbittorrentService to GamesService
Added download functionality:
interface CandidateCardProps {
candidate: GameDownloadCandidate;
game: GameSearchResult | MonitoredGame;
onDownload: () => void; // NEW
isDownloading: boolean; // NEW
}UI Changes:
- "⬇️ Download to qBittorrent" button (green, primary action)
- Disabled state during download
- Success/error alerts
- "🧲 Magnet" link (secondary, opens magnet URL directly)
Added download mutation:
const downloadMutation = useMutation({
mutationFn: ({ candidate, downloadClient }) =>
api.games.startDownload(game.igdbId, candidate, downloadClient),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['games', 'monitored'] });
alert('Download started successfully!');
},
onError: (error) => {
alert(`Failed to start download: ${error.message}`);
},
});1. Search for game
↓
2. Click "🔍 Search Downloads"
↓
3. View candidates with scores
↓
4. Expand desired candidate
↓
5. Click "⬇️ Download to qBittorrent"
↓
6. Game added to monitored with 'downloading' status
↓
7. Download appears in qBittorrent with 'games' category
POST /api/v1/games/:igdbId/download
Body: {
candidate: GameDownloadCandidate,
downloadClient?: 'qbittorrent' | 'rdtclient'
}
- Game must be monitored before download
- Download automatically updates game status
- Tracks download hash for progress monitoring
- Downloads added to 'games' category in qBittorrent
- Enables organization and filtering
- Validates magnet/torrent URL exists
- Checks qBittorrent availability
- User-friendly error messages
game.currentDownload = {
status: 'downloading',
progress: 0,
source: candidate.source,
title: candidate.title,
client: 'qbittorrent',
hash: downloadHash, // For tracking
};Test with Baldur's Gate 3:
curl -X POST "http://localhost:3000/api/v1/games/119171/download" \
-H "Content-Type: application/json" \
-d '{
"candidate": {
"title": "Baldur's Gate 3: Digital Deluxe Edition",
"magnetUrl": "magnet:?xt=urn:btih:...",
"source": "FitGirl",
"releaseType": "repack"
}
}'- Real-time Progress: Poll qBittorrent for download progress
- Completion Detection: Auto-mark game as 'downloaded' when complete
- RDTClient Support: Add Real-Debrid download option
- Torrent File Support: Download and add .torrent files
- Download History: Track all download attempts