From fb4651c9250a7922b5a92281759c496b5f16d225 Mon Sep 17 00:00:00 2001 From: Brock H Caldwell Date: Mon, 21 Apr 2025 16:11:57 -0500 Subject: [PATCH] feat: torrentio api for movie results --- src/Controller/SearchController.php | 6 +- src/Controller/TorrentioController.php | 26 +++++++ .../Handler/GetDownloadOptionsHandler.php | 2 +- .../Action/Command/GetMovieOptionsCommand.php | 12 ++++ .../Action/Handler/GetMovieOptionsHandler.php | 23 +++++++ .../Action/Input/GetMovieOptionsInput.php | 21 ++++++ .../Action/Result/GetMovieOptionsResult.php | 12 ++++ .../Rule/DownloadOptionFilter/Resolution.php | 2 +- .../{ => Client}/Rule/RuleEngine.php | 2 +- src/Torrentio/{ => Client}/Torrentio.php | 7 +- templates/search/result.html.twig | 20 +++++- templates/torrentio/index.html.twig | 20 ++++++ templates/torrentio/movies.html.twig | 67 +++++++++++++++++++ templates/torrentio/tvshows.html.twig | 3 + 14 files changed, 210 insertions(+), 13 deletions(-) create mode 100644 src/Controller/TorrentioController.php create mode 100644 src/Torrentio/Action/Command/GetMovieOptionsCommand.php create mode 100644 src/Torrentio/Action/Handler/GetMovieOptionsHandler.php create mode 100644 src/Torrentio/Action/Input/GetMovieOptionsInput.php create mode 100644 src/Torrentio/Action/Result/GetMovieOptionsResult.php rename src/Torrentio/{ => Client}/Rule/DownloadOptionFilter/Resolution.php (82%) rename src/Torrentio/{ => Client}/Rule/RuleEngine.php (93%) rename src/Torrentio/{ => Client}/Torrentio.php (96%) create mode 100644 templates/torrentio/index.html.twig create mode 100644 templates/torrentio/movies.html.twig create mode 100644 templates/torrentio/tvshows.html.twig diff --git a/src/Controller/SearchController.php b/src/Controller/SearchController.php index 3c0b596..a0c5ee2 100644 --- a/src/Controller/SearchController.php +++ b/src/Controller/SearchController.php @@ -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, ]); } } diff --git a/src/Controller/TorrentioController.php b/src/Controller/TorrentioController.php new file mode 100644 index 0000000..37e5cfb --- /dev/null +++ b/src/Controller/TorrentioController.php @@ -0,0 +1,26 @@ +getMovieOptionsHandler->handle($input->toCommand()); + + return $this->render('torrentio/movies.html.twig', [ + 'results' => $results, + ]); + } +} diff --git a/src/Download/Action/Handler/GetDownloadOptionsHandler.php b/src/Download/Action/Handler/GetDownloadOptionsHandler.php index 32daa81..ed569a3 100644 --- a/src/Download/Action/Handler/GetDownloadOptionsHandler.php +++ b/src/Download/Action/Handler/GetDownloadOptionsHandler.php @@ -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; diff --git a/src/Torrentio/Action/Command/GetMovieOptionsCommand.php b/src/Torrentio/Action/Command/GetMovieOptionsCommand.php new file mode 100644 index 0000000..8dfeb75 --- /dev/null +++ b/src/Torrentio/Action/Command/GetMovieOptionsCommand.php @@ -0,0 +1,12 @@ +torrentio->search($command->imdbId, 'movies') + ); + } +} diff --git a/src/Torrentio/Action/Input/GetMovieOptionsInput.php b/src/Torrentio/Action/Input/GetMovieOptionsInput.php new file mode 100644 index 0000000..b5a9653 --- /dev/null +++ b/src/Torrentio/Action/Input/GetMovieOptionsInput.php @@ -0,0 +1,21 @@ +imdbId); + } +} diff --git a/src/Torrentio/Action/Result/GetMovieOptionsResult.php b/src/Torrentio/Action/Result/GetMovieOptionsResult.php new file mode 100644 index 0000000..4e77a33 --- /dev/null +++ b/src/Torrentio/Action/Result/GetMovieOptionsResult.php @@ -0,0 +1,12 @@ + -

Search Results

+

Media Results

- + +
+ +
+

+ {{ results.media.title }} - {{ results.media.year }} +

+

+ {{ results.media.description }} +

+
+
+ +
+
diff --git a/templates/torrentio/index.html.twig b/templates/torrentio/index.html.twig new file mode 100644 index 0000000..a7e4147 --- /dev/null +++ b/templates/torrentio/index.html.twig @@ -0,0 +1,20 @@ +{% extends 'base.html.twig' %} + +{% block title %}Hello TorrentioController!{% endblock %} + +{% block body %} + + +
+

Hello {{ controller_name }}! ✅

+ + This friendly message is coming from: + +
+{% endblock %} diff --git a/templates/torrentio/movies.html.twig b/templates/torrentio/movies.html.twig new file mode 100644 index 0000000..4a88f5c --- /dev/null +++ b/templates/torrentio/movies.html.twig @@ -0,0 +1,67 @@ + + +
+ + + + + + + + + + + + + + {% for result in results.results %} + + + + + + + + + + {% endfor %} + +
+ Size + + Resolution + + Codec + + Seeders + + Provider + + Language + +
+ {{ result.size }} + + {{ result.resolution }} + + {{ result.codec }} + + {{ result.seeders }} + + {{ result.provider }} + + {{ result.languageFlags }} + + + Download + + +
+
\ No newline at end of file diff --git a/templates/torrentio/tvshows.html.twig b/templates/torrentio/tvshows.html.twig new file mode 100644 index 0000000..5417f46 --- /dev/null +++ b/templates/torrentio/tvshows.html.twig @@ -0,0 +1,3 @@ +
+

Episodes

+
\ No newline at end of file