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;

View File

@@ -1,12 +1,26 @@
{% extends 'base.html.twig' %}
{% block title %}Search Results &mdash - Torsearch{% endblock %}
{% block title %}{{ results.media.title }} &mdash; Download Options &mdash; Torsearch{% endblock %}
{% block body %}
<div class="p-4 flex flex-col grow gap-4">
<h2 class="mb-2 text-3xl font-bold text-gray-50">Search Results</h2>
<h2 class="mb-2 text-3xl font-bold text-gray-50">Media Results</h2>
<div class="flex flex-row w-full gap-2">
<twig:Card title="{{ result.media.title }}" contentClass="flex flex-col gap-4 justify-between w-full">
<twig:Card title="" contentClass="flex flex-col gap-4 justify-between w-full text-gray-50">
<div class="p-4 flex flex-row gap-6">
<img class="w-24" src="{{ results.media.poster }}" />
<div class="w-full flex flex-col">
<h3 class="mb-4 text-xl font-medium leading-tight font-bold text-gray-50">
{{ results.media.title }} - {{ results.media.year }}
</h3>
<p class="text-gray-50">
{{ results.media.description }}
</p>
</div>
</div>
<div id="results">
</div>
</twig:Card>
</div>

View File

@@ -0,0 +1,20 @@
{% extends 'base.html.twig' %}
{% block title %}Hello TorrentioController!{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
This friendly message is coming from:
<ul>
<li>Your controller at <code>/var/www/src/Controller/TorrentioController.php</code></li>
<li>Your template at <code>/var/www/templates/torrentio/index.html.twig</code></li>
</ul>
</div>
{% endblock %}

View File

@@ -0,0 +1,67 @@
<div class="p-2 flex flex-col gap-6 bg-orange-500 bg-clip-padding backdrop-filter backdrop-blur-md bg-opacity-60 rounded-md">
<table class="divide-y divide-gray-200 dark:divide-gray-50 dark:bg-transparent rounded-lg">
<thead>
<tr class="dark:bg-stone-600 overflow-hidden rounded-md">
<th scope="col"
class="px-6 py-3 text-start text-xs font-medium text-stone-500 uppercase dark:text-gray-50">
Size
</th>
<th scope="col"
class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase dark:text-gray-50">
Resolution
</th>
<th scope="col"
class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase dark:text-gray-50">
Codec
</th>
<th scope="col"
class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase dark:text-gray-50">
Seeders
</th>
<th scope="col"
class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase dark:text-gray-50">
Provider
</th>
<th scope="col"
class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase dark:text-gray-50">
Language
</th>
<th scope="col"
class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase dark:text-gray-50">
</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200 dark:divide-gray-50">
{% for result in results.results %}
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
{{ result.size }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
{{ result.resolution }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
{{ result.codec }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
{{ result.seeders }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
{{ result.provider }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-gray-50">
{{ result.languageFlags }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-end text-gray-800 dark:text-gray-50">
<span class="p-1.5 bg-green-600 rounded-md">
<span class="text-gray-50">Download</span>
</span>
<input class="ml-1" type="checkbox" name="select" />
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>

View File

@@ -0,0 +1,3 @@
<div class="p-2 flex flex-row gap-6 bg-orange-500 bg-clip-padding backdrop-filter backdrop-blur-md bg-opacity-60 rounded-md">
<h3 class="text-md">Episodes</h3>
</div>