feat: torrentio api for movie results

This commit is contained in:
2025-04-21 16:11:57 -05:00
parent 77907601f8
commit fb4651c925
14 changed files with 210 additions and 13 deletions

View File

@@ -32,12 +32,10 @@ final class SearchController extends AbstractController
public function result(
GetMediaInfoInput $getDownloadOptionsInput,
): Response {
$result = $this->getMediaInfoHandler->handle(
$getDownloadOptionsInput->toCommand()
);
$result = $this->getMediaInfoHandler->handle($getDownloadOptionsInput->toCommand());
return $this->render('search/result.html.twig', [
'result' => $result,
'results' => $result,
]);
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Controller;
use App\Torrentio\Action\Handler\GetMovieOptionsHandler;
use App\Torrentio\Action\Input\GetMovieOptionsInput;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
final class TorrentioController extends AbstractController
{
public function __construct(
private readonly GetMovieOptionsHandler $getMovieOptionsHandler,
) {}
#[Route('/torrentio/movies/{imdbId}', name: 'app_torrentio')]
public function index(GetMovieOptionsInput $input): Response
{
$results = $this->getMovieOptionsHandler->handle($input->toCommand());
return $this->render('torrentio/movies.html.twig', [
'results' => $results,
]);
}
}

View File

@@ -3,7 +3,7 @@
namespace App\Download\Action\Handler;
use App\Tmdb\Tmdb;
use App\Torrentio\Torrentio;
use App\Torrentio\Client\Torrentio;
use OneToMany\RichBundle\Contract\CommandInterface;
use OneToMany\RichBundle\Contract\HandlerInterface;
use OneToMany\RichBundle\Contract\ResultInterface;

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Torrentio\Action\Command;
use OneToMany\RichBundle\Contract\CommandInterface;
class GetMovieOptionsCommand implements CommandInterface
{
public function __construct(
public string $imdbId,
) {}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Torrentio\Action\Handler;
use App\Torrentio\Action\Result\GetMovieOptionsResult;
use App\Torrentio\Client\Torrentio;
use OneToMany\RichBundle\Contract\CommandInterface;
use OneToMany\RichBundle\Contract\HandlerInterface;
use OneToMany\RichBundle\Contract\ResultInterface;
class GetMovieOptionsHandler implements HandlerInterface
{
public function __construct(
private readonly Torrentio $torrentio,
) {}
public function handle(CommandInterface $command): ResultInterface
{
return new GetMovieOptionsResult(
results: $this->torrentio->search($command->imdbId, 'movies')
);
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Torrentio\Action\Input;
use App\Torrentio\Action\Command\GetMovieOptionsCommand;
use OneToMany\RichBundle\Attribute\SourceRoute;
use OneToMany\RichBundle\Contract\CommandInterface;
use OneToMany\RichBundle\Contract\InputInterface;
class GetMovieOptionsInput implements InputInterface
{
public function __construct(
#[SourceRoute('imdbId')]
public string $imdbId,
) {}
public function toCommand(): CommandInterface
{
return new GetMovieOptionsCommand($this->imdbId);
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Torrentio\Action\Result;
use OneToMany\RichBundle\Contract\ResultInterface;
class GetMovieOptionsResult implements ResultInterface
{
public function __construct(
public array $results
) {}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Torrentio\Rule\DownloadOptionFilter;
namespace App\Torrentio\Client\Rule\DownloadOptionFilter;
use App\Torrentio\Result\ResultFactory;

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Torrentio\Rule;
namespace App\Torrentio\Client\Rule;
class RuleEngine
{

View File

@@ -1,9 +1,10 @@
<?php
namespace App\Torrentio;
namespace App\Torrentio\Client;
use App\Torrentio\Rule\DownloadOptionFilter\Resolution;
use App\Torrentio\Rule\RuleEngine;
use App\Torrentio\Client\Rule\DownloadOptionFilter\Resolution;
use App\Torrentio\Client\Rule\RuleEngine;
use App\Torrentio\MediaResult;
use App\Torrentio\Result\ResultFactory;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Contracts\Cache\CacheInterface;