15
15
class DownloadCommand extends Command
16
16
{
17
17
/** {@inheritdoc} */
18
- protected $ signature = 'download { trakt-user : Trakt username for the list }
18
+ protected $ signature = 'download { trakt-user= : Trakt username for the list }
19
19
{ --l|list=watchlist : A custom list id or stub }
20
20
{ --o|output=./torrents : The directory to output data to }
21
21
{ --quality=1080p : The quality to download (720p, 1080p or 3D) }
@@ -27,7 +27,7 @@ class DownloadCommand extends Command
27
27
/** @var Collection<Movie> */
28
28
private Collection $ traktList ;
29
29
30
- private Quality | null $ quality ;
30
+ private Quality $ quality ;
31
31
32
32
private TraktClient $ trakt ;
33
33
@@ -38,23 +38,27 @@ public function handle(TraktClient $traktClient): void
38
38
$ this ->trakt = $ traktClient ;
39
39
$ this ->yts = $ ytsClient ;
40
40
41
- $ this ->quality = Quality::tryFrom ($ this ->option ('quality ' ));
41
+ $
42
+ $ this ->quality = Quality::tryFrom ($ this ->option ('quality ' )) ?? Quality::Q_1080P ;
42
43
43
44
try {
44
- $ this ->retrieveTraktList ()->downloadTorrentsFromYts ();
45
+ $ this ->retrieveTraktList (
46
+ $ 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 ();
45
49
} catch (\RuntimeException $ exception ) {
46
50
$ this ->warn ($ exception ->getMessage ());
47
51
48
52
return ;
49
53
}
50
54
}
51
55
52
- private function retrieveTraktList (): self
56
+ private function retrieveTraktList (string $ username , string | null $ list ): self
53
57
{
54
- $ this ->traktList = $ this ->trakt ->getList ($ this -> argument ( ' trakt-user ' ) , $ this -> option ( ' list ' ) );
58
+ $ this ->traktList = $ this ->trakt ->getList ($ username , $ list );
55
59
56
60
$ this ->comment (
57
- "<options=bold> {$ this -> option ( ' list ' ) }</> (<options=bold> {$ this -> argument ( ' trakt-user ' ) }</>): Retrieved successfully " ,
61
+ "<options=bold> {$ list }</> (<options=bold> {$ username }</>): Retrieved successfully " ,
58
62
OutputInterface::VERBOSITY_VERY_VERBOSE
59
63
);
60
64
@@ -104,7 +108,7 @@ private function downloadTorrentsFromYts(): void
104
108
105
109
if (! $ matchedTorrent ) {
106
110
$ this ->components ->warn (
107
- "' {$ movie ->title } ( {$ movie ->year })': No torrent available in ' {$ this ->quality ? ->value}' quality " ,
111
+ "' {$ movie ->title } ( {$ movie ->year })': No torrent available in ' {$ this ->quality ->value }' quality " ,
108
112
OutputInterface::VERBOSITY_VERY_VERBOSE
109
113
);
110
114
0 commit comments