|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Console\Commands; |
|
4
|
|
|
|
|
5
|
|
|
use App\Models\Settings; |
|
6
|
|
|
use App\Services\AdultProcessing\AdultProcessingPipeline; |
|
7
|
|
|
use Illuminate\Console\Command; |
|
8
|
|
|
|
|
9
|
|
|
class ProcessAdultMovies extends Command |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* The name and signature of the console command. |
|
13
|
|
|
* |
|
14
|
|
|
* @var string |
|
15
|
|
|
*/ |
|
16
|
|
|
protected $signature = 'nntmux:process-adult |
|
17
|
|
|
{--title= : Process a specific movie title} |
|
18
|
|
|
{--debug : Enable debug output} |
|
19
|
|
|
{--limit= : Limit number of releases to process}'; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* The console command description. |
|
23
|
|
|
* |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $description = 'Process adult movie releases using the pipeline-based scraper'; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Execute the console command. |
|
30
|
|
|
*/ |
|
31
|
|
|
public function handle(): int |
|
32
|
|
|
{ |
|
33
|
|
|
if ((int) Settings::settingValue('lookupxxx') !== 1) { |
|
34
|
|
|
$this->error('Adult movie lookup is disabled in settings. Enable "lookupxxx" to use this command.'); |
|
35
|
|
|
return Command::FAILURE; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
$debug = $this->option('debug'); |
|
39
|
|
|
$title = $this->option('title'); |
|
40
|
|
|
$limit = $this->option('limit'); |
|
41
|
|
|
|
|
42
|
|
|
$pipeline = new AdultProcessingPipeline([], true); |
|
43
|
|
|
|
|
44
|
|
|
if ($title) { |
|
45
|
|
|
// Process a single title |
|
46
|
|
|
$this->info("Looking up: {$title}"); |
|
47
|
|
|
|
|
48
|
|
|
$result = $pipeline->processMovie($title, $debug); |
|
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
if ($result['status'] === 'matched') { |
|
51
|
|
|
$this->info("Match found on {$result['provider']}!"); |
|
52
|
|
|
$title_display = $result['movieData']['title'] ?? 'N/A'; |
|
53
|
|
|
$synopsis_display = substr($result['movieData']['synopsis'] ?? 'N/A', 0, 200); |
|
54
|
|
|
$this->line("Title: {$title_display}"); |
|
55
|
|
|
$this->line("Synopsis: {$synopsis_display}..."); |
|
56
|
|
|
|
|
57
|
|
|
if (!empty($result['movieData']['boxcover'])) { |
|
58
|
|
|
$cover_url = $result['movieData']['boxcover']; |
|
59
|
|
|
$this->line("Cover: {$cover_url}"); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
if ($debug && !empty($result['debug'])) { |
|
63
|
|
|
$this->newLine(); |
|
64
|
|
|
$this->line('Debug Info:'); |
|
65
|
|
|
$this->line(json_encode($result['debug'], JSON_PRETTY_PRINT)); |
|
66
|
|
|
} |
|
67
|
|
|
} else { |
|
68
|
|
|
$this->warn("No match found for: {$title}"); |
|
69
|
|
|
|
|
70
|
|
|
if ($debug && !empty($result['debug'])) { |
|
71
|
|
|
$this->newLine(); |
|
72
|
|
|
$this->line('Debug Info:'); |
|
73
|
|
|
$this->line(json_encode($result['debug'], JSON_PRETTY_PRINT)); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
} else { |
|
77
|
|
|
// Process all pending releases |
|
78
|
|
|
$this->info('Processing adult movie releases using pipeline...'); |
|
79
|
|
|
|
|
80
|
|
|
if ($limit) { |
|
81
|
|
|
$this->info("Limited to {$limit} releases"); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
$pipeline->processXXXReleases(); |
|
85
|
|
|
|
|
86
|
|
|
$stats = $pipeline->getStats(); |
|
87
|
|
|
|
|
88
|
|
|
$this->newLine(); |
|
89
|
|
|
$this->table( |
|
90
|
|
|
['Metric', 'Value'], |
|
91
|
|
|
[ |
|
92
|
|
|
['Processed', $stats['processed']], |
|
93
|
|
|
['Matched', $stats['matched']], |
|
94
|
|
|
['Failed', $stats['failed']], |
|
95
|
|
|
['Skipped', $stats['skipped']], |
|
96
|
|
|
['Duration', sprintf('%.2f seconds', $stats['duration'])], |
|
97
|
|
|
] |
|
98
|
|
|
); |
|
99
|
|
|
|
|
100
|
|
|
if (!empty($stats['providers'])) { |
|
101
|
|
|
$this->newLine(); |
|
102
|
|
|
$this->info('Provider Statistics:'); |
|
103
|
|
|
$providerData = []; |
|
104
|
|
|
foreach ($stats['providers'] as $provider => $count) { |
|
105
|
|
|
$providerData[] = [$provider, $count]; |
|
106
|
|
|
} |
|
107
|
|
|
$this->table(['Provider', 'Matches'], $providerData); |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
return Command::SUCCESS; |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
|