11
11
use Illuminate \Support \Facades \File ;
12
12
use LaravelZero \Framework \Commands \Command ;
13
13
use Symfony \Component \Console \Output \OutputInterface ;
14
- use function Termwind \render ;
15
14
16
15
class DownloadCommand extends Command
17
16
{
18
17
/** {@inheritdoc} */
19
18
protected $ signature = 'download { trakt-user? : Trakt username for the list }
20
- { --l| list=watchlist : A custom list id or stub }
19
+ { list=watchlist : A custom list id or stub }
21
20
{ --o|output=./torrents : The directory to output data to }
22
21
{ --quality=1080p : The quality to download (720p, 1080p or 3D) }
23
22
{ --y|force : Do not prompt about downloading torrents } ' ;
@@ -28,8 +27,6 @@ class DownloadCommand extends Command
28
27
/** @var Collection<Movie> */
29
28
private Collection $ traktList ;
30
29
31
- private Quality $ quality ;
32
-
33
30
private TraktClient $ trakt ;
34
31
35
32
private YTSClient $ yts ;
@@ -39,13 +36,13 @@ public function handle(TraktClient $traktClient, YTSClient $ytsClient): void
39
36
$ this ->trakt = $ traktClient ;
40
37
$ this ->yts = $ ytsClient ;
41
38
42
- $ this -> quality = Quality::tryFrom ($ this ->option ('quality ' )) ?? Quality::Q_1080P ;
39
+ $ quality = Quality::tryFrom ($ this ->option ('quality ' )) ?? Quality::Q_1080P ;
43
40
44
41
try {
45
42
$ this ->retrieveTraktList (
46
43
$ this ->argument ('trakt-user ' ) ?? $ this ->ask ('What is the Trakt username ' ),
47
- $ this ->option ('list ' ) ?? $ this ->ask ('What is the list slug or id ' ),
48
- )->downloadTorrentsFromYts ();
44
+ $ this ->argument ('list ' ) ?? $ this ->ask ('What is the list slug or id ' ),
45
+ )->downloadTorrentsFromYts ($ quality );
49
46
} catch (\RuntimeException $ exception ) {
50
47
$ this ->warn ($ exception ->getMessage ());
51
48
@@ -83,7 +80,7 @@ private function downloadTorrentsFromYts(): void
83
80
continue ;
84
81
}
85
82
86
- if (! $ ytsListing = $ this ->yts ->getMovieByImdbId ($ movie ->imdbId , $ this -> quality )) {
83
+ if (! $ ytsListing = $ this ->yts ->getMovieByImdbId ($ movie ->imdbId , $ quality )) {
87
84
$ this ->components ->warn (
88
85
"' {$ movie ->title } ( {$ movie ->year })': Not found on YTS " ,
89
86
OutputInterface::VERBOSITY_VERBOSE
@@ -103,12 +100,12 @@ private function downloadTorrentsFromYts(): void
103
100
104
101
/** @var Torrent $matchedTorrent */
105
102
$ matchedTorrent = $ ytsListing ->torrents
106
- ->filter (fn (Torrent $ torrent ) => $ torrent ->quality instanceof $ this -> quality )
103
+ ->filter (fn (Torrent $ torrent ) => $ torrent ->quality === $ quality )
107
104
->first ();
108
105
109
106
if (! $ matchedTorrent ) {
110
107
$ this ->components ->warn (
111
- " ↳ ' {$ movie ->title } ( {$ movie ->year })': No torrent available in ' {$ this -> quality ->value }' quality " ,
108
+ " ↳ ' {$ movie ->title } ( {$ movie ->year })': No torrent available in ' {$ quality ->value }' quality " ,
112
109
OutputInterface::VERBOSITY_VERBOSE
113
110
);
114
111
0 commit comments