feat: tv episode results
This commit is contained in:
15
src/Torrentio/Action/Command/GetTvShowOptionsCommand.php
Normal file
15
src/Torrentio/Action/Command/GetTvShowOptionsCommand.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Torrentio\Action\Command;
|
||||
|
||||
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||
|
||||
class GetTvShowOptionsCommand implements CommandInterface
|
||||
{
|
||||
public function __construct(
|
||||
public string $tmdbId,
|
||||
public string $imdbId,
|
||||
public ?string $season,
|
||||
public ?string $episode,
|
||||
) {}
|
||||
}
|
||||
32
src/Torrentio/Action/Handler/GetTvShowOptionsHandler.php
Normal file
32
src/Torrentio/Action/Handler/GetTvShowOptionsHandler.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Torrentio\Action\Handler;
|
||||
|
||||
use App\Tmdb\Tmdb;
|
||||
use App\Torrentio\Action\Result\GetTvShowOptionsResult;
|
||||
use App\Torrentio\Client\Torrentio;
|
||||
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||
use OneToMany\RichBundle\Contract\HandlerInterface;
|
||||
use OneToMany\RichBundle\Contract\ResultInterface;
|
||||
|
||||
class GetTvShowOptionsHandler implements HandlerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Tmdb $tmdb,
|
||||
private readonly Torrentio $torrentio,
|
||||
) {}
|
||||
|
||||
public function handle(CommandInterface $command): ResultInterface
|
||||
{
|
||||
return new GetTvShowOptionsResult(
|
||||
media: $this->tmdb->episodeDetails($command->tmdbId, $command->season, $command->episode),
|
||||
season: $command->season,
|
||||
episode: $command->episode,
|
||||
results: $this->torrentio->fetchEpisodeResults(
|
||||
$command->imdbId,
|
||||
$command->season,
|
||||
$command->episode,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
32
src/Torrentio/Action/Input/GetTvShowOptionsInput.php
Normal file
32
src/Torrentio/Action/Input/GetTvShowOptionsInput.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Torrentio\Action\Input;
|
||||
|
||||
use App\Torrentio\Action\Command\GetTvShowOptionsCommand;
|
||||
use OneToMany\RichBundle\Attribute\SourceRoute;
|
||||
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||
use OneToMany\RichBundle\Contract\InputInterface;
|
||||
|
||||
class GetTvShowOptionsInput implements InputInterface
|
||||
{
|
||||
public function __construct(
|
||||
#[SourceRoute('tmdbId')]
|
||||
public string $tmdbId,
|
||||
#[SourceRoute('imdbId')]
|
||||
public string $imdbId,
|
||||
#[SourceRoute('season', nullify: true)]
|
||||
public ?string $season,
|
||||
#[SourceRoute('episode', nullify: true)]
|
||||
public string $episode,
|
||||
) {}
|
||||
|
||||
public function toCommand(): CommandInterface
|
||||
{
|
||||
return new GetTvShowOptionsCommand(
|
||||
$this->tmdbId,
|
||||
$this->imdbId,
|
||||
$this->season,
|
||||
$this->episode
|
||||
);
|
||||
}
|
||||
}
|
||||
16
src/Torrentio/Action/Result/GetTvShowOptionsResult.php
Normal file
16
src/Torrentio/Action/Result/GetTvShowOptionsResult.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Torrentio\Action\Result;
|
||||
|
||||
use App\Tmdb\TmdbResult;
|
||||
use OneToMany\RichBundle\Contract\ResultInterface;
|
||||
|
||||
class GetTvShowOptionsResult implements ResultInterface
|
||||
{
|
||||
public function __construct(
|
||||
public TmdbResult $media,
|
||||
public string $season,
|
||||
public string $episode,
|
||||
public array $results
|
||||
) {}
|
||||
}
|
||||
Reference in New Issue
Block a user