fix: includes missing files from last commit

This commit is contained in:
Brock H Caldwell
2026-02-06 15:23:18 -06:00
parent f4644d40ef
commit 7958f50ff7
2 changed files with 35 additions and 2 deletions

View File

@@ -123,4 +123,16 @@ class DownloadRepository extends ServiceEntityRepository
->getQuery() ->getQuery()
->getResult(); ->getResult();
} }
public function badDownloadUrls()
{
return $this->createQueryBuilder('d')
->select('d.url')
->andWhere('d.status = :status')
->andWhere('d.progress = 100')
->setParameter('status', 'Failed')
->distinct()
->getQuery()
->getResult();
}
} }

View File

@@ -2,14 +2,25 @@
namespace App\Torrentio\Client; namespace App\Torrentio\Client;
use Aimeos\Map;
use App\Download\Framework\Repository\DownloadRepository;
use App\Torrentio\Result\ResultFactory; use App\Torrentio\Result\ResultFactory;
use App\Torrentio\Exception\TorrentioRateLimitException; use App\Torrentio\Exception\TorrentioRateLimitException;
use Psr\Log\LoggerInterface;
class Torrentio class Torrentio
{ {
private array $badDownloadUrls = [];
public function __construct( public function __construct(
private readonly HttpClient $client, private readonly HttpClient $client,
) {} private readonly DownloadRepository $downloadRepository, private readonly LoggerInterface $logger,
) {
$badDownloadUrls = $this->downloadRepository->badDownloadUrls();
$this->badDownloadUrls = Map::from($badDownloadUrls)
->map(fn ($url) => $url['url'])
->toArray();
}
public function search(string $imdbCode, string $type, bool $parseResults = true): array public function search(string $imdbCode, string $type, bool $parseResults = true): array
{ {
@@ -47,6 +58,16 @@ class Torrentio
continue; continue;
} }
$url = explode('/', $stream['url']);
$filename = urldecode(end($url));
$url[count($url) - 1] = $filename;
$url = implode('/', $url);
if (in_array($stream['url'], $this->badDownloadUrls)) {
$this->logger->warning($stream['url'] . ' was skipped because it was identified as a bad download url.');
continue;
}
if ( if (
array_key_exists('behaviorHints', $stream) && array_key_exists('behaviorHints', $stream) &&
array_key_exists('bingeGroup', $stream['behaviorHints']) array_key_exists('bingeGroup', $stream['behaviorHints'])