@@ -29,15 +29,19 @@ class DownloadCommand extends Command
29
29
30
30
private Quality |null $ quality ;
31
31
32
- private string $ apiToken ;
32
+ private TraktClient $ trakt ;
33
33
34
- public function handle (): void
34
+ private YTSClient $ yts ;
35
+
36
+ public function handle (TraktClient $ traktClient ): void
35
37
{
38
+ $ this ->trakt = $ traktClient ;
39
+ $ this ->yts = $ ytsClient ;
40
+
36
41
$ this ->quality = Quality::tryFrom ($ this ->option ('quality ' ));
37
42
38
43
try {
39
- $ this ->retrieveTraktList ()
40
- ->downloadTorrentsFromYts ();
44
+ $ this ->retrieveTraktList ()->downloadTorrentsFromYts ();
41
45
} catch (\RuntimeException $ exception ) {
42
46
$ this ->warn ($ exception ->getMessage ());
43
47
@@ -47,10 +51,7 @@ public function handle(): void
47
51
48
52
private function retrieveTraktList (): self
49
53
{
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 ' ));
54
55
55
56
$ this ->comment (
56
57
"<options=bold> {$ this ->option ('list ' )}</> (<options=bold> {$ this ->argument ('trakt-user ' )}</>): Retrieved successfully " ,
@@ -70,9 +71,6 @@ private function downloadTorrentsFromYts(): void
70
71
return ;
71
72
}
72
73
73
- /** @var YTSClient $ytsApi */
74
- $ ytsApi = app (YTSClient::class);
75
-
76
74
$ this ->line ('' );
77
75
78
76
/** @var Movie $movie */
@@ -81,7 +79,7 @@ private function downloadTorrentsFromYts(): void
81
79
continue ;
82
80
}
83
81
84
- if (! $ ytsListing = $ ytsApi ->getMovieByImdbId ($ movie ->imdbId , $ this ->quality )) {
82
+ if (! $ ytsListing = $ this -> yts ->getMovieByImdbId ($ movie ->imdbId , $ this ->quality )) {
85
83
$ this ->components ->warn (
86
84
"' {$ movie ->title } ( {$ movie ->year })': Not found on YTS " ,
87
85
OutputInterface::VERBOSITY_VERY_VERBOSE
@@ -117,7 +115,7 @@ private function downloadTorrentsFromYts(): void
117
115
118
116
File::ensureDirectoryExists ($ outputDirectory );
119
117
120
- if ($ ytsApi ->downloadTorrentTo (
118
+ if ($ this -> yts ->downloadTorrentTo (
121
119
$ matchedTorrent ,
122
120
"{$ outputDirectory }/ {$ movie ->title } ( {$ movie ->year }) {$ matchedTorrent ->quality ?->value}.torrent "
123
121
)) {
0 commit comments