fix: includes missing files from last commit
This commit is contained in:
@@ -123,4 +123,16 @@ class DownloadRepository extends ServiceEntityRepository
|
||||
->getQuery()
|
||||
->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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,25 @@
|
||||
|
||||
namespace App\Torrentio\Client;
|
||||
|
||||
use Aimeos\Map;
|
||||
use App\Download\Framework\Repository\DownloadRepository;
|
||||
use App\Torrentio\Result\ResultFactory;
|
||||
use App\Torrentio\Exception\TorrentioRateLimitException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Torrentio
|
||||
{
|
||||
private array $badDownloadUrls = [];
|
||||
|
||||
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
|
||||
{
|
||||
@@ -47,6 +58,16 @@ class Torrentio
|
||||
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 (
|
||||
array_key_exists('behaviorHints', $stream) &&
|
||||
array_key_exists('bingeGroup', $stream['behaviorHints'])
|
||||
|
||||
Reference in New Issue
Block a user