Skip to content

Commit 9327263

Browse files
authored
chore: cleanup command
1 parent bac429a commit 9327263

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

Diff for: app/Commands/DownloadCommand.php

+11-13
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,19 @@ class DownloadCommand extends Command
2929

3030
private Quality|null $quality;
3131

32-
private string $apiToken;
32+
private TraktClient $trakt;
3333

34-
public function handle(): void
34+
private YTSClient $yts;
35+
36+
public function handle(TraktClient $traktClient): void
3537
{
38+
$this->trakt = $traktClient;
39+
$this->yts = $ytsClient;
40+
3641
$this->quality = Quality::tryFrom($this->option('quality'));
3742

3843
try {
39-
$this->retrieveTraktList()
40-
->downloadTorrentsFromYts();
44+
$this->retrieveTraktList()->downloadTorrentsFromYts();
4145
} catch (\RuntimeException $exception) {
4246
$this->warn($exception->getMessage());
4347

@@ -47,10 +51,7 @@ public function handle(): void
4751

4852
private function retrieveTraktList(): self
4953
{
50-
/** @var TraktClient $traktApi */
51-
$traktApi = app(TraktClient::class);
52-
53-
$this->traktList = $traktApi->getList($this->argument('trakt-user'), $this->option('list'));
54+
$this->traktList = $this->trakt->getList($this->argument('trakt-user'), $this->option('list'));
5455

5556
$this->comment(
5657
"<options=bold>{$this->option('list')}</> (<options=bold>{$this->argument('trakt-user')}</>): Retrieved successfully",
@@ -70,9 +71,6 @@ private function downloadTorrentsFromYts(): void
7071
return;
7172
}
7273

73-
/** @var YTSClient $ytsApi */
74-
$ytsApi = app(YTSClient::class);
75-
7674
$this->line('');
7775

7876
/** @var Movie $movie */
@@ -81,7 +79,7 @@ private function downloadTorrentsFromYts(): void
8179
continue;
8280
}
8381

84-
if (! $ytsListing = $ytsApi->getMovieByImdbId($movie->imdbId, $this->quality)) {
82+
if (! $ytsListing = $this->yts->getMovieByImdbId($movie->imdbId, $this->quality)) {
8583
$this->components->warn(
8684
"'{$movie->title} ({$movie->year})': Not found on YTS",
8785
OutputInterface::VERBOSITY_VERY_VERBOSE
@@ -117,7 +115,7 @@ private function downloadTorrentsFromYts(): void
117115

118116
File::ensureDirectoryExists($outputDirectory);
119117

120-
if ($ytsApi->downloadTorrentTo(
118+
if ($this->yts->downloadTorrentTo(
121119
$matchedTorrent,
122120
"{$outputDirectory}/{$movie->title} ({$movie->year}) {$matchedTorrent->quality?->value}.torrent"
123121
)) {

0 commit comments

Comments
 (0)