feat: torrentio api for movie results
This commit is contained in:
@@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
26
src/Controller/TorrentioController.php
Normal file
26
src/Controller/TorrentioController.php
Normal 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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
12
src/Torrentio/Action/Command/GetMovieOptionsCommand.php
Normal file
12
src/Torrentio/Action/Command/GetMovieOptionsCommand.php
Normal 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,
|
||||
) {}
|
||||
}
|
||||
23
src/Torrentio/Action/Handler/GetMovieOptionsHandler.php
Normal file
23
src/Torrentio/Action/Handler/GetMovieOptionsHandler.php
Normal 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')
|
||||
);
|
||||
}
|
||||
}
|
||||
21
src/Torrentio/Action/Input/GetMovieOptionsInput.php
Normal file
21
src/Torrentio/Action/Input/GetMovieOptionsInput.php
Normal 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);
|
||||
}
|
||||
}
|
||||
12
src/Torrentio/Action/Result/GetMovieOptionsResult.php
Normal file
12
src/Torrentio/Action/Result/GetMovieOptionsResult.php
Normal 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
|
||||
) {}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Torrentio\Rule\DownloadOptionFilter;
|
||||
namespace App\Torrentio\Client\Rule\DownloadOptionFilter;
|
||||
|
||||
use App\Torrentio\Result\ResultFactory;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Torrentio\Rule;
|
||||
namespace App\Torrentio\Client\Rule;
|
||||
|
||||
class RuleEngine
|
||||
{
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user