public function testTorrentsCategoryFilter() { $t411 = new T411($this->loadConfig()); $this->assertTrue($t411->login()); $torrents = $t411->getTopToday(); $filteredTorrents = $t411->filter($torrents, ['categoryimage' => '!= video-movie']); foreach ($filteredTorrents as $torrent) { $this->assertTrue($torrent->categoryimage != 'video-movie', 'Le torrent ' . $torrent->id . ' est de la catégorie ' . $torrent->categoryimage); } }
#!/usr/bin/env php <?php require_once __DIR__ . '/../src/T411.php'; $config = (include __DIR__ . '/../config.php'); $torrentPath = '/home/kocal/watch'; // --- App --- echo "Initialisation de l'objet t411..." . PHP_EOL; $t411 = new T411($config); try { echo "Connexion à l'API..." . PHP_EOL; $t411->login(); } catch (Exception $e) { die($e); } echo "Récupération des torrents 'Top today'..." . PHP_EOL; $torrentsTopToday = $t411->getTopToday(); echo "Récupération des torrents 'Top week'..." . PHP_EOL; $torrentsTopWeek = $t411->getTopWeek(); echo "Récupération des torrents 'Top month'..." . PHP_EOL; $torrentsTopMonth = $t411->getTopMonth(); // On récupère tous les torrents "Top" et on les fusionnes $torrents = array_merge($torrentsTopToday, $torrentsTopWeek, $torrentsTopMonth); echo "Filtrage des torrents..." . PHP_EOL; // On fait le tri pour récupérer seulement les torrents avec 1 seeder et dont la taille fait moins de 15 Gio $torrents = $t411->filter($torrents, ['seeders' => '== 1', 'size' => '<= 1.611e10', 'categoryimage' => '!= xxx-video']); // Traitement foreach ($torrents as $torrent) { $file = null; try { printf('#%d: %d/%d/%s - %s (%s) : ', $torrent->id, $torrent->seeders, $torrent->leechers, formatBytes($torrent->size), $torrent->name, $torrent->categoryimage); $file = $t411->downloadTorrent($torrent);