|
1
|
|
|
<?php |
|
2
|
|
|
namespace App\Services\AdditionalProcessing\DTO; |
|
3
|
|
|
use App\Models\Release; |
|
4
|
|
|
/** |
|
5
|
|
|
* Mutable context object that holds the processing state for a single release. |
|
6
|
|
|
* Passed between services during processing to share state. |
|
7
|
|
|
*/ |
|
8
|
|
|
class ReleaseProcessingContext |
|
9
|
|
|
{ |
|
10
|
|
|
// The release being processed |
|
11
|
|
|
public Release $release; |
|
12
|
|
|
// Processing state flags |
|
13
|
|
|
public bool $foundVideo = false; |
|
14
|
|
|
public bool $foundMediaInfo = false; |
|
15
|
|
|
public bool $foundAudioInfo = false; |
|
16
|
|
|
public bool $foundAudioSample = false; |
|
17
|
|
|
public bool $foundJPGSample = false; |
|
18
|
|
|
public bool $foundSample = false; |
|
19
|
|
|
public bool $foundPAR2Info = false; |
|
20
|
|
|
// Password state |
|
21
|
|
|
public int $passwordStatus = 0; |
|
22
|
|
|
public bool $releaseHasPassword = false; |
|
23
|
|
|
// NFO state |
|
24
|
|
|
public bool $releaseHasNoNFO = false; |
|
25
|
|
|
// Group state |
|
26
|
|
|
public string $releaseGroupName = ''; |
|
27
|
|
|
public bool $groupUnavailable = false; |
|
28
|
|
|
// NZB state |
|
29
|
|
|
public bool $nzbHasCompressedFile = false; |
|
30
|
|
|
public array $nzbContents = []; |
|
31
|
|
|
// Message IDs for downloading |
|
32
|
|
|
public array $sampleMessageIDs = []; |
|
33
|
|
|
public array $jpgMessageIDs = []; |
|
34
|
|
|
public string|array $mediaInfoMessageIDs = []; |
|
35
|
|
|
public string|array $audioInfoMessageIDs = []; |
|
36
|
|
|
public array $rarFileMessageIDs = []; |
|
37
|
|
|
public string $audioInfoExtension = ''; |
|
38
|
|
|
// File info counters |
|
39
|
|
|
public int $addedFileInfo = 0; |
|
40
|
|
|
public int $totalFileInfo = 0; |
|
41
|
|
|
public int $compressedFilesChecked = 0; |
|
42
|
|
|
// Temp path for this release |
|
43
|
|
|
public string $tmpPath = ''; |
|
44
|
|
|
public function __construct(Release $release) |
|
45
|
|
|
{ |
|
46
|
|
|
$this->release = $release; |
|
47
|
|
|
} |
|
48
|
|
|
/** |
|
49
|
|
|
* Initialize processing state based on configuration flags. |
|
50
|
|
|
* Sets "found" flags to true if processing is disabled (to skip those steps). |
|
51
|
|
|
*/ |
|
52
|
|
|
public function initializeFromConfig( |
|
53
|
|
|
bool $processVideo, |
|
54
|
|
|
bool $processMediaInfo, |
|
55
|
|
|
bool $processAudioInfo, |
|
56
|
|
|
bool $processAudioSample, |
|
57
|
|
|
bool $processJPGSample, |
|
58
|
|
|
bool $processThumbnails |
|
59
|
|
|
): void { |
|
60
|
|
|
$this->foundVideo = ! $processVideo; |
|
61
|
|
|
$this->foundMediaInfo = ! $processMediaInfo; |
|
62
|
|
|
$this->foundAudioInfo = ! $processAudioInfo; |
|
63
|
|
|
$this->foundAudioSample = ! $processAudioSample; |
|
64
|
|
|
$this->foundJPGSample = ! $processJPGSample; |
|
65
|
|
|
$this->foundSample = ! $processThumbnails; |
|
66
|
|
|
$this->foundPAR2Info = false; |
|
67
|
|
|
} |
|
68
|
|
|
/** |
|
69
|
|
|
* Reset message ID arrays for a fresh processing run. |
|
70
|
|
|
*/ |
|
71
|
|
|
public function resetMessageIDs(): void |
|
72
|
|
|
{ |
|
73
|
|
|
$this->sampleMessageIDs = []; |
|
74
|
|
|
$this->jpgMessageIDs = []; |
|
75
|
|
|
$this->mediaInfoMessageIDs = []; |
|
76
|
|
|
$this->audioInfoMessageIDs = []; |
|
77
|
|
|
$this->rarFileMessageIDs = []; |
|
78
|
|
|
$this->audioInfoExtension = ''; |
|
79
|
|
|
} |
|
80
|
|
|
/** |
|
81
|
|
|
* Reset file counters. |
|
82
|
|
|
*/ |
|
83
|
|
|
public function resetCounters(): void |
|
84
|
|
|
{ |
|
85
|
|
|
$this->addedFileInfo = 0; |
|
86
|
|
|
$this->totalFileInfo = 0; |
|
87
|
|
|
$this->compressedFilesChecked = 0; |
|
88
|
|
|
} |
|
89
|
|
|
/** |
|
90
|
|
|
* Full reset for processing a new release. |
|
91
|
|
|
*/ |
|
92
|
|
|
public function reset(): void |
|
93
|
|
|
{ |
|
94
|
|
|
$this->passwordStatus = 0; |
|
95
|
|
|
$this->releaseHasPassword = false; |
|
96
|
|
|
$this->nzbHasCompressedFile = false; |
|
97
|
|
|
$this->groupUnavailable = false; |
|
98
|
|
|
$this->resetMessageIDs(); |
|
99
|
|
|
$this->resetCounters(); |
|
100
|
|
|
} |
|
101
|
|
|
/** |
|
102
|
|
|
* Check if more media processing is needed. |
|
103
|
|
|
*/ |
|
104
|
|
|
public function needsMediaProcessing(): bool |
|
105
|
|
|
{ |
|
106
|
|
|
return ! $this->foundVideo |
|
107
|
|
|
|| ! $this->foundMediaInfo |
|
108
|
|
|
|| ! $this->foundAudioInfo |
|
109
|
|
|
|| ! $this->foundAudioSample; |
|
110
|
|
|
} |
|
111
|
|
|
/** |
|
112
|
|
|
* Check if any sample is still needed. |
|
113
|
|
|
*/ |
|
114
|
|
|
public function needsSample(): bool |
|
115
|
|
|
{ |
|
116
|
|
|
return ! $this->foundSample || ! $this->foundJPGSample; |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
|