Files
torsearch/src/Torrentio/Action/Handler/GetMovieOptionsHandler.php

31 lines
961 B
PHP

<?php
namespace App\Torrentio\Action\Handler;
use App\Monitor\Service\MediaFiles;
use App\Tmdb\Tmdb;
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 Tmdb $tmdb,
private readonly Torrentio $torrentio,
private readonly MediaFiles $mediaFiles
) {}
public function handle(CommandInterface $command): ResultInterface
{
$media = $this->tmdb->mediaDetails($command->imdbId, 'movies');
return new GetMovieOptionsResult(
media: $media,
file: $this->mediaFiles->movieExists($media->title),
results: $this->torrentio->search($command->imdbId, 'movies'),
);
}
}