|
1
|
|
|
<?php |
|
2
|
|
|
namespace nntmux; |
|
3
|
|
|
|
|
4
|
|
|
use nntmux\db\DB; |
|
5
|
|
|
use nntmux\processing\PostProcess; |
|
6
|
|
|
use nntmux\utility\Utility; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class NameFixer |
|
10
|
|
|
*/ |
|
11
|
|
|
class NameFixer |
|
|
|
|
|
|
12
|
|
|
{ |
|
13
|
|
|
const PREDB_REGEX = '/([\w\(\)]+[\s\._-]([\w\(\)]+[\s\._-])+[\w\(\)]+-\w+)/'; |
|
14
|
|
|
|
|
15
|
|
|
// Constants for name fixing status |
|
16
|
|
|
const PROC_NFO_NONE = 0; |
|
17
|
|
|
const PROC_NFO_DONE = 1; |
|
18
|
|
|
const PROC_FILES_NONE = 0; |
|
19
|
|
|
const PROC_FILES_DONE = 1; |
|
20
|
|
|
const PROC_PAR2_NONE = 0; |
|
21
|
|
|
const PROC_PAR2_DONE = 1; |
|
22
|
|
|
const PROC_UID_NONE = 0; |
|
23
|
|
|
const PROC_UID_DONE = 1; |
|
24
|
|
|
|
|
25
|
|
|
// Constants for overall rename status |
|
26
|
|
|
const IS_RENAMED_NONE = 0; |
|
27
|
|
|
const IS_RENAMED_DONE = 1; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Has the current release found a new name? |
|
31
|
|
|
* |
|
32
|
|
|
* @var bool |
|
33
|
|
|
*/ |
|
34
|
|
|
public $matched; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* How many releases have got a new name? |
|
38
|
|
|
* |
|
39
|
|
|
* @var int |
|
40
|
|
|
*/ |
|
41
|
|
|
public $fixed; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* How many releases were checked. |
|
45
|
|
|
* |
|
46
|
|
|
* @var int |
|
47
|
|
|
*/ |
|
48
|
|
|
public $checked; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Whether or not the check has completed |
|
52
|
|
|
* |
|
53
|
|
|
* @var bool |
|
54
|
|
|
*/ |
|
55
|
|
|
public $done; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Whether or not to echo info to CLI |
|
59
|
|
|
* |
|
60
|
|
|
* @var bool |
|
61
|
|
|
*/ |
|
62
|
|
|
public $echooutput; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Total releases we are working on. |
|
66
|
|
|
* |
|
67
|
|
|
* @var int |
|
68
|
|
|
*/ |
|
69
|
|
|
protected $_totalReleases; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* The cleaned filename we want to match |
|
73
|
|
|
* |
|
74
|
|
|
* @var string |
|
75
|
|
|
*/ |
|
76
|
|
|
protected $_fileName; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* The release ID we are trying to rename |
|
80
|
|
|
* |
|
81
|
|
|
* @var int |
|
82
|
|
|
*/ |
|
83
|
|
|
protected $relid; |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @var string |
|
87
|
|
|
*/ |
|
88
|
|
|
protected $othercats; |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @var string |
|
92
|
|
|
*/ |
|
93
|
|
|
protected $timeother; |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @var string |
|
97
|
|
|
*/ |
|
98
|
|
|
protected $timeall; |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @var string |
|
102
|
|
|
*/ |
|
103
|
|
|
protected $fullother; |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @var string |
|
107
|
|
|
*/ |
|
108
|
|
|
protected $fullall; |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @var \nntmux\db\Settings |
|
112
|
|
|
*/ |
|
113
|
|
|
public $pdo; |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @var \nntmux\ConsoleTools |
|
117
|
|
|
*/ |
|
118
|
|
|
public $consoletools; |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* @var \nntmux\Category |
|
122
|
|
|
*/ |
|
123
|
|
|
public $category; |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @var \nntmux\utility\Utility |
|
127
|
|
|
*/ |
|
128
|
|
|
public $text; |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @var \nntmux\Groups |
|
132
|
|
|
*/ |
|
133
|
|
|
public $_groups; |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* @var \nntmux\SphinxSearch |
|
137
|
|
|
*/ |
|
138
|
|
|
public $sphinx; |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* @param array $options Class instances / Echo to cli. |
|
142
|
|
|
*/ |
|
143
|
|
|
public function __construct(array $options = []) |
|
144
|
|
|
{ |
|
145
|
|
|
$defaults = [ |
|
146
|
|
|
'Echo' => true, |
|
147
|
|
|
'Categorize' => null, |
|
148
|
|
|
'ConsoleTools' => null, |
|
149
|
|
|
'Groups' => null, |
|
150
|
|
|
'Misc' => null, |
|
151
|
|
|
'Settings' => null, |
|
152
|
|
|
'SphinxSearch' => null, |
|
153
|
|
|
]; |
|
154
|
|
|
$options += $defaults; |
|
155
|
|
|
|
|
156
|
|
|
$this->echooutput = ($options['Echo'] && NN_ECHOCLI); |
|
157
|
|
|
$this->relid = $this->fixed = $this->checked = 0; |
|
158
|
|
|
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); |
|
|
|
|
|
|
159
|
|
|
$this->othercats = implode(",", Category::OTHERS_GROUP); |
|
160
|
|
|
$this->timeother = sprintf(' AND rel.adddate > (NOW() - INTERVAL 6 HOUR) AND rel.categories_id IN (%s) GROUP BY rel.id ORDER BY postdate DESC', $this->othercats); |
|
161
|
|
|
$this->timeall = ' AND rel.adddate > (NOW() - INTERVAL 6 HOUR) GROUP BY rel.id ORDER BY postdate DESC'; |
|
162
|
|
|
$this->fullother = sprintf(' AND rel.categories_id IN (%s) GROUP BY rel.id', $this->othercats); |
|
163
|
|
|
$this->fullall = ''; |
|
164
|
|
|
$this->_fileName = ''; |
|
165
|
|
|
$this->done = $this->matched = false; |
|
166
|
|
|
$this->consoletools = ($options['ConsoleTools'] instanceof ConsoleTools ? $options['ConsoleTools'] : new ConsoleTools(['ColorCLI' => $this->pdo->log])); |
|
167
|
|
|
$this->category = ($options['Categorize'] instanceof Categorize ? $options['Categorize'] : new Categorize(['Settings' => $this->pdo])); |
|
168
|
|
|
$this->text = ($options['Misc'] instanceof Utility ? $options['Misc'] : new Utility()); |
|
169
|
|
|
$this->_groups = ($options['Groups'] instanceof Groups ? $options['Groups'] : new Groups(['Settings' => $this->pdo])); |
|
170
|
|
|
$this->sphinx = ($options['SphinxSearch'] instanceof SphinxSearch ? $options['SphinxSearch'] : new SphinxSearch()); |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* Attempts to fix release names using the NFO. |
|
175
|
|
|
* |
|
176
|
|
|
* @param int $time 1: 24 hours, 2: no time limit |
|
177
|
|
|
* @param boolean $echo 1: change the name, anything else: preview of what could have been changed. |
|
178
|
|
|
* @param int $cats 1: other categories, 2: all categories |
|
179
|
|
|
* @param $nameStatus |
|
180
|
|
|
* @param $show |
|
181
|
|
|
*/ |
|
182
|
|
|
public function fixNamesWithNfo($time, $echo, $cats, $nameStatus, $show) |
|
183
|
|
|
{ |
|
184
|
|
|
$this->_echoStartMessage($time, '.nfo files'); |
|
185
|
|
|
$type = 'NFO, '; |
|
186
|
|
|
|
|
187
|
|
|
// Only select releases we haven't checked here before |
|
188
|
|
|
$preId = false; |
|
189
|
|
|
if ($cats === 3) { |
|
190
|
|
|
$query = sprintf(' |
|
191
|
|
|
SELECT rel.id AS releases_id, rel.fromname |
|
192
|
|
|
FROM releases rel |
|
193
|
|
|
INNER JOIN release_nfos nfo ON (nfo.releases_id = rel.id) |
|
194
|
|
|
WHERE rel.nzbstatus = %d |
|
195
|
|
|
AND rel.predb_id = 0', |
|
196
|
|
|
NZB::NZB_ADDED |
|
197
|
|
|
); |
|
198
|
|
|
$cats = 2; |
|
199
|
|
|
$preId = true; |
|
200
|
|
|
} else { |
|
201
|
|
|
$query = sprintf(' |
|
202
|
|
|
SELECT rel.id AS releases_id, rel.fromname |
|
203
|
|
|
FROM releases rel |
|
204
|
|
|
INNER JOIN release_nfos nfo ON (nfo.releases_id = rel.id) |
|
205
|
|
|
WHERE (rel.isrenamed = %d OR rel.categories_id = %d) |
|
206
|
|
|
AND rel.proc_nfo = %d', |
|
207
|
|
|
self::IS_RENAMED_NONE, |
|
208
|
|
|
Category::OTHER_MISC, |
|
209
|
|
|
self::PROC_NFO_NONE |
|
210
|
|
|
); |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
$releases = $this->_getReleases($time, $cats, $query); |
|
214
|
|
|
|
|
215
|
|
|
if ($releases instanceof \Traversable && $releases !== false) { |
|
216
|
|
|
$total = $releases->rowCount(); |
|
217
|
|
|
|
|
218
|
|
|
if ($total > 0) { |
|
219
|
|
|
$this->_totalReleases = $total; |
|
220
|
|
|
echo $this->pdo->log->primary(number_format($total) . ' releases to process.'); |
|
221
|
|
|
|
|
222
|
|
|
foreach ($releases as $rel) { |
|
223
|
|
|
$releaseRow = $this->pdo->queryOneRow( |
|
224
|
|
|
sprintf(' |
|
225
|
|
|
SELECT nfo.releases_id AS nfoid, rel.groups_id, rel.fromname, rel.categories_id, rel.name, rel.searchname, |
|
226
|
|
|
UNCOMPRESS(nfo) AS textstring, rel.id AS releases_id |
|
227
|
|
|
FROM releases rel |
|
228
|
|
|
INNER JOIN release_nfos nfo ON (nfo.releases_id = rel.id) |
|
229
|
|
|
WHERE rel.id = %d', |
|
230
|
|
|
$rel['releases_id'] |
|
231
|
|
|
) |
|
232
|
|
|
); |
|
233
|
|
|
|
|
234
|
|
|
$this->checked++; |
|
235
|
|
|
|
|
236
|
|
|
// Ignore encrypted NFOs. |
|
237
|
|
|
if (preg_match('/^=newz\[NZB\]=\w+/', $releaseRow['textstring'])) { |
|
238
|
|
|
$this->_updateSingleColumn('proc_nfo', self::PROC_NFO_DONE, $rel['releases_id']); |
|
239
|
|
|
continue; |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
$this->done = $this->matched = false; |
|
243
|
|
|
$this->checkName($releaseRow, $echo, $type, $nameStatus, $show, $preId); |
|
244
|
|
|
$this->_echoRenamed($show); |
|
245
|
|
|
} |
|
246
|
|
|
$this->_echoFoundCount($echo, ' NFO\'s'); |
|
|
|
|
|
|
247
|
|
|
} else { |
|
248
|
|
|
echo $this->pdo->log->info('Nothing to fix.'); |
|
249
|
|
|
} |
|
250
|
|
|
} |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
/** |
|
254
|
|
|
* Attempts to fix release names using the File name. |
|
255
|
|
|
* |
|
256
|
|
|
* @param int $time 1: 24 hours, 2: no time limit |
|
257
|
|
|
* @param boolean $echo 1: change the name, anything else: preview of what could have been changed. |
|
258
|
|
|
* @param int $cats 1: other categories, 2: all categories |
|
259
|
|
|
* @param $nameStatus |
|
260
|
|
|
* @param $show |
|
261
|
|
|
*/ |
|
262
|
|
|
public function fixNamesWithFiles($time, $echo, $cats, $nameStatus, $show) |
|
263
|
|
|
{ |
|
264
|
|
|
$this->_echoStartMessage($time, 'file names'); |
|
265
|
|
|
$type = 'Filenames, '; |
|
266
|
|
|
|
|
267
|
|
|
$preId = false; |
|
268
|
|
|
if ($cats === 3) { |
|
269
|
|
|
$query = sprintf(' |
|
270
|
|
|
SELECT rf.name AS textstring, rel.categories_id, rel.name, rel.searchname, rel.fromname, rel.groups_id, |
|
271
|
|
|
rf.releases_id AS fileid, rel.id AS releases_id |
|
272
|
|
|
FROM releases rel |
|
273
|
|
|
INNER JOIN release_files rf ON (rf.releases_id = rel.id) |
|
274
|
|
|
WHERE nzbstatus = %d |
|
275
|
|
|
AND predb_id = 0', |
|
276
|
|
|
NZB::NZB_ADDED |
|
277
|
|
|
); |
|
278
|
|
|
$cats = 2; |
|
279
|
|
|
$preId = true; |
|
280
|
|
|
} else { |
|
281
|
|
|
$query = sprintf(' |
|
282
|
|
|
SELECT rf.name AS textstring, rel.categories_id, rel.name, rel.searchname, rel.fromname, rel.groups_id, |
|
283
|
|
|
rf.releases_id AS fileid, rel.id AS releases_id |
|
284
|
|
|
FROM releases rel |
|
285
|
|
|
INNER JOIN release_files rf ON (rf.releases_id = rel.id) |
|
286
|
|
|
WHERE (rel.isrenamed = %d OR rel.categories_id IN(%d, %d)) |
|
287
|
|
|
AND proc_files = %d', |
|
288
|
|
|
self::IS_RENAMED_NONE, |
|
289
|
|
|
Category::OTHER_MISC, |
|
290
|
|
|
Category::OTHER_HASHED, |
|
291
|
|
|
self::PROC_FILES_NONE |
|
292
|
|
|
); |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
$releases = $this->_getReleases($time, $cats, $query); |
|
296
|
|
|
if ($releases instanceof \Traversable && $releases !== false) { |
|
297
|
|
|
|
|
298
|
|
|
$total = $releases->rowCount(); |
|
299
|
|
|
if ($total > 0) { |
|
300
|
|
|
$this->_totalReleases = $total; |
|
301
|
|
|
echo $this->pdo->log->primary(number_format($total) . ' file names to process.'); |
|
302
|
|
|
|
|
303
|
|
|
foreach ($releases as $release) { |
|
304
|
|
|
$this->done = $this->matched = false; |
|
305
|
|
|
$this->checkName($release, $echo, $type, $nameStatus, $show, $preId); |
|
306
|
|
|
$this->checked++; |
|
307
|
|
|
$this->_echoRenamed($show); |
|
308
|
|
|
} |
|
309
|
|
|
|
|
310
|
|
|
$this->_echoFoundCount($echo, ' files'); |
|
|
|
|
|
|
311
|
|
|
} else { |
|
312
|
|
|
echo $this->pdo->log->info('Nothing to fix.'); |
|
313
|
|
|
} |
|
314
|
|
|
} |
|
315
|
|
|
} |
|
316
|
|
|
|
|
317
|
|
|
/** |
|
318
|
|
|
* Attempts to fix release names using the File name. |
|
319
|
|
|
* |
|
320
|
|
|
* @param int $time 1: 24 hours, 2: no time limit |
|
321
|
|
|
* @param boolean $echo 1: change the name, anything else: preview of what could have been changed. |
|
322
|
|
|
* @param int $cats 1: other categories, 2: all categories |
|
323
|
|
|
* @param $nameStatus |
|
324
|
|
|
* @param $show |
|
325
|
|
|
*/ |
|
326
|
|
View Code Duplication |
public function fixXXXNamesWithFiles($time, $echo, $cats, $nameStatus, $show) |
|
|
|
|
|
|
327
|
|
|
{ |
|
328
|
|
|
$this->_echoStartMessage($time, 'file names'); |
|
329
|
|
|
$type = 'Filenames, '; |
|
330
|
|
|
|
|
331
|
|
|
if ($cats === 3) { |
|
332
|
|
|
$query = sprintf(' |
|
333
|
|
|
SELECT rf.name AS textstring, rel.categories_id, rel.name, rel.searchname, rel.fromname, rel.groups_id, |
|
334
|
|
|
rf.releases_id AS fileid, rel.id AS releases_id |
|
335
|
|
|
FROM releases rel |
|
336
|
|
|
INNER JOIN release_files rf ON (rf.releases_id = rel.id) |
|
337
|
|
|
WHERE nzbstatus = %d |
|
338
|
|
|
AND predb_id = 0', |
|
339
|
|
|
NZB::NZB_ADDED |
|
340
|
|
|
); |
|
341
|
|
|
$cats = 2; |
|
342
|
|
|
} else { |
|
343
|
|
|
$query = sprintf(' |
|
344
|
|
|
SELECT rf.name AS textstring, rel.categories_id, rel.name, rel.searchname, rel.fromname, rel.groups_id, |
|
345
|
|
|
rf.releases_id AS fileid, rel.id AS releases_id |
|
346
|
|
|
FROM releases rel |
|
347
|
|
|
INNER JOIN release_files rf ON (rf.releases_id = rel.id) |
|
348
|
|
|
WHERE (rel.isrenamed = %d OR rel.categories_id IN (%d, %d)) |
|
349
|
|
|
AND rf.name %s', |
|
350
|
|
|
self::IS_RENAMED_NONE, |
|
351
|
|
|
Category::OTHER_MISC, |
|
352
|
|
|
Category::OTHER_HASHED, |
|
353
|
|
|
$this->pdo->likeString('SDPORN', true, true) |
|
354
|
|
|
); |
|
355
|
|
|
} |
|
356
|
|
|
|
|
357
|
|
|
$releases = $this->_getReleases($time, $cats, $query); |
|
358
|
|
|
if ($releases instanceof \Traversable && $releases !== false) { |
|
359
|
|
|
|
|
360
|
|
|
$total = $releases->rowCount(); |
|
361
|
|
|
if ($total > 0) { |
|
362
|
|
|
$this->_totalReleases = $total; |
|
363
|
|
|
echo $this->pdo->log->primary(number_format($total) . ' xxx file names to process.'); |
|
364
|
|
|
|
|
365
|
|
|
foreach ($releases as $release) { |
|
366
|
|
|
$this->done = $this->matched = false; |
|
367
|
|
|
$this->xxxNameCheck($release, $echo, $type, $nameStatus, $show); |
|
368
|
|
|
$this->checked++; |
|
369
|
|
|
$this->_echoRenamed($show); |
|
370
|
|
|
} |
|
371
|
|
|
$this->_echoFoundCount($echo, ' files'); |
|
|
|
|
|
|
372
|
|
|
} else { |
|
373
|
|
|
echo $this->pdo->log->info('Nothing to fix.'); |
|
374
|
|
|
} |
|
375
|
|
|
} |
|
376
|
|
|
} |
|
377
|
|
|
|
|
378
|
|
|
/** |
|
379
|
|
|
* Attempts to fix release names using the File name. |
|
380
|
|
|
* |
|
381
|
|
|
* @param int $time 1: 24 hours, 2: no time limit |
|
382
|
|
|
* @param boolean $echo 1: change the name, anything else: preview of what could have been changed. |
|
383
|
|
|
* @param int $cats 1: other categories, 2: all categories |
|
384
|
|
|
* @param $nameStatus |
|
385
|
|
|
* @param $show |
|
386
|
|
|
*/ |
|
387
|
|
View Code Duplication |
public function fixNamesWithSrr($time, $echo, $cats, $nameStatus, $show) |
|
|
|
|
|
|
388
|
|
|
{ |
|
389
|
|
|
$this->_echoStartMessage($time, 'file names'); |
|
390
|
|
|
$type = 'Filenames, '; |
|
391
|
|
|
|
|
392
|
|
|
if ($cats === 3) { |
|
393
|
|
|
$query = sprintf(' |
|
394
|
|
|
SELECT rf.name AS textstring, rel.categories_id, rel.name, rel.searchname, rel.fromname, rel.groups_id, |
|
395
|
|
|
rf.releases_id AS fileid, rel.id AS releases_id |
|
396
|
|
|
FROM releases rel |
|
397
|
|
|
INNER JOIN release_files rf ON (rf.releases_id = rel.id) |
|
398
|
|
|
WHERE nzbstatus = %d |
|
399
|
|
|
AND predb_id = 0', |
|
400
|
|
|
NZB::NZB_ADDED |
|
401
|
|
|
); |
|
402
|
|
|
$cats = 2; |
|
403
|
|
|
} else { |
|
404
|
|
|
$query = sprintf(' |
|
405
|
|
|
SELECT rf.name AS textstring, rel.categories_id, rel.name, rel.searchname, rel.fromname, rel.groups_id, |
|
406
|
|
|
rf.releases_id AS fileid, rel.id AS releases_id |
|
407
|
|
|
FROM releases rel |
|
408
|
|
|
INNER JOIN release_files rf ON (rf.releases_id = rel.id) |
|
409
|
|
|
WHERE (rel.isrenamed = %d OR rel.categories_id IN (%d, %d)) |
|
410
|
|
|
AND rf.name %s', |
|
411
|
|
|
self::IS_RENAMED_NONE, |
|
412
|
|
|
Category::OTHER_MISC, |
|
413
|
|
|
Category::OTHER_HASHED, |
|
414
|
|
|
$this->pdo->likeString('.srr', true, false) |
|
415
|
|
|
); |
|
416
|
|
|
} |
|
417
|
|
|
|
|
418
|
|
|
$releases = $this->_getReleases($time, $cats, $query); |
|
419
|
|
|
if ($releases instanceof \Traversable && $releases !== false) { |
|
420
|
|
|
|
|
421
|
|
|
$total = $releases->rowCount(); |
|
422
|
|
|
if ($total > 0) { |
|
423
|
|
|
$this->_totalReleases = $total; |
|
424
|
|
|
echo $this->pdo->log->primary(number_format($total) . ' srr file extensions to process.'); |
|
425
|
|
|
|
|
426
|
|
|
foreach ($releases as $release) { |
|
427
|
|
|
$this->done = $this->matched = false; |
|
428
|
|
|
$this->srrNameCheck($release, $echo, $type, $nameStatus, $show); |
|
429
|
|
|
$this->checked++; |
|
430
|
|
|
$this->_echoRenamed($show); |
|
431
|
|
|
} |
|
432
|
|
|
$this->_echoFoundCount($echo, ' files'); |
|
|
|
|
|
|
433
|
|
|
} else { |
|
434
|
|
|
echo $this->pdo->log->info('Nothing to fix.'); |
|
435
|
|
|
} |
|
436
|
|
|
} |
|
437
|
|
|
} |
|
438
|
|
|
|
|
439
|
|
|
/** |
|
440
|
|
|
* Attempts to fix release names using the Par2 File. |
|
441
|
|
|
* |
|
442
|
|
|
* @param int $time 1: 24 hours, 2: no time limit |
|
443
|
|
|
* @param int $echo 1: change the name, anything else: preview of what could have been changed. |
|
444
|
|
|
* @param int $cats 1: other categories, 2: all categories |
|
445
|
|
|
* @param $nameStatus |
|
446
|
|
|
* @param $show |
|
447
|
|
|
* @param NNTP $nntp |
|
448
|
|
|
*/ |
|
449
|
|
|
public function fixNamesWithPar2($time, $echo, $cats, $nameStatus, $show, $nntp) |
|
450
|
|
|
{ |
|
451
|
|
|
$this->_echoStartMessage($time, 'par2 files'); |
|
452
|
|
|
|
|
453
|
|
|
if ($cats === 3) { |
|
454
|
|
|
$query = sprintf(' |
|
455
|
|
|
SELECT rel.id AS releases_id, rel.guid, rel.groups_id, rel.fromname |
|
456
|
|
|
FROM releases rel |
|
457
|
|
|
WHERE rel.nzbstatus = %d |
|
458
|
|
|
AND rel.predb_id = 0', |
|
459
|
|
|
NZB::NZB_ADDED |
|
460
|
|
|
); |
|
461
|
|
|
$cats = 2; |
|
462
|
|
|
} else { |
|
463
|
|
|
$query = sprintf(' |
|
464
|
|
|
SELECT rel.id AS releases_id, rel.guid, rel.groups_id, rel.fromname |
|
465
|
|
|
FROM releases rel |
|
466
|
|
|
WHERE rel.isrenamed = %d |
|
467
|
|
|
AND rel.proc_par2 = %d', |
|
468
|
|
|
self::IS_RENAMED_NONE, |
|
469
|
|
|
self::PROC_PAR2_NONE |
|
470
|
|
|
); |
|
471
|
|
|
} |
|
472
|
|
|
|
|
473
|
|
|
$releases = $this->_getReleases($time, $cats, $query); |
|
474
|
|
|
|
|
475
|
|
|
if ($releases instanceof \Traversable && $releases !== false) { |
|
476
|
|
|
|
|
477
|
|
|
$total = $releases->rowCount(); |
|
478
|
|
|
if ($total > 0) { |
|
479
|
|
|
$this->_totalReleases = $total; |
|
480
|
|
|
|
|
481
|
|
|
echo $this->pdo->log->primary(number_format($total) . ' releases to process.'); |
|
482
|
|
|
$Nfo = new Nfo(['Echo' => $this->echooutput, 'Settings' => $this->pdo]); |
|
483
|
|
|
$nzbContents = new NZBContents( |
|
484
|
|
|
[ |
|
485
|
|
|
'Echo' => $this->echooutput, |
|
486
|
|
|
'NNTP' => $nntp, |
|
487
|
|
|
'Nfo' => $Nfo, |
|
488
|
|
|
'Settings' => $this->pdo, |
|
489
|
|
|
'PostProcess' => new PostProcess(['Settings' => $this->pdo, 'Nfo' => $Nfo]) |
|
490
|
|
|
] |
|
491
|
|
|
); |
|
492
|
|
|
|
|
493
|
|
|
foreach ($releases as $release) { |
|
494
|
|
|
if (($nzbContents->checkPAR2($release['guid'], $release['releases_id'], $release['groups_id'], $nameStatus, $show)) === true) { |
|
495
|
|
|
$this->fixed++; |
|
496
|
|
|
} |
|
497
|
|
|
|
|
498
|
|
|
$this->checked++; |
|
499
|
|
|
$this->_echoRenamed($show); |
|
500
|
|
|
} |
|
501
|
|
|
$this->_echoFoundCount($echo, ' files'); |
|
502
|
|
|
} else { |
|
503
|
|
|
echo $this->pdo->log->alternate('Nothing to fix.'); |
|
504
|
|
|
} |
|
505
|
|
|
} |
|
506
|
|
|
} |
|
507
|
|
|
|
|
508
|
|
|
/** |
|
509
|
|
|
* Attempts to fix release names using the mediainfo xml Unique_ID. |
|
510
|
|
|
* |
|
511
|
|
|
* @param int $time 1: 24 hours, 2: no time limit |
|
512
|
|
|
* @param boolean $echo 1: change the name, anything else: preview of what could have been changed. |
|
513
|
|
|
* @param int $cats 1: other categories, 2: all categories |
|
514
|
|
|
* @param $nameStatus |
|
515
|
|
|
* @param $show |
|
516
|
|
|
*/ |
|
517
|
|
|
public function fixNamesWithMedia($time, $echo, $cats, $nameStatus, $show) |
|
518
|
|
|
{ |
|
519
|
|
|
$type = 'UID, '; |
|
520
|
|
|
|
|
521
|
|
|
$this->_echoStartMessage($time, 'mediainfo Unique_IDs'); |
|
522
|
|
|
|
|
523
|
|
|
// Re-check all releases we haven't matched to a PreDB |
|
524
|
|
|
if ($cats === 3) { |
|
525
|
|
|
$query = sprintf(' |
|
526
|
|
|
SELECT |
|
527
|
|
|
rel.id AS releases_id, rel.size AS relsize, rel.groups_id, rel.fromname, rel.categories_id, |
|
528
|
|
|
rel.name, rel.name AS textstring, rel.predb_id, rel.searchname, |
|
529
|
|
|
HEX(ru.uniqueid) AS uid |
|
530
|
|
|
FROM releases rel |
|
531
|
|
|
LEFT JOIN release_unique ru ON ru.releases_id = rel.id |
|
532
|
|
|
WHERE ru.releases_id IS NOT NULL |
|
533
|
|
|
AND rel.nzbstatus = %d |
|
534
|
|
|
AND rel.predb_id = 0', |
|
535
|
|
|
NZB::NZB_ADDED |
|
536
|
|
|
); |
|
537
|
|
|
$cats = 2; |
|
538
|
|
|
// Otherwise check only releases we haven't renamed and checked uid before in Misc categories |
|
539
|
|
|
} else { |
|
540
|
|
|
$query = sprintf(' |
|
541
|
|
|
SELECT |
|
542
|
|
|
rel.id AS releases_id, rel.size AS relsize, rel.groups_id, rel.fromname, rel.categories_id, |
|
543
|
|
|
rel.name, rel.name AS textstring, rel.predb_id, rel.searchname, |
|
544
|
|
|
HEX(ru.uniqueid) AS uid |
|
545
|
|
|
FROM releases rel |
|
546
|
|
|
LEFT JOIN release_unique ru ON ru.releases_id = rel.id |
|
547
|
|
|
WHERE ru.releases_id IS NOT NULL |
|
548
|
|
|
AND rel.nzbstatus = %d |
|
549
|
|
|
AND rel.isrenamed = %d |
|
550
|
|
|
AND rel.categories_id IN (%d, %d) |
|
551
|
|
|
AND rel.proc_uid = %d', |
|
552
|
|
|
NZB::NZB_ADDED, |
|
553
|
|
|
self::IS_RENAMED_NONE, |
|
554
|
|
|
Category::OTHER_MISC, |
|
555
|
|
|
Category::OTHER_HASHED, |
|
556
|
|
|
self::PROC_UID_NONE |
|
557
|
|
|
); |
|
558
|
|
|
} |
|
559
|
|
|
|
|
560
|
|
|
$releases = $this->_getReleases($time, $cats, $query); |
|
561
|
|
|
if ($releases instanceof \Traversable && $releases !== false) { |
|
562
|
|
|
$total = $releases->rowCount(); |
|
563
|
|
|
if ($total > 0) { |
|
564
|
|
|
$this->_totalReleases = $total; |
|
565
|
|
|
echo $this->pdo->log->primary(number_format($total) . ' unique ids to process.'); |
|
566
|
|
|
foreach ($releases as $rel) { |
|
567
|
|
|
$this->checked++; |
|
568
|
|
|
$this->done = $this->matched = false; |
|
569
|
|
|
$this->uidCheck($rel, $echo, $type, $nameStatus, $show); |
|
570
|
|
|
$this->_echoRenamed($show); |
|
571
|
|
|
} |
|
572
|
|
|
$this->_echoFoundCount($echo, ' UID\'s'); |
|
|
|
|
|
|
573
|
|
|
} else { |
|
574
|
|
|
echo $this->pdo->log->info('Nothing to fix.'); |
|
575
|
|
|
} |
|
576
|
|
|
} |
|
577
|
|
|
} |
|
578
|
|
|
|
|
579
|
|
|
/** |
|
580
|
|
|
* @param int $time 1: 24 hours, 2: no time limit |
|
581
|
|
|
* @param int $cats 1: other categories, 2: all categories |
|
582
|
|
|
* @param string $query Query to execute. |
|
583
|
|
|
* |
|
584
|
|
|
* @param string $limit limit defined by maxperrun |
|
585
|
|
|
* |
|
586
|
|
|
* @return bool|\PDOStatement False on failure, PDOStatement with query results on success. |
|
587
|
|
|
*/ |
|
588
|
|
|
protected function _getReleases($time, $cats, $query, $limit = '') |
|
589
|
|
|
{ |
|
590
|
|
|
$releases = false; |
|
591
|
|
|
$queryLimit = ($limit === '') ? '' : ' LIMIT ' . $limit; |
|
592
|
|
|
// 24 hours, other cats |
|
593
|
|
|
if ($time == 1 && $cats == 1) { |
|
594
|
|
|
echo $this->pdo->log->header($query . $this->timeother . $queryLimit . ";\n"); |
|
595
|
|
|
$releases = $this->pdo->queryDirect($query . $this->timeother . $queryLimit); |
|
596
|
|
|
} // 24 hours, all cats |
|
597
|
|
|
else if ($time == 1 && $cats == 2) { |
|
598
|
|
|
echo $this->pdo->log->header($query . $this->timeall . $queryLimit . ";\n"); |
|
599
|
|
|
$releases = $this->pdo->queryDirect($query . $this->timeall . $queryLimit); |
|
600
|
|
|
} //other cats |
|
601
|
|
|
else if ($time == 2 && $cats == 1) { |
|
602
|
|
|
echo $this->pdo->log->header($query . $this->fullother . $queryLimit . ";\n"); |
|
603
|
|
|
$releases = $this->pdo->queryDirect($query . $this->fullother . $queryLimit); |
|
604
|
|
|
} // all cats |
|
605
|
|
|
else if ($time == 2 && $cats == 2) { |
|
606
|
|
|
echo $this->pdo->log->header($query . $this->fullall . $queryLimit . ";\n"); |
|
607
|
|
|
$releases = $this->pdo->queryDirect($query . $this->fullall . $queryLimit); |
|
608
|
|
|
} |
|
609
|
|
|
|
|
610
|
|
|
return $releases; |
|
611
|
|
|
} |
|
612
|
|
|
|
|
613
|
|
|
/** |
|
614
|
|
|
* Echo the amount of releases that found a new name. |
|
615
|
|
|
* |
|
616
|
|
|
* @param int $echo 1: change the name, anything else: preview of what could have been changed. |
|
617
|
|
|
* @param string $type The function type that found the name. |
|
618
|
|
|
*/ |
|
619
|
|
|
protected function _echoFoundCount($echo, $type) |
|
620
|
|
|
{ |
|
621
|
|
|
if ($echo == 1) { |
|
622
|
|
|
echo $this->pdo->log->header( |
|
623
|
|
|
PHP_EOL . |
|
624
|
|
|
number_format($this->fixed) . |
|
625
|
|
|
' releases have had their names changed out of: ' . |
|
626
|
|
|
number_format($this->checked) . |
|
627
|
|
|
$type . '.' |
|
628
|
|
|
); |
|
629
|
|
|
} else { |
|
630
|
|
|
echo $this->pdo->log->header( |
|
631
|
|
|
PHP_EOL . |
|
632
|
|
|
number_format($this->fixed) . |
|
633
|
|
|
' releases could have their names changed. ' . |
|
634
|
|
|
number_format($this->checked) . |
|
635
|
|
|
$type . ' were checked.' |
|
636
|
|
|
); |
|
637
|
|
|
} |
|
638
|
|
|
} |
|
639
|
|
|
|
|
640
|
|
|
/** |
|
641
|
|
|
* @param int $time 1: 24 hours, 2: no time limit |
|
642
|
|
|
* @param string $type The function type. |
|
643
|
|
|
*/ |
|
644
|
|
|
protected function _echoStartMessage($time, $type) |
|
645
|
|
|
{ |
|
646
|
|
|
echo $this->pdo->log->header( |
|
647
|
|
|
sprintf( |
|
648
|
|
|
'Fixing search names %s using %s.', |
|
649
|
|
|
($time == 1 ? 'in the past 6 hours' : 'since the beginning'), |
|
650
|
|
|
$type |
|
651
|
|
|
) |
|
652
|
|
|
); |
|
653
|
|
|
|
|
654
|
|
|
} |
|
655
|
|
|
|
|
656
|
|
|
/** |
|
657
|
|
|
* @param int $show |
|
658
|
|
|
*/ |
|
659
|
|
|
protected function _echoRenamed($show) |
|
660
|
|
|
{ |
|
661
|
|
|
if ($this->checked % 500 == 0 && $show === 1) { |
|
662
|
|
|
echo $this->pdo->log->alternate(PHP_EOL . number_format($this->checked) . ' files processed.' . PHP_EOL); |
|
663
|
|
|
} |
|
664
|
|
|
|
|
665
|
|
View Code Duplication |
if ($show === 2) { |
|
|
|
|
|
|
666
|
|
|
$this->consoletools->overWritePrimary( |
|
667
|
|
|
'Renamed Releases: [' . |
|
668
|
|
|
number_format($this->fixed) . |
|
669
|
|
|
'] ' . |
|
670
|
|
|
$this->consoletools->percentString($this->checked, $this->_totalReleases) |
|
671
|
|
|
); |
|
672
|
|
|
} |
|
673
|
|
|
} |
|
674
|
|
|
|
|
675
|
|
|
/** |
|
676
|
|
|
* Update the release with the new information. |
|
677
|
|
|
* |
|
678
|
|
|
* @param array $release |
|
679
|
|
|
* @param string $name |
|
680
|
|
|
* @param string $method |
|
681
|
|
|
* @param boolean $echo |
|
682
|
|
|
* @param string $type |
|
683
|
|
|
* @param int $nameStatus |
|
684
|
|
|
* @param int $show |
|
685
|
|
|
* @param int $preId |
|
686
|
|
|
*/ |
|
687
|
|
|
public function updateRelease($release, $name, $method, $echo, $type, $nameStatus, $show, $preId = 0) |
|
688
|
|
|
{ |
|
689
|
|
|
$release['releases_id'] = (isset($release['releases_id']) ? $release['releases_id'] : $release["releaseid"]); |
|
690
|
|
|
if ($this->relid !== $release['releases_id']) { |
|
691
|
|
|
$releaseCleaning = new ReleaseCleaning($this->pdo); |
|
692
|
|
|
$newName = $releaseCleaning->fixerCleaner($name); |
|
693
|
|
|
if (strtolower($newName) != strtolower($release["searchname"])) { |
|
694
|
|
|
$this->matched = true; |
|
695
|
|
|
$this->relid = $release['releases_id']; |
|
696
|
|
|
|
|
697
|
|
|
$determinedCategory = $this->category->determineCategory($release['groups_id'], $newName, !empty($release['fromname']) ? $release['fromname'] : ''); |
|
|
|
|
|
|
698
|
|
|
|
|
699
|
|
|
if ($type === "PAR2, ") { |
|
700
|
|
|
$newName = ucwords($newName); |
|
701
|
|
|
if (preg_match('/(.+?)\.[a-z0-9]{2,3}(PAR2)?$/i', $name, $match)) { |
|
702
|
|
|
$newName = $match[1]; |
|
703
|
|
|
} |
|
704
|
|
|
} |
|
705
|
|
|
|
|
706
|
|
|
$this->fixed++; |
|
707
|
|
|
|
|
708
|
|
|
if(!empty($release['fromname']) && preg_match('/oz@lot[.]com/i', $release['fromname'])) { |
|
709
|
|
|
$newName = preg_replace('/KTR$/', 'SDCLiP', $newName); |
|
710
|
|
|
} |
|
711
|
|
|
$newName = explode("\\", $newName); |
|
712
|
|
|
$newName = preg_replace(['/^[-=_\.:\s]+/', '/[-=_\.:\s]+$/'], '', $newName[0]); |
|
713
|
|
|
|
|
714
|
|
|
if ($this->echooutput === true && $show === 1) { |
|
715
|
|
|
$groupName = $this->_groups->getNameByID($release['groups_id']); |
|
716
|
|
|
$oldCatName = $this->category->getNameByID($release['categories_id']); |
|
717
|
|
|
$newCatName = $this->category->getNameByID($determinedCategory); |
|
718
|
|
|
|
|
719
|
|
|
if ($type === "PAR2, ") { |
|
720
|
|
|
echo PHP_EOL; |
|
721
|
|
|
} |
|
722
|
|
|
|
|
723
|
|
|
echo |
|
724
|
|
|
$this->pdo->log->headerOver("\nNew name: ") . |
|
725
|
|
|
$this->pdo->log->primary(substr($newName, 0, 255)) . |
|
726
|
|
|
$this->pdo->log->headerOver("Old name: ") . |
|
727
|
|
|
$this->pdo->log->primary($release["searchname"]) . |
|
728
|
|
|
$this->pdo->log->headerOver("Use name: ") . |
|
729
|
|
|
$this->pdo->log->primary($release["name"]) . |
|
730
|
|
|
$this->pdo->log->headerOver("New cat: ") . |
|
731
|
|
|
$this->pdo->log->primary($newCatName) . |
|
732
|
|
|
$this->pdo->log->headerOver("Old cat: ") . |
|
733
|
|
|
$this->pdo->log->primary($oldCatName) . |
|
734
|
|
|
$this->pdo->log->headerOver("Group: ") . |
|
735
|
|
|
$this->pdo->log->primary($groupName) . |
|
736
|
|
|
$this->pdo->log->headerOver("Method: ") . |
|
737
|
|
|
$this->pdo->log->primary($type . $method) . |
|
738
|
|
|
$this->pdo->log->headerOver("ReleaseID: ") . |
|
739
|
|
|
$this->pdo->log->primary($release["releases_id"]); |
|
740
|
|
|
if (isset($release['filename']) && $release['filename'] != "") { |
|
741
|
|
|
echo |
|
742
|
|
|
$this->pdo->log->headerOver("Filename: ") . |
|
743
|
|
|
$this->pdo->log->primary($release["filename"]); |
|
744
|
|
|
} |
|
745
|
|
|
|
|
746
|
|
|
if ($type !== "PAR2, ") { |
|
747
|
|
|
echo "\n"; |
|
748
|
|
|
} |
|
749
|
|
|
} |
|
750
|
|
|
|
|
751
|
|
|
$newTitle = $this->pdo->escapeString(substr($newName, 0, 255)); |
|
752
|
|
|
|
|
753
|
|
|
if ($echo == true) { |
|
|
|
|
|
|
754
|
|
|
if ($nameStatus == 1) { |
|
755
|
|
|
$status = ''; |
|
756
|
|
|
switch ($type) { |
|
757
|
|
|
case "NFO, ": |
|
758
|
|
|
$status = "isrenamed = 1, iscategorized = 1, proc_nfo = 1,"; |
|
759
|
|
|
break; |
|
760
|
|
|
case "PAR2, ": |
|
761
|
|
|
$status = "isrenamed = 1, iscategorized = 1, proc_par2 = 1,"; |
|
762
|
|
|
break; |
|
763
|
|
|
case "Filenames, ": |
|
764
|
|
|
case "file matched source: ": |
|
765
|
|
|
$status = "isrenamed = 1, iscategorized = 1, proc_files = 1,"; |
|
766
|
|
|
break; |
|
767
|
|
|
case "SHA1, ": |
|
768
|
|
|
case "MD5, ": |
|
769
|
|
|
$status = "isrenamed = 1, iscategorized = 1, dehashstatus = 1,"; |
|
770
|
|
|
break; |
|
771
|
|
|
case "PreDB FT Exact, ": |
|
772
|
|
|
$status = "isrenamed = 1, iscategorized = 1,"; |
|
773
|
|
|
break; |
|
774
|
|
|
case "sorter, ": |
|
775
|
|
|
$status = "isrenamed = 1, iscategorized = 1, proc_sorter = 1,"; |
|
776
|
|
|
break; |
|
777
|
|
|
case "UID, ": |
|
778
|
|
|
$status = "isrenamed = 1, iscategorized = 1, proc_uid = 1,"; |
|
779
|
|
|
break; |
|
780
|
|
|
} |
|
781
|
|
|
$this->pdo->queryExec( |
|
782
|
|
|
sprintf(' |
|
783
|
|
|
UPDATE releases |
|
784
|
|
|
SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfo_id = NULL, |
|
785
|
|
|
consoleinfo_id = NULL, bookinfo_id = NULL, anidbid = NULL, predb_id = %d, |
|
786
|
|
|
searchname = %s, %s categories_id = %d |
|
787
|
|
|
WHERE id = %d', |
|
788
|
|
|
$preId, |
|
789
|
|
|
$newTitle, |
|
790
|
|
|
$status, |
|
791
|
|
|
$determinedCategory, |
|
792
|
|
|
$release['releases_id'] |
|
793
|
|
|
) |
|
794
|
|
|
); |
|
795
|
|
|
$this->sphinx->updateRelease($release['releases_id'], $this->pdo); |
|
796
|
|
|
} else { |
|
797
|
|
|
$newTitle = $this->pdo->escapeString(substr($newName, 0, 255)); |
|
798
|
|
|
$this->pdo->queryExec( |
|
799
|
|
|
sprintf(' |
|
800
|
|
|
UPDATE releases |
|
801
|
|
|
SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfo_id = NULL, |
|
802
|
|
|
consoleinfo_id = NULL, bookinfo_id = NULL, anidbid = NULL, predb_id = %d, |
|
803
|
|
|
searchname = %s, iscategorized = 1, categories_id = %d |
|
804
|
|
|
WHERE id = %d', |
|
805
|
|
|
$preId, |
|
806
|
|
|
$newTitle, |
|
807
|
|
|
$determinedCategory, |
|
808
|
|
|
$release['releases_id'] |
|
809
|
|
|
) |
|
810
|
|
|
); |
|
811
|
|
|
$this->sphinx->updateRelease($release['releases_id'], $this->pdo); |
|
812
|
|
|
} |
|
813
|
|
|
} |
|
814
|
|
|
} |
|
815
|
|
|
} |
|
816
|
|
|
$this->done = true; |
|
817
|
|
|
} |
|
818
|
|
|
|
|
819
|
|
|
/** |
|
820
|
|
|
* Echo a updated release name to CLI. |
|
821
|
|
|
* |
|
822
|
|
|
* @param array $data |
|
823
|
|
|
* array( |
|
824
|
|
|
* 'new_name' => (string) The new release search name. |
|
825
|
|
|
* 'old_name' => (string) The old release search name. |
|
826
|
|
|
* 'new_category' => (string) The new category name or ID for the release. |
|
827
|
|
|
* 'old_category' => (string) The old category name or ID for the release. |
|
828
|
|
|
* 'group' => (string) The group name or ID of the release. |
|
829
|
|
|
* 'release_id' => (int) The ID of the release. |
|
830
|
|
|
* 'method' => (string) The method used to rename the release. |
|
831
|
|
|
* ) |
|
832
|
|
|
* |
|
833
|
|
|
* @access public |
|
834
|
|
|
* @static |
|
835
|
|
|
* @void |
|
836
|
|
|
*/ |
|
837
|
|
|
public static function echoChangedReleaseName(array $data = |
|
838
|
|
|
[ |
|
839
|
|
|
'new_name' => '', |
|
840
|
|
|
'old_name' => '', |
|
841
|
|
|
'new_category' => '', |
|
842
|
|
|
'old_category' => '', |
|
843
|
|
|
'group' => '', |
|
844
|
|
|
'release_id' => 0, |
|
845
|
|
|
'method' => '' |
|
846
|
|
|
] |
|
847
|
|
|
) |
|
848
|
|
|
{ |
|
849
|
|
|
echo |
|
850
|
|
|
PHP_EOL . |
|
851
|
|
|
ColorCLI::headerOver('New name: ') . ColorCLI::primaryOver($data['new_name']) . PHP_EOL . |
|
852
|
|
|
ColorCLI::headerOver('Old name: ') . ColorCLI::primaryOver($data['old_name']) . PHP_EOL . |
|
853
|
|
|
ColorCLI::headerOver('New category: ') . ColorCLI::primaryOver($data['new_category']) . PHP_EOL . |
|
854
|
|
|
ColorCLI::headerOver('Old category: ') . ColorCLI::primaryOver($data['old_category']) . PHP_EOL . |
|
855
|
|
|
ColorCLI::headerOver('Group: ') . ColorCLI::primaryOver($data['group']) . PHP_EOL . |
|
856
|
|
|
ColorCLI::headerOver('Release ID: ') . ColorCLI::primaryOver($data['release_id']) . PHP_EOL . |
|
857
|
|
|
ColorCLI::headerOver('Method: ') . ColorCLI::primaryOver($data['method']) . PHP_EOL; |
|
858
|
|
|
} |
|
859
|
|
|
|
|
860
|
|
|
// Match a PreDB title to a release name or searchname using an exact full-text match |
|
861
|
|
|
public function matchPredbFT($pre, $echo, $namestatus, $echooutput, $show) |
|
|
|
|
|
|
862
|
|
|
{ |
|
863
|
|
|
$matching = $total = 0; |
|
864
|
|
|
|
|
865
|
|
|
$join = $this->_preFTsearchQuery($pre['title']); |
|
866
|
|
|
|
|
867
|
|
|
if ($join === '') { |
|
868
|
|
|
|
|
869
|
|
|
return $matching; |
|
870
|
|
|
} |
|
871
|
|
|
|
|
872
|
|
|
//Find release matches with fulltext and then identify exact matches with cleaned LIKE string |
|
873
|
|
|
$res = $this->pdo->queryDirect( |
|
874
|
|
|
sprintf(" |
|
875
|
|
|
SELECT r.id AS releases_id, r.name, r.searchname, |
|
876
|
|
|
r.fromname, r.groups_id, r.categories_id |
|
877
|
|
|
FROM releases r |
|
878
|
|
|
%1\$s |
|
879
|
|
|
AND (r.name %2\$s OR r.searchname %2\$s) |
|
880
|
|
|
AND r.predb_id = 0 |
|
881
|
|
|
LIMIT 21", |
|
882
|
|
|
$join, |
|
883
|
|
|
$this->pdo->likeString($pre['title'], true, true) |
|
884
|
|
|
) |
|
885
|
|
|
); |
|
886
|
|
|
|
|
887
|
|
|
if ($res !== false) { |
|
888
|
|
|
$total = $res->rowCount(); |
|
889
|
|
|
} |
|
890
|
|
|
|
|
891
|
|
|
// Run if row count is positive, but do not run if row count exceeds 10 (as this is likely a failed title match) |
|
892
|
|
|
if ($total > 0 && $total <= 15 && $res instanceof \Traversable) { |
|
893
|
|
|
foreach ($res as $row) { |
|
894
|
|
|
if ($pre['title'] !== $row['searchname']) { |
|
895
|
|
|
$this->updateRelease($row, $pre['title'], $method = "Title Match source: " . $pre['source'], $echo, "PreDB FT Exact, ", $namestatus, $show, $pre['predb_id']); |
|
896
|
|
|
$matching++; |
|
897
|
|
|
} else { |
|
898
|
|
|
$this->_updateSingleColumn('predb_id', $pre['predb_id'], $row['releases_id']); |
|
899
|
|
|
} |
|
900
|
|
|
} |
|
901
|
|
|
} elseif ($total >= 16) { |
|
902
|
|
|
$matching = -1; |
|
903
|
|
|
} |
|
904
|
|
|
|
|
905
|
|
|
return $matching; |
|
906
|
|
|
} |
|
907
|
|
|
|
|
908
|
|
|
protected function _preFTsearchQuery($preTitle) |
|
909
|
|
|
{ |
|
910
|
|
|
$join = ''; |
|
911
|
|
|
|
|
912
|
|
|
if (strlen($preTitle) >= 15 && preg_match(self::PREDB_REGEX, $preTitle)) { |
|
913
|
|
|
switch (NN_RELEASE_SEARCH_TYPE) { |
|
914
|
|
|
case ReleaseSearch::SPHINX: |
|
915
|
|
|
$titlematch = SphinxSearch::escapeString($preTitle); |
|
916
|
|
|
$join .= sprintf( |
|
917
|
|
|
'INNER JOIN releases_se rse ON rse.id = r.id |
|
918
|
|
|
WHERE rse.query = "@(name,searchname,filename) %s;mode=extended"', |
|
919
|
|
|
$titlematch |
|
920
|
|
|
); |
|
921
|
|
|
break; |
|
922
|
|
|
case ReleaseSearch::FULLTEXT: |
|
923
|
|
|
//Remove all non-printable chars from PreDB title |
|
924
|
|
|
preg_match_all('#[a-zA-Z0-9]{3,}#', $preTitle, $matches, PREG_PATTERN_ORDER); |
|
925
|
|
|
$titlematch = '+' . implode(' +', $matches[0]); |
|
926
|
|
|
$join .= sprintf( |
|
927
|
|
|
"INNER JOIN release_search_data rs ON rs.releases_id = r.id |
|
928
|
|
|
WHERE |
|
929
|
|
|
(MATCH (rs.name) AGAINST ('%1\$s' IN BOOLEAN MODE) |
|
930
|
|
|
OR MATCH (rs.searchname) AGAINST ('%1\$s' IN BOOLEAN MODE))", |
|
931
|
|
|
$titlematch |
|
932
|
|
|
); |
|
933
|
|
|
break; |
|
934
|
|
|
case ReleaseSearch::LIKE: |
|
935
|
|
|
// Do not add a JOIN for FT, let the query run in LIKE mode only (slow) |
|
936
|
|
|
$join .= 'WHERE 1=1 '; |
|
937
|
|
|
break; |
|
938
|
|
|
} |
|
939
|
|
|
} |
|
940
|
|
|
return $join; |
|
941
|
|
|
} |
|
942
|
|
|
|
|
943
|
|
|
public function getPreFileNames($args = []) |
|
944
|
|
|
{ |
|
945
|
|
|
$timestart = time(); |
|
946
|
|
|
$counter = $counted = 0; |
|
947
|
|
|
$limit = $orderby = ''; |
|
948
|
|
|
$show = (isset($args[2]) && $args[2] === 'show') ? 1 : 0; |
|
949
|
|
|
|
|
950
|
|
View Code Duplication |
if (isset($args[1]) && is_numeric($args[1])) { |
|
|
|
|
|
|
951
|
|
|
$orderby = "ORDER BY r.id DESC"; |
|
952
|
|
|
$limit = "LIMIT " . $args[1]; |
|
953
|
|
|
} |
|
954
|
|
|
|
|
955
|
|
|
echo $this->pdo->log->header("\nMatch PreFiles (${args[1]}) Started at " . date('g:i:s')); |
|
956
|
|
|
echo $this->pdo->log->primary("Matching predb filename to cleaned release_files.name.\n"); |
|
957
|
|
|
|
|
958
|
|
|
$query = $this->pdo->queryDirect( |
|
959
|
|
|
sprintf(' |
|
960
|
|
|
SELECT r.id AS releases_id, r.name, r.searchname, |
|
961
|
|
|
r.groups_id, r.fromname, r.categories_id, |
|
962
|
|
|
rf.name AS filename |
|
963
|
|
|
FROM releases r |
|
964
|
|
|
INNER JOIN release_files rf ON r.id = rf.releases_id |
|
965
|
|
|
AND rf.name IS NOT NULL |
|
966
|
|
|
WHERE r.predb_id = 0 |
|
967
|
|
|
%s %s', |
|
968
|
|
|
$orderby, |
|
969
|
|
|
$limit |
|
970
|
|
|
) |
|
971
|
|
|
); |
|
972
|
|
|
|
|
973
|
|
|
if ($query !== false) { |
|
974
|
|
|
$total = $query->rowCount(); |
|
975
|
|
|
|
|
976
|
|
|
if ($total > 0 && $query instanceof \Traversable) { |
|
977
|
|
|
echo $this->pdo->log->header("\n" . number_format($total) . ' releases to process.'); |
|
978
|
|
|
|
|
979
|
|
|
foreach ($query as $row) { |
|
980
|
|
|
$success = $this->matchPredbFiles($row, 1, 1, true, $show); |
|
|
|
|
|
|
981
|
|
|
if ($success === 1) { |
|
982
|
|
|
$counted++; |
|
983
|
|
|
} |
|
984
|
|
|
if ($show === 0) { |
|
985
|
|
|
$this->consoletools->overWritePrimary("Renamed Releases: [" . number_format($counted) . "] " . $this->consoletools->percentString(++$counter, $total)); |
|
986
|
|
|
} |
|
987
|
|
|
} |
|
988
|
|
|
echo $this->pdo->log->header("\nRenamed " . number_format($counted) . " releases in " . $this->consoletools->convertTime(time() - $timestart) . "."); |
|
989
|
|
|
} else { |
|
990
|
|
|
echo $this->pdo->log->info("\nNothing to do."); |
|
991
|
|
|
} |
|
992
|
|
|
} |
|
993
|
|
|
} |
|
994
|
|
|
|
|
995
|
|
|
/** |
|
996
|
|
|
* Match a release filename to a PreDB filename or title. |
|
997
|
|
|
* |
|
998
|
|
|
* @param $release |
|
999
|
|
|
* @param boolean $echo |
|
1000
|
|
|
* @param integer $namestatus |
|
1001
|
|
|
* @param boolean $echooutput |
|
1002
|
|
|
* @param integer $show |
|
1003
|
|
|
* |
|
1004
|
|
|
* @return int |
|
1005
|
|
|
*/ |
|
1006
|
|
|
public function matchPredbFiles($release, $echo, $namestatus, $echooutput, $show) |
|
|
|
|
|
|
1007
|
|
|
{ |
|
1008
|
|
|
$matching = 0; |
|
1009
|
|
|
$this->_fileName = $this->_cleanMatchFiles($release['filename']); |
|
1010
|
|
|
$pre = false; |
|
1011
|
|
|
$preMatch = preg_match('/(\d{2}\.\d{2}\.\d{2})+[\w-.]+[\w]$/i', $this->_fileName, $match); |
|
1012
|
|
|
if($preMatch) { |
|
1013
|
|
|
$result = $this->pdo->queryOneRow(sprintf("SELECT filename AS filename FROM predb WHERE MATCH(filename) AGAINST ('$match[0]' IN BOOLEAN MODE)")); |
|
|
|
|
|
|
1014
|
|
|
$preFTmatch = preg_match('/(\d{2}\.\d{2}\.\d{2})+[\w-.]+[\w]$/i', $result['filename'], $match1); |
|
1015
|
|
|
if($preFTmatch) { |
|
1016
|
|
|
if ($match[0] == $match1[0]) { |
|
1017
|
|
|
$this->_fileName = $result['filename']; |
|
1018
|
|
|
} |
|
1019
|
|
|
} |
|
1020
|
|
|
} |
|
1021
|
|
|
|
|
1022
|
|
|
if ($this->_fileName !== '') { |
|
1023
|
|
|
$pre = $this->pdo->queryOneRow( |
|
1024
|
|
|
sprintf(' |
|
1025
|
|
|
SELECT id AS predb_id, title, source |
|
1026
|
|
|
FROM predb |
|
1027
|
|
|
WHERE filename = %s |
|
1028
|
|
|
OR title = %1$s', |
|
1029
|
|
|
$this->pdo->escapeString($this->_fileName) |
|
1030
|
|
|
) |
|
1031
|
|
|
); |
|
1032
|
|
|
} |
|
1033
|
|
|
|
|
1034
|
|
View Code Duplication |
if (isset($pre) && $pre !== false) { |
|
|
|
|
|
|
1035
|
|
|
if ($pre['title'] !== $release['searchname']) { |
|
1036
|
|
|
$this->updateRelease($release, $pre['title'], $method = "file matched source: " . $pre['source'], $echo, "PreDB file match, ", $namestatus, $show, $pre['predb_id']); |
|
1037
|
|
|
} else { |
|
1038
|
|
|
$this->_updateSingleColumn('predb_id', $pre['predb_id'], $release['releases_id']); |
|
1039
|
|
|
} |
|
1040
|
|
|
$matching++; |
|
1041
|
|
|
} |
|
1042
|
|
|
|
|
1043
|
|
|
return $matching; |
|
1044
|
|
|
} |
|
1045
|
|
|
|
|
1046
|
|
|
/** |
|
1047
|
|
|
* Cleans file names for PreDB Match |
|
1048
|
|
|
* |
|
1049
|
|
|
* @param string $fileName |
|
1050
|
|
|
* |
|
1051
|
|
|
* @return string |
|
1052
|
|
|
*/ |
|
1053
|
|
|
protected function _cleanMatchFiles($fileName = '') |
|
1054
|
|
|
{ |
|
1055
|
|
|
|
|
1056
|
|
|
// first strip all non-printing chars from filename |
|
1057
|
|
|
$this->_fileName = $this->text->stripNonPrintingChars($fileName); |
|
1058
|
|
|
|
|
1059
|
|
|
if (strlen($this->_fileName) !== false && strlen($this->_fileName) > 0 && strpos($this->_fileName, '.') !== 0) { |
|
1060
|
|
|
switch (true) { |
|
|
|
|
|
|
1061
|
|
|
|
|
1062
|
|
View Code Duplication |
case strpos($this->_fileName, '.') !== false: |
|
|
|
|
|
|
1063
|
|
|
//some filenames start with a period that ends up creating bad matches so we don't process them |
|
1064
|
|
|
$this->_fileName = $this->text->cutStringUsingLast('.', $this->_fileName, "left", false); |
|
|
|
|
|
|
1065
|
|
|
continue; |
|
1066
|
|
|
|
|
1067
|
|
|
//if filename has a .part001, send it back to the function to cut the next period |
|
1068
|
|
View Code Duplication |
case preg_match('/\.part\d+$/', $this->_fileName): |
|
|
|
|
|
|
1069
|
|
|
$this->_fileName = $this->text->cutStringUsingLast('.', $this->_fileName, "left", false); |
|
1070
|
|
|
continue; |
|
1071
|
|
|
|
|
1072
|
|
|
//if filename has a .vol001, send it back to the function to cut the next period |
|
1073
|
|
View Code Duplication |
case preg_match('/\.vol\d+(\+\d+)?$/', $this->_fileName): |
|
|
|
|
|
|
1074
|
|
|
$this->_fileName = $this->text->cutStringUsingLast('.', $this->_fileName, "left", false); |
|
1075
|
|
|
continue; |
|
1076
|
|
|
|
|
1077
|
|
|
//if filename contains a slash, cut the string and keep string to the right of the last slash to remove dir |
|
1078
|
|
View Code Duplication |
case strpos($this->_fileName, '\\') !== false: |
|
|
|
|
|
|
1079
|
|
|
$this->_fileName = $this->text->cutStringUsingLast('\\', $this->_fileName, "right", false); |
|
|
|
|
|
|
1080
|
|
|
continue; |
|
1081
|
|
|
|
|
1082
|
|
|
// A lot of obscured releases have one NFO file properly named with a track number (Audio) at the front of it |
|
1083
|
|
|
// This will strip out the track and match it to its pre title |
|
1084
|
|
|
case preg_match('/^\d{2}-/', $this->_fileName): |
|
1085
|
|
|
$this->_fileName = preg_replace('/^\d{2}-/', '', $this->_fileName); |
|
1086
|
|
|
} |
|
1087
|
|
|
|
|
1088
|
|
|
return trim($this->_fileName); |
|
1089
|
|
|
} |
|
1090
|
|
|
} |
|
1091
|
|
|
|
|
1092
|
|
|
/** |
|
1093
|
|
|
* Match a Hash from the predb to a release. |
|
1094
|
|
|
* |
|
1095
|
|
|
* @param string $hash |
|
1096
|
|
|
* @param $release |
|
1097
|
|
|
* @param $echo |
|
1098
|
|
|
* @param $namestatus |
|
1099
|
|
|
* @param boolean $echooutput |
|
1100
|
|
|
* @param $show |
|
1101
|
|
|
* |
|
1102
|
|
|
* @return int |
|
1103
|
|
|
*/ |
|
1104
|
|
|
public function matchPredbHash($hash, $release, $echo, $namestatus, $echooutput, $show) |
|
|
|
|
|
|
1105
|
|
|
{ |
|
1106
|
|
|
$pdo = $this->pdo; |
|
1107
|
|
|
$matching = 0; |
|
1108
|
|
|
$this->matched = false; |
|
1109
|
|
|
|
|
1110
|
|
|
// Determine MD5 or SHA1 |
|
1111
|
|
|
if (strlen($hash) === 40) { |
|
1112
|
|
|
$hashtype = "SHA1, "; |
|
1113
|
|
|
} else { |
|
1114
|
|
|
$hashtype = "MD5, "; |
|
1115
|
|
|
} |
|
1116
|
|
|
|
|
1117
|
|
|
$row = $pdo->queryOneRow( |
|
1118
|
|
|
sprintf(" |
|
1119
|
|
|
SELECT p.id AS predb_id, p.title, p.source |
|
1120
|
|
|
FROM predb p INNER JOIN predb_hashes h ON h.predb_id = p.id |
|
1121
|
|
|
WHERE h.hash = UNHEX(%s) |
|
1122
|
|
|
LIMIT 1", |
|
1123
|
|
|
$pdo->escapeString($hash) |
|
1124
|
|
|
) |
|
1125
|
|
|
); |
|
1126
|
|
|
|
|
1127
|
|
View Code Duplication |
if ($row !== false) { |
|
|
|
|
|
|
1128
|
|
|
if ($row["title"] !== $release["searchname"]) { |
|
1129
|
|
|
$this->updateRelease($release, $row["title"], $method = "predb hash release name: " . $row["source"], $echo, $hashtype, $namestatus, $show, $row['predb_id']); |
|
1130
|
|
|
$matching++; |
|
1131
|
|
|
} |
|
1132
|
|
|
} else { |
|
1133
|
|
|
$this->_updateSingleColumn('dehashstatus', $release['dehashstatus'] - 1, $release['releases_id']); |
|
1134
|
|
|
} |
|
1135
|
|
|
|
|
1136
|
|
|
return $matching; |
|
1137
|
|
|
} |
|
1138
|
|
|
|
|
1139
|
|
|
/** |
|
1140
|
|
|
* Check the array using regex for a clean name. |
|
1141
|
|
|
* |
|
1142
|
|
|
* @param $release |
|
1143
|
|
|
* @param boolean $echo |
|
1144
|
|
|
* @param string $type |
|
1145
|
|
|
* @param $namestatus |
|
1146
|
|
|
* @param $show |
|
1147
|
|
|
* @param boolean $preid |
|
1148
|
|
|
* |
|
1149
|
|
|
* @return boolean |
|
1150
|
|
|
*/ |
|
1151
|
|
|
public function checkName($release, $echo, $type, $namestatus, $show, $preid = false) |
|
1152
|
|
|
{ |
|
1153
|
|
|
// Get pre style name from releases.name |
|
1154
|
|
|
if (preg_match_all(self::PREDB_REGEX, $release['textstring'], $matches) && !preg_match('/Source\s\:/i', $release['textstring'])) { |
|
1155
|
|
|
foreach ($matches as $match) { |
|
1156
|
|
|
foreach ($match as $val) { |
|
1157
|
|
|
$title = $this->pdo->queryOneRow("SELECT title, id from predb WHERE title = " . $this->pdo->escapeString(trim($val))); |
|
1158
|
|
|
if ($title !== false) { |
|
1159
|
|
|
$this->updateRelease($release, $title['title'], $method = "preDB: Match", $echo, $type, $namestatus, $show, $title['id']); |
|
1160
|
|
|
$preid = true; |
|
1161
|
|
|
} |
|
1162
|
|
|
} |
|
1163
|
|
|
} |
|
1164
|
|
|
} |
|
1165
|
|
|
|
|
1166
|
|
|
// if only processing for PreDB match skip to return |
|
1167
|
|
|
if ($preid !== true) { |
|
1168
|
|
|
|
|
1169
|
|
|
switch ($type) { |
|
1170
|
|
|
case "PAR2, ": |
|
1171
|
|
|
$this->fileCheck($release, $echo, $type, $namestatus, $show); |
|
1172
|
|
|
break; |
|
1173
|
|
|
case "UID, ": |
|
1174
|
|
|
$this->uidCheck($release, $echo, $type, $namestatus, $show); |
|
1175
|
|
|
break; |
|
1176
|
|
|
case "NFO, ": |
|
1177
|
|
|
$this->nfoCheckTV($release, $echo, $type, $namestatus, $show); |
|
1178
|
|
|
$this->nfoCheckMov($release, $echo, $type, $namestatus, $show); |
|
1179
|
|
|
$this->nfoCheckMus($release, $echo, $type, $namestatus, $show); |
|
1180
|
|
|
$this->nfoCheckTY($release, $echo, $type, $namestatus, $show); |
|
1181
|
|
|
$this->nfoCheckG($release, $echo, $type, $namestatus, $show); |
|
1182
|
|
|
continue; |
|
1183
|
|
|
case "Filenames, ": |
|
1184
|
|
|
$this->fileCheck($release, $echo, $type, $namestatus, $show); |
|
1185
|
|
|
continue; |
|
1186
|
|
|
default: |
|
1187
|
|
|
$this->tvCheck($release, $echo, $type, $namestatus, $show); |
|
1188
|
|
|
$this->movieCheck($release, $echo, $type, $namestatus, $show); |
|
1189
|
|
|
$this->gameCheck($release, $echo, $type, $namestatus, $show); |
|
1190
|
|
|
$this->appCheck($release, $echo, $type, $namestatus, $show); |
|
1191
|
|
|
} |
|
1192
|
|
|
|
|
1193
|
|
|
// set NameFixer process flags after run |
|
1194
|
|
|
if ($namestatus == 1 && $this->matched === false) { |
|
1195
|
|
|
switch ($type) { |
|
1196
|
|
|
case "NFO, ": |
|
1197
|
|
|
$this->_updateSingleColumn('proc_nfo', self::PROC_NFO_DONE, $release['releases_id']); |
|
1198
|
|
|
break; |
|
1199
|
|
|
case "Filenames, ": |
|
1200
|
|
|
$this->_updateSingleColumn('proc_files', self::PROC_FILES_DONE, $release['releases_id']); |
|
1201
|
|
|
break; |
|
1202
|
|
|
case "PAR2, ": |
|
1203
|
|
|
$this->_updateSingleColumn('proc_par2', self::PROC_FILES_DONE, $release['releases_id']); |
|
1204
|
|
|
break; |
|
1205
|
|
|
case "UID, ": |
|
1206
|
|
|
$this->_updateSingleColumn('proc_uid', self::PROC_UID_DONE, $release['releases_id']); |
|
1207
|
|
|
break; |
|
1208
|
|
|
} |
|
1209
|
|
|
} |
|
1210
|
|
|
} |
|
1211
|
|
|
|
|
1212
|
|
|
return $this->matched; |
|
1213
|
|
|
} |
|
1214
|
|
|
|
|
1215
|
|
|
/** This function updates a single variable column in releases |
|
1216
|
|
|
* The first parameter is the column to update, the second is the value |
|
1217
|
|
|
* The final parameter is the ID of the release to update |
|
1218
|
|
|
* |
|
1219
|
|
|
* @param string $column |
|
1220
|
|
|
* @param integer $status |
|
1221
|
|
|
* @param integer $id |
|
1222
|
|
|
*/ |
|
1223
|
|
|
public function _updateSingleColumn($column = '', $status = 0, $id = 0) |
|
1224
|
|
|
{ |
|
1225
|
|
|
if ($column !== '' && $id !== 0) { |
|
1226
|
|
|
$this->pdo->queryExec( |
|
1227
|
|
|
sprintf(' |
|
1228
|
|
|
UPDATE releases |
|
1229
|
|
|
SET %s = %s |
|
1230
|
|
|
WHERE id = %d', |
|
1231
|
|
|
$column, |
|
1232
|
|
|
(is_numeric($status) ? $status : $this->pdo->escapeString($status)), |
|
1233
|
|
|
$id |
|
1234
|
|
|
) |
|
1235
|
|
|
); |
|
1236
|
|
|
} |
|
1237
|
|
|
} |
|
1238
|
|
|
|
|
1239
|
|
|
/** |
|
1240
|
|
|
* Look for a TV name. |
|
1241
|
|
|
* |
|
1242
|
|
|
* @param $release |
|
1243
|
|
|
* @param boolean $echo |
|
1244
|
|
|
* @param string $type |
|
1245
|
|
|
* @param $namestatus |
|
1246
|
|
|
* @param $show |
|
1247
|
|
|
*/ |
|
1248
|
|
|
public function tvCheck($release, $echo, $type, $namestatus, $show) |
|
1249
|
|
|
{ |
|
1250
|
|
|
$result = []; |
|
1251
|
|
|
|
|
1252
|
|
|
if ($this->done === false && $this->relid !== $release["releases_id"]) { |
|
1253
|
|
|
|
|
1254
|
|
View Code Duplication |
if (preg_match('/\w[-\w.\',;& ]+((s\d{1,2}[._ -]?[bde]\d{1,2})|(?<!\d)[S|]\d{1,2}[E|x]\d{1,}(?!\d)|ep[._ -]?\d{2})[-\w.\',;.()]+(BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[._ -][-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
|
|
|
|
|
1255
|
|
|
$this->updateRelease($release, $result["0"], $method = "tvCheck: Title.SxxExx.Text.source.group", $echo, $type, $namestatus, $show); |
|
1256
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+((s\d{1,2}[._ -]?[bde]\d{1,2})|\d{1,2}x\d{2}|ep[._ -]?\d{2})[-\w.\',;& ]+((19|20)\d\d)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1257
|
|
|
$this->updateRelease($release, $result["0"], $method = "tvCheck: Title.SxxExx.Text.year.group", $echo, $type, $namestatus, $show); |
|
1258
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+((s\d{1,2}[._ -]?[bde]\d{1,2})|\d{1,2}x\d{2}|ep[._ -]?\d{2})[-\w.\',;& ]+(480|720|1080)[ip][._ -](BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[._ -](DivX|[HX][._ -]?264|MPEG2|XviD(HD)?|WMV)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1259
|
|
|
$this->updateRelease($release, $result["0"], $method = "tvCheck: Title.SxxExx.Text.resolution.source.vcodec.group", $echo, $type, $namestatus, $show); |
|
1260
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+((s\d{1,2}[._ -]?[bde]\d{1,2})|\d{1,2}x\d{2}|ep[._ -]?\d{2})[._ -](BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[._ -](DivX|[HX][._ -]?264|MPEG2|XviD(HD)?|WMV)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1261
|
|
|
$this->updateRelease($release, $result["0"], $method = "tvCheck: Title.SxxExx.source.vcodec.group", $echo, $type, $namestatus, $show); |
|
1262
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+((s\d{1,2}[._ -]?[bde]\d{1,2})|\d{1,2}x\d{2}|ep[._ -]?\d{2})[._ -](AAC( LC)?|AC-?3|DD5([._ -]1)?|(A_)?DTS-?(HD)?|Dolby( ?TrueHD)?|MP3|TrueHD)[._ -](BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[._ -](480|720|1080)[ip][._ -](DivX|[HX][._ -]?264|MPEG2|XviD(HD)?|WMV)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1263
|
|
|
$this->updateRelease($release, $result["0"], $method = "tvCheck: Title.SxxExx.acodec.source.res.vcodec.group", $echo, $type, $namestatus, $show); |
|
1264
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+((s\d{1,2}[._ -]?[bde]\d{1,2})|\d{1,2}x\d{2}|ep[._ -]?\d{2})[-\w.\',;& ]+((19|20)\d\d)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1265
|
|
|
$this->updateRelease($release, $result["0"], $method = "tvCheck: Title.SxxExx.resolution.source.vcodec.group", $echo, $type, $namestatus, $show); |
|
1266
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+((19|20)\d\d)[._ -]((s\d{1,2}[._ -]?[bde]\d{1,2})|\d{1,2}x\d{2}|ep[._ -]?\d{2})[._ -](BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1267
|
|
|
$this->updateRelease($release, $result["0"], $method = "tvCheck: Title.year.###(season/episode).source.group", $echo, $type, $namestatus, $show); |
|
1268
|
|
|
} else if (preg_match('/\w(19|20)\d\d[._ -]\d{2}[._ -]\d{2}[._ -](IndyCar|NBA|NCW(T|Y)S|NNS|NSCS?)([._ -](19|20)\d\d)?[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1269
|
|
|
$this->updateRelease($release, $result["0"], $method = "tvCheck: Sports", $echo, $type, $namestatus, $show); |
|
1270
|
|
|
} |
|
1271
|
|
|
} |
|
1272
|
|
|
} |
|
1273
|
|
|
|
|
1274
|
|
|
/** |
|
1275
|
|
|
* Look for a movie name. |
|
1276
|
|
|
* |
|
1277
|
|
|
* @param $release |
|
1278
|
|
|
* @param boolean $echo |
|
1279
|
|
|
* @param string $type |
|
1280
|
|
|
* @param $namestatus |
|
1281
|
|
|
* @param $show |
|
1282
|
|
|
*/ |
|
1283
|
|
|
public function movieCheck($release, $echo, $type, $namestatus, $show) |
|
1284
|
|
|
{ |
|
1285
|
|
|
$result = []; |
|
1286
|
|
|
|
|
1287
|
|
|
if ($this->done === false && $this->relid !== $release["releases_id"]) { |
|
1288
|
|
|
|
|
1289
|
|
|
if (preg_match('/\w[-\w.\',;& ]+((19|20)\d\d)[-\w.\',;& ]+(480|720|1080)[ip][._ -](DivX|[HX][._ -]?264|MPEG2|XviD(HD)?|WMV)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1290
|
|
|
$this->updateRelease($release, $result["0"], $method = "movieCheck: Title.year.Text.res.vcod.group", $echo, $type, $namestatus, $show); |
|
1291
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+((19|20)\d\d)[._ -](BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[._ -](DivX|[HX][._ -]?264|MPEG2|XviD(HD)?|WMV)[._ -](480|720|1080)[ip][-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1292
|
|
|
$this->updateRelease($release, $result["0"], $method = "movieCheck: Title.year.source.vcodec.res.group", $echo, $type, $namestatus, $show); |
|
1293
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+((19|20)\d\d)[._ -](BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[._ -](DivX|[HX][._ -]?264|MPEG2|XviD(HD)?|WMV)[._ -](AAC( LC)?|AC-?3|DD5([._ -]1)?|(A_)?DTS-?(HD)?|Dolby( ?TrueHD)?|MP3|TrueHD)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1294
|
|
|
$this->updateRelease($release, $result["0"], $method = "movieCheck: Title.year.source.vcodec.acodec.group", $echo, $type, $namestatus, $show); |
|
1295
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+(Brazilian|Chinese|Croatian|Danish|Deutsch|Dutch|Estonian|English|Finnish|Flemish|Francais|French|German|Greek|Hebrew|Icelandic|Italian|Japenese|Japan|Japanese|Korean|Latin|Nordic|Norwegian|Polish|Portuguese|Russian|Serbian|Slovenian|Swedish|Spanisch|Spanish|Thai|Turkish)[._ -](AAC( LC)?|AC-?3|DD5([._ -]1)?|(A_)?DTS-?(HD)?|Dolby( ?TrueHD)?|MP3|TrueHD)[._ -](BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[._ -](DivX|[HX][._ -]?264|MPEG2|XviD(HD)?|WMV)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1296
|
|
|
$this->updateRelease($release, $result["0"], $method = "movieCheck: Title.year.language.acodec.source.vcodec.group", $echo, $type, $namestatus, $show); |
|
1297
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+((19|20)\d\d)[._ -](480|720|1080)[ip][._ -](BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[._ -](AAC( LC)?|AC-?3|DD5([._ -]1)?|(A_)?DTS-?(HD)?|Dolby( ?TrueHD)?|MP3|TrueHD)[._ -](DivX|[HX][._ -]?264|MPEG2|XviD(HD)?|WMV)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1298
|
|
|
$this->updateRelease($release, $result["0"], $method = "movieCheck: Title.year.resolution.source.acodec.vcodec.group", $echo, $type, $namestatus, $show); |
|
1299
|
|
View Code Duplication |
} else if (preg_match('/\w[-\w.\',;& ]+((19|20)\d\d)[._ -](480|720|1080)[ip][._ -](BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[._ -](DivX|[HX][._ -]?264|MPEG2|XviD(HD)?|WMV)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
|
|
|
|
|
1300
|
|
|
$this->updateRelease($release, $result["0"], $method = "movieCheck: Title.year.resolution.source.vcodec.group", $echo, $type, $namestatus, $show); |
|
1301
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+((19|20)\d\d)[._ -](BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[._ -](480|720|1080)[ip][._ -](AAC( LC)?|AC-?3|DD5([._ -]1)?|(A_)?DTS-?(HD)?|Dolby( ?TrueHD)?|MP3|TrueHD)[._ -](DivX|[HX][._ -]?264|MPEG2|XviD(HD)?|WMV)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1302
|
|
|
$this->updateRelease($release, $result["0"], $method = "movieCheck: Title.year.source.resolution.acodec.vcodec.group", $echo, $type, $namestatus, $show); |
|
1303
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+((19|20)\d\d)[._ -](480|720|1080)[ip][._ -](AAC( LC)?|AC-?3|DD5([._ -]1)?|(A_)?DTS-?(HD)?|Dolby( ?TrueHD)?|MP3|TrueHD)[._ -](DivX|[HX][._ -]?264|MPEG2|XviD(HD)?|WMV)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1304
|
|
|
$this->updateRelease($release, $result["0"], $method = "movieCheck: Title.year.resolution.acodec.vcodec.group", $echo, $type, $namestatus, $show); |
|
1305
|
|
|
} else if (preg_match('/[-\w.\',;& ]+((19|20)\d\d)[._ -](BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BR(RIP)?|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[._ -](480|720|1080)[ip][._ -][-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1306
|
|
|
$this->updateRelease($release, $result["0"], $method = "movieCheck: Title.year.source.res.group", $echo, $type, $namestatus, $show); |
|
1307
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+((19|20)\d\d)[._ -][-\w.\',;& ]+[._ -](BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BR(RIP)?|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[._ -](DivX|[HX][._ -]?264|MPEG2|XviD(HD)?|WMV)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1308
|
|
|
$this->updateRelease($release, $result["0"], $method = "movieCheck: Title.year.eptitle.source.vcodec.group", $echo, $type, $namestatus, $show); |
|
1309
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+(480|720|1080)[ip][._ -](BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[._ -](AAC( LC)?|AC-?3|DD5([._ -]1)?|(A_)?DTS-?(HD)?|Dolby( ?TrueHD)?|MP3|TrueHD)[._ -](DivX|[HX][._ -]?264|MPEG2|XviD(HD)?|WMV)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1310
|
|
|
$this->updateRelease($release, $result["0"], $method = "movieCheck: Title.resolution.source.acodec.vcodec.group", $echo, $type, $namestatus, $show); |
|
1311
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+(480|720|1080)[ip][._ -](AAC( LC)?|AC-?3|DD5([._ -]1)?|(A_)?DTS-?(HD)?|Dolby( ?TrueHD)?|MP3|TrueHD)[-\w.\',;& ]+(BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[._ -]((19|20)\d\d)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1312
|
|
|
$this->updateRelease($release, $result["0"], $method = "movieCheck: Title.resolution.acodec.eptitle.source.year.group", $echo, $type, $namestatus, $show); |
|
1313
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+(Brazilian|Chinese|Croatian|Danish|Deutsch|Dutch|Estonian|English|Finnish|Flemish|Francais|French|German|Greek|Hebrew|Icelandic|Italian|Japenese|Japan|Japanese|Korean|Latin|Nordic|Norwegian|Polish|Portuguese|Russian|Serbian|Slovenian|Swedish|Spanisch|Spanish|Thai|Turkish)[._ -]((19|20)\d\d)[._ -](AAC( LC)?|AC-?3|DD5([._ -]1)?|(A_)?DTS-?(HD)?|Dolby( ?TrueHD)?|MP3|TrueHD)[._ -](BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1314
|
|
|
$this->updateRelease($release, $result["0"], $method = "movieCheck: Title.language.year.acodec.src", $echo, $type, $namestatus, $show); |
|
1315
|
|
|
} |
|
1316
|
|
|
} |
|
1317
|
|
|
} |
|
1318
|
|
|
|
|
1319
|
|
|
/** |
|
1320
|
|
|
* Look for a game name. |
|
1321
|
|
|
* |
|
1322
|
|
|
* @param $release |
|
1323
|
|
|
* @param boolean $echo |
|
1324
|
|
|
* @param string $type |
|
1325
|
|
|
* @param $namestatus |
|
1326
|
|
|
* @param $show |
|
1327
|
|
|
*/ |
|
1328
|
|
|
public function gameCheck($release, $echo, $type, $namestatus, $show) |
|
1329
|
|
|
{ |
|
1330
|
|
|
$result = []; |
|
1331
|
|
|
|
|
1332
|
|
|
if ($this->done === false && $this->relid !== $release["releases_id"]) { |
|
1333
|
|
|
|
|
1334
|
|
|
if (preg_match('/\w[-\w.\',;& ]+(ASIA|DLC|EUR|GOTY|JPN|KOR|MULTI\d{1}|NTSCU?|PAL|RF|Region[._ -]?Free|USA|XBLA)[._ -](DLC[._ -]Complete|FRENCH|GERMAN|MULTI\d{1}|PROPER|PSN|READ[._ -]?NFO|UMD)?[._ -]?(GC|NDS|NGC|PS3|PSP|WII|XBOX(360)?)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1335
|
|
|
$this->updateRelease($release, $result["0"], $method = "gameCheck: Videogames 1", $echo, $type, $namestatus, $show); |
|
1336
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+(GC|NDS|NGC|PS3|WII|XBOX(360)?)[._ -](DUPLEX|iNSOMNi|OneUp|STRANGE|SWAG|SKY)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1337
|
|
|
$this->updateRelease($release, $result["0"], $method = "gameCheck: Videogames 2", $echo, $type, $namestatus, $show); |
|
1338
|
|
View Code Duplication |
} else if (preg_match('/\w[\w.\',;-].+-OUTLAWS/i', $release["textstring"], $result)) { |
|
|
|
|
|
|
1339
|
|
|
$result = str_replace("OUTLAWS", "PC GAME OUTLAWS", $result['0']); |
|
1340
|
|
|
$this->updateRelease($release, $result["0"], $method = "gameCheck: PC Games -OUTLAWS", $echo, $type, $namestatus, $show); |
|
1341
|
|
|
} else if (preg_match('/\w[\w.\',;-].+\-ALiAS/i', $release["textstring"], $result)) { |
|
1342
|
|
|
$newresult = str_replace("-ALiAS", " PC GAME ALiAS", $result['0']); |
|
1343
|
|
|
$this->updateRelease($release, $newresult, $method = "gameCheck: PC Games -ALiAS", $echo, $type, $namestatus, $show); |
|
1344
|
|
|
} |
|
1345
|
|
|
} |
|
1346
|
|
|
} |
|
1347
|
|
|
|
|
1348
|
|
|
/** |
|
1349
|
|
|
* Look for a app name. |
|
1350
|
|
|
* |
|
1351
|
|
|
* @param $release |
|
1352
|
|
|
* @param boolean $echo |
|
1353
|
|
|
* @param string $type |
|
1354
|
|
|
* @param $namestatus |
|
1355
|
|
|
* @param $show |
|
1356
|
|
|
*/ |
|
1357
|
|
View Code Duplication |
public function appCheck($release, $echo, $type, $namestatus, $show) |
|
|
|
|
|
|
1358
|
|
|
{ |
|
1359
|
|
|
$result = []; |
|
1360
|
|
|
|
|
1361
|
|
|
if ($this->done === false && $this->relid !== $release["releases_id"]) { |
|
1362
|
|
|
|
|
1363
|
|
|
if (preg_match('/\w[-\w.\',;& ]+(\d{1,10}|Linux|UNIX)[._ -](RPM)?[._ -]?(X64)?[._ -]?(Incl)[._ -](Keygen)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1364
|
|
|
$this->updateRelease($release, $result["0"], $method = "appCheck: Apps 1", $echo, $type, $namestatus, $show); |
|
1365
|
|
|
} else if (preg_match('/\w[-\w.\',;& ]+\d{1,8}[._ -](winall-freeware)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
1366
|
|
|
$this->updateRelease($release, $result["0"], $method = "appCheck: Apps 2", $echo, $type, $namestatus, $show); |
|
1367
|
|
|
} |
|
1368
|
|
|
} |
|
1369
|
|
|
} |
|
1370
|
|
|
|
|
1371
|
|
|
/* |
|
1372
|
|
|
* Just for NFOS. |
|
1373
|
|
|
*/ |
|
1374
|
|
|
|
|
1375
|
|
|
/** |
|
1376
|
|
|
* TV. |
|
1377
|
|
|
* |
|
1378
|
|
|
* @param $release |
|
1379
|
|
|
* @param boolean $echo |
|
1380
|
|
|
* @param string $type |
|
1381
|
|
|
* @param $namestatus |
|
1382
|
|
|
* @param $show |
|
1383
|
|
|
*/ |
|
1384
|
|
View Code Duplication |
public function nfoCheckTV($release, $echo, $type, $namestatus, $show) |
|
|
|
|
|
|
1385
|
|
|
{ |
|
1386
|
|
|
$result = []; |
|
1387
|
|
|
|
|
1388
|
|
|
if ($this->done === false && $this->relid !== $release['releases_id']) { |
|
1389
|
|
|
|
|
1390
|
|
|
if (preg_match('/:\s*.*[\\\\\/]([A-Z0-9].+?S\d+[.-_ ]?[ED]\d+.+?)\.\w{2,}\s+/i', $release["textstring"], $result)) { |
|
1391
|
|
|
$this->updateRelease($release, $result["1"], $method = "nfoCheck: Generic TV 1", $echo, $type, $namestatus, $show); |
|
1392
|
|
|
} else if (preg_match('/(?:(\:\s{1,}))(.+?S\d{1,3}[.-_ ]?[ED]\d{1,3}.+?)(\s{2,}|\r|\n)/i', $release["textstring"], $result)) { |
|
1393
|
|
|
$this->updateRelease($release, $result["2"], $method = "nfoCheck: Generic TV 2", $echo, $type, $namestatus, $show); |
|
1394
|
|
|
} |
|
1395
|
|
|
} |
|
1396
|
|
|
} |
|
1397
|
|
|
|
|
1398
|
|
|
/** |
|
1399
|
|
|
* Movies. |
|
1400
|
|
|
* |
|
1401
|
|
|
* @param $release |
|
1402
|
|
|
* @param boolean $echo |
|
1403
|
|
|
* @param string $type |
|
1404
|
|
|
* @param $namestatus |
|
1405
|
|
|
* @param $show |
|
1406
|
|
|
*/ |
|
1407
|
|
|
public function nfoCheckMov($release, $echo, $type, $namestatus, $show) |
|
1408
|
|
|
{ |
|
1409
|
|
|
$result = []; |
|
1410
|
|
|
|
|
1411
|
|
|
if ($this->done === false && $this->relid !== $release["releases_id"]) { |
|
1412
|
|
|
|
|
1413
|
|
|
if (preg_match('/(?:((?!Source\s)\:\s{1,}))(.+?(19|20)\d\d.+?(BDRip|bluray|DVD(R|Rip)?|XVID).+?)(\s{2,}|\r|\n)/i', $release["textstring"], $result)) { |
|
1414
|
|
|
$this->updateRelease($release, $result["2"], $method = "nfoCheck: Generic Movies 1", $echo, $type, $namestatus, $show); |
|
1415
|
|
|
} else if (preg_match('/(?:(\s{2,}))((?!Source).+?[\.\-_ ](19|20)\d\d.+?(BDRip|bluray|DVD(R|Rip)?|XVID).+?)(\s{2,}|\r|\n)/i', $release["textstring"], $result)) { |
|
1416
|
|
|
$this->updateRelease($release, $result["2"], $method = "nfoCheck: Generic Movies 2", $echo, $type, $namestatus, $show); |
|
1417
|
|
|
} else if (preg_match('/(?:(\s{2,}))(.+?[\.\-_ ](NTSC|MULTi).+?(MULTi|DVDR)[\.\-_ ].+?)(\s{2,}|\r|\n)/i', $release["textstring"], $result)) { |
|
1418
|
|
|
$this->updateRelease($release, $result["2"], $method = "nfoCheck: Generic Movies 3", $echo, $type, $namestatus, $show); |
|
1419
|
|
|
} |
|
1420
|
|
|
} |
|
1421
|
|
|
} |
|
1422
|
|
|
|
|
1423
|
|
|
/** |
|
1424
|
|
|
* @param $release |
|
1425
|
|
|
* @param boolean $echo |
|
1426
|
|
|
* @param string $type |
|
1427
|
|
|
* @param $namestatus |
|
1428
|
|
|
* @param $show |
|
1429
|
|
|
*/ |
|
1430
|
|
|
public function nfoCheckMus($release, $echo, $type, $namestatus, $show) |
|
1431
|
|
|
{ |
|
1432
|
|
|
$result = []; |
|
1433
|
|
|
|
|
1434
|
|
|
if ($this->done === false && $this->relid !== $release["releases_id"]) { |
|
1435
|
|
|
|
|
1436
|
|
|
if (preg_match('/(?:\s{2,})(.+?-FM-\d{2}-\d{2})/i', $release["textstring"], $result)) { |
|
1437
|
|
|
$newname = str_replace('-FM-', '-FM-Radio-MP3-', $result["1"]); |
|
1438
|
|
|
$this->updateRelease($release, $newname, $method = "nfoCheck: Music FM RADIO", $echo, $type, $namestatus, $show); |
|
1439
|
|
|
} |
|
1440
|
|
|
} |
|
1441
|
|
|
} |
|
1442
|
|
|
|
|
1443
|
|
|
/** |
|
1444
|
|
|
* Title (year) |
|
1445
|
|
|
* |
|
1446
|
|
|
* @param $release |
|
1447
|
|
|
* @param boolean $echo |
|
1448
|
|
|
* @param string $type |
|
1449
|
|
|
* @param $namestatus |
|
1450
|
|
|
* @param $show |
|
1451
|
|
|
*/ |
|
1452
|
|
|
public function nfoCheckTY($release, $echo, $type, $namestatus, $show) |
|
1453
|
|
|
{ |
|
1454
|
|
|
$result = []; |
|
1455
|
|
|
|
|
1456
|
|
|
if ($this->done === false && $this->relid !== $release["releases_id"]) { |
|
1457
|
|
|
if (preg_match('/(\w[-\w`~!@#$%^&*()_+={}|"<>?\[\]\\;\',.\/ ]+\s?\((19|20)\d\d\))/i', $release["textstring"], $result) && !preg_match('/\.pdf|Audio ?Book/i', $release["textstring"])) { |
|
1458
|
|
|
$releasename = $result[0]; |
|
1459
|
|
|
if (preg_match('/(idiomas|lang|language|langue|sprache).*?\b(?P<lang>Brazilian|Chinese|Croatian|Danish|DE|Deutsch|Dutch|Estonian|ES|English|Englisch|Finnish|Flemish|Francais|French|FR|German|Greek|Hebrew|Icelandic|Italian|Japenese|Japan|Japanese|Korean|Latin|Nordic|Norwegian|Polish|Portuguese|Russian|Serbian|Slovenian|Swedish|Spanisch|Spanish|Thai|Turkish)\b/i', $release["textstring"], $result)) { |
|
1460
|
|
|
switch ($result['lang']) { |
|
1461
|
|
|
case 'DE': |
|
1462
|
|
|
$result['lang'] = 'DUTCH'; |
|
1463
|
|
|
break; |
|
1464
|
|
|
case 'Englisch': |
|
1465
|
|
|
$result['lang'] = 'ENGLISH'; |
|
1466
|
|
|
break; |
|
1467
|
|
|
case 'FR': |
|
1468
|
|
|
$result['lang'] = 'FRENCH'; |
|
1469
|
|
|
break; |
|
1470
|
|
|
case 'ES': |
|
1471
|
|
|
$result['lang'] = 'SPANISH'; |
|
1472
|
|
|
break; |
|
1473
|
|
|
default: |
|
1474
|
|
|
break; |
|
1475
|
|
|
} |
|
1476
|
|
|
$releasename = $releasename . "." . $result['lang']; |
|
1477
|
|
|
} |
|
1478
|
|
|
|
|
1479
|
|
|
if (preg_match('/(frame size|(video )?res(olution)?|video).*?(?P<res>(272|336|480|494|528|608|\(?640|688|704|720x480|810|816|820|1 ?080|1280( \@)?|1 ?920(x1080)?))/i', $release["textstring"], $result)) { |
|
1480
|
|
|
switch ($result['res']) { |
|
1481
|
|
|
case '272': |
|
1482
|
|
|
case '336': |
|
1483
|
|
|
case '480': |
|
1484
|
|
|
case '494': |
|
1485
|
|
|
case '608': |
|
1486
|
|
|
case '640': |
|
1487
|
|
|
case '(640': |
|
1488
|
|
|
case '688': |
|
1489
|
|
|
case '704': |
|
1490
|
|
|
case '720x480': |
|
1491
|
|
|
$result['res'] = '480p'; |
|
1492
|
|
|
break; |
|
1493
|
|
|
case '1280x720': |
|
1494
|
|
|
case '1280': |
|
1495
|
|
|
case '1280 @': |
|
1496
|
|
|
$result['res'] = '720p'; |
|
1497
|
|
|
break; |
|
1498
|
|
|
case '810': |
|
1499
|
|
|
case '816': |
|
1500
|
|
|
case '820': |
|
1501
|
|
|
case '1920': |
|
1502
|
|
|
case '1 920': |
|
1503
|
|
|
case '1080': |
|
1504
|
|
|
case '1 080': |
|
1505
|
|
|
case '1920x1080': |
|
1506
|
|
|
$result['res'] = '1080p'; |
|
1507
|
|
|
break; |
|
1508
|
|
|
} |
|
1509
|
|
|
|
|
1510
|
|
|
$releasename = $releasename . "." . $result['res']; |
|
1511
|
|
View Code Duplication |
} else if (preg_match('/(largeur|width).*?(?P<res>(\(?640|688|704|720|1280( \@)?|1 ?920))/i', $release["textstring"], $result)) { |
|
|
|
|
|
|
1512
|
|
|
switch ($result['res']) { |
|
1513
|
|
|
case '640': |
|
1514
|
|
|
case '(640': |
|
1515
|
|
|
case '688': |
|
1516
|
|
|
case '704': |
|
1517
|
|
|
case '720': |
|
1518
|
|
|
$result['res'] = '480p'; |
|
1519
|
|
|
break; |
|
1520
|
|
|
case '1280 @': |
|
1521
|
|
|
case '1280': |
|
1522
|
|
|
$result['res'] = '720p'; |
|
1523
|
|
|
break; |
|
1524
|
|
|
case '1920': |
|
1525
|
|
|
case '1 920': |
|
1526
|
|
|
$result['res'] = '1080p'; |
|
1527
|
|
|
break; |
|
1528
|
|
|
} |
|
1529
|
|
|
|
|
1530
|
|
|
$releasename = $releasename . "." . $result['res']; |
|
1531
|
|
|
} |
|
1532
|
|
|
|
|
1533
|
|
|
if (preg_match('/source.*?\b(?P<source>BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)\b/i', $release["textstring"], $result)) { |
|
1534
|
|
|
|
|
1535
|
|
|
switch ($result['source']) { |
|
1536
|
|
|
case 'BD': |
|
1537
|
|
|
$result['source'] = 'Bluray.x264'; |
|
1538
|
|
|
break; |
|
1539
|
|
|
case 'CAMRIP': |
|
1540
|
|
|
$result['source'] = 'CAM'; |
|
1541
|
|
|
break; |
|
1542
|
|
|
case 'DBrip': |
|
1543
|
|
|
$result['source'] = 'BDRIP'; |
|
1544
|
|
|
break; |
|
1545
|
|
|
case 'DVD R1': |
|
1546
|
|
|
case 'NTSC': |
|
1547
|
|
|
case 'PAL': |
|
1548
|
|
|
case 'VOD': |
|
1549
|
|
|
$result['source'] = 'DVD'; |
|
1550
|
|
|
break; |
|
1551
|
|
|
case 'HD': |
|
1552
|
|
|
$result['source'] = 'HDTV'; |
|
1553
|
|
|
break; |
|
1554
|
|
|
case 'Ripped ': |
|
1555
|
|
|
$result['source'] = 'DVDRIP'; |
|
1556
|
|
|
} |
|
1557
|
|
|
|
|
1558
|
|
|
$releasename = $releasename . "." . $result['source']; |
|
1559
|
|
|
} else if (preg_match('/(codec( (name|code))?|(original )?format|res(olution)|video( (codec|format|res))?|tv system|type|writing library).*?\b(?P<video>AVC|AVI|DBrip|DIVX|\(Divx|DVD|[HX][._ -]?264|MPEG-4 Visual|NTSC|PAL|WMV|XVID)\b/i', $release["textstring"], $result)) { |
|
1560
|
|
|
switch ($result['video']) { |
|
1561
|
|
|
case 'AVI': |
|
1562
|
|
|
$result['video'] = 'DVDRIP'; |
|
1563
|
|
|
break; |
|
1564
|
|
|
case 'DBrip': |
|
1565
|
|
|
$result['video'] = 'BDRIP'; |
|
1566
|
|
|
break; |
|
1567
|
|
|
case '(Divx': |
|
1568
|
|
|
$result['video'] = 'DIVX'; |
|
1569
|
|
|
break; |
|
1570
|
|
|
case 'h264': |
|
1571
|
|
|
case 'h-264': |
|
1572
|
|
|
case 'h.264': |
|
1573
|
|
|
$result['video'] = 'H264'; |
|
1574
|
|
|
break; |
|
1575
|
|
|
case 'MPEG-4 Visual': |
|
1576
|
|
|
case 'x264': |
|
1577
|
|
|
case 'x-264': |
|
1578
|
|
|
case 'x.264': |
|
1579
|
|
|
$result['video'] = 'x264'; |
|
1580
|
|
|
break; |
|
1581
|
|
|
case 'NTSC': |
|
1582
|
|
|
case 'PAL': |
|
1583
|
|
|
$result['video'] = 'DVD'; |
|
1584
|
|
|
break; |
|
1585
|
|
|
} |
|
1586
|
|
|
|
|
1587
|
|
|
$releasename = $releasename . "." . $result['video']; |
|
1588
|
|
|
} |
|
1589
|
|
|
|
|
1590
|
|
View Code Duplication |
if (preg_match('/(audio( format)?|codec( name)?|format).*?\b(?P<audio>0x0055 MPEG-1 Layer 3|AAC( LC)?|AC-?3|\(AC3|DD5(.1)?|(A_)?DTS-?(HD)?|Dolby(\s?TrueHD)?|TrueHD|FLAC|MP3)\b/i', $release["textstring"], $result)) { |
|
|
|
|
|
|
1591
|
|
|
|
|
1592
|
|
|
switch ($result['audio']) { |
|
1593
|
|
|
case '0x0055 MPEG-1 Layer 3': |
|
1594
|
|
|
$result['audio'] = 'MP3'; |
|
1595
|
|
|
break; |
|
1596
|
|
|
case 'AC-3': |
|
1597
|
|
|
case '(AC3': |
|
1598
|
|
|
$result['audio'] = 'AC3'; |
|
1599
|
|
|
break; |
|
1600
|
|
|
case 'AAC LC': |
|
1601
|
|
|
$result['audio'] = 'AAC'; |
|
1602
|
|
|
break; |
|
1603
|
|
|
case 'A_DTS': |
|
1604
|
|
|
case 'DTS-HD': |
|
1605
|
|
|
case 'DTSHD': |
|
1606
|
|
|
$result['audio'] = 'DTS'; |
|
1607
|
|
|
} |
|
1608
|
|
|
$releasename = $releasename . "." . $result['audio']; |
|
1609
|
|
|
} |
|
1610
|
|
|
$releasename = $releasename . "-NoGroup"; |
|
1611
|
|
|
$this->updateRelease($release, $releasename, $method = "nfoCheck: Title (Year)", $echo, $type, $namestatus, $show); |
|
1612
|
|
|
} |
|
1613
|
|
|
} |
|
1614
|
|
|
} |
|
1615
|
|
|
|
|
1616
|
|
|
/** |
|
1617
|
|
|
* Games. |
|
1618
|
|
|
* |
|
1619
|
|
|
* @param $release |
|
1620
|
|
|
* @param boolean $echo |
|
1621
|
|
|
* @param string $type |
|
1622
|
|
|
* @param $namestatus |
|
1623
|
|
|
* @param $show |
|
1624
|
|
|
*/ |
|
1625
|
|
|
public function nfoCheckG($release, $echo, $type, $namestatus, $show) |
|
1626
|
|
|
{ |
|
1627
|
|
|
$result = []; |
|
1628
|
|
|
|
|
1629
|
|
|
if ($this->done === false && $this->relid !== $release["releases_id"]) { |
|
1630
|
|
|
if (preg_match('/ALiAS|BAT-TEAM|FAiRLiGHT|Game Type|Glamoury|HI2U|iTWINS|JAGUAR|(LARGE|MEDIUM)ISO|MAZE|nERv|PROPHET|PROFiT|PROCYON|RELOADED|REVOLVER|ROGUE|ViTALiTY/i', $release["textstring"])) { |
|
1631
|
|
View Code Duplication |
if (preg_match('/\w[\w.+&*\/\()\',;: -]+\(c\)[-\w.\',;& ]+\w/i', $release["textstring"], $result)) { |
|
|
|
|
|
|
1632
|
|
|
$releasename = str_replace(["(c)", "(C)"], "(GAMES) (c)", $result['0']); |
|
1633
|
|
|
$this->updateRelease($release, $releasename, $method = "nfoCheck: PC Games (c)", $echo, $type, $namestatus, $show); |
|
1634
|
|
|
} else if (preg_match('/\w[\w.+&*\/()\',;: -]+\*ISO\*/i', $release["textstring"], $result)) { |
|
1635
|
|
|
$releasename = str_replace("*ISO*", "*ISO* (PC GAMES)", $result['0']); |
|
1636
|
|
|
$this->updateRelease($release, $releasename, $method = "nfoCheck: PC Games *ISO*", $echo, $type, $namestatus, $show); |
|
1637
|
|
|
} |
|
1638
|
|
|
} |
|
1639
|
|
|
} |
|
1640
|
|
|
} |
|
1641
|
|
|
|
|
1642
|
|
|
// |
|
1643
|
|
|
/** |
|
1644
|
|
|
* Misc. |
|
1645
|
|
|
* |
|
1646
|
|
|
* @param $release |
|
1647
|
|
|
* @param boolean $echo |
|
1648
|
|
|
* @param string $type |
|
1649
|
|
|
* @param $namestatus |
|
1650
|
|
|
* @param $show |
|
1651
|
|
|
*/ |
|
1652
|
|
|
public function nfoCheckMisc($release, $echo, $type, $namestatus, $show) |
|
1653
|
|
|
{ |
|
1654
|
|
|
if ($this->done === false && $this->relid !== $release["releases_id"]) { |
|
1655
|
|
|
|
|
1656
|
|
|
if (preg_match('/Supplier.+?IGUANA/i', $release["textstring"])) { |
|
1657
|
|
|
$releasename = ''; |
|
1658
|
|
|
$result = []; |
|
1659
|
|
|
if (preg_match('/\w[-\w`~!@#$%^&*()+={}|:"<>?\[\]\\;\',.\/ ]+\s\((19|20)\d\d\)/i', $release["textstring"], $result)) { |
|
1660
|
|
|
$releasename = $result[0]; |
|
1661
|
|
|
} else if (preg_match('/\s\[\*\] (English|Dutch|French|German|Spanish)\b/i', $release["textstring"], $result)) { |
|
1662
|
|
|
$releasename = $releasename . "." . $result[1]; |
|
1663
|
|
|
} else if (preg_match('/\s\[\*\] (DT?S [2567][._ -][0-2]( MONO)?)\b/i', $release["textstring"], $result)) { |
|
1664
|
|
|
$releasename = $releasename . "." . $result[2]; |
|
1665
|
|
|
} else if (preg_match('/Format.+(DVD(5|9|R)?|[HX][._ -]?264)\b/i', $release["textstring"], $result)) { |
|
1666
|
|
|
$releasename = $releasename . "." . $result[1]; |
|
1667
|
|
|
} else if (preg_match('/\[(640x.+|1280x.+|1920x.+)\] Resolution\b/i', $release["textstring"], $result)) { |
|
1668
|
|
|
if ($result[1] == '640x.+') { |
|
1669
|
|
|
$result[1] = '480p'; |
|
1670
|
|
|
} else if ($result[1] == '1280x.+') { |
|
1671
|
|
|
$result[1] = '720p'; |
|
1672
|
|
|
} else if ($result[1] == '1920x.+') { |
|
1673
|
|
|
$result[1] = '1080p'; |
|
1674
|
|
|
} |
|
1675
|
|
|
$releasename = $releasename . "." . $result[1]; |
|
1676
|
|
|
} |
|
1677
|
|
|
$result = $releasename . ".IGUANA"; |
|
1678
|
|
|
$this->updateRelease($release, $result, $method = "nfoCheck: IGUANA", $echo, $type, $namestatus, $show); |
|
1679
|
|
|
} |
|
1680
|
|
|
} |
|
1681
|
|
|
} |
|
1682
|
|
|
|
|
1683
|
|
|
/** |
|
1684
|
|
|
* Just for filenames. |
|
1685
|
|
|
* |
|
1686
|
|
|
* @param $release |
|
1687
|
|
|
* @param boolean $echo |
|
1688
|
|
|
* @param string $type |
|
1689
|
|
|
* @param $namestatus |
|
1690
|
|
|
* @param $show |
|
1691
|
|
|
* |
|
1692
|
|
|
* @return bool |
|
1693
|
|
|
*/ |
|
1694
|
|
|
public function fileCheck($release, $echo, $type, $namestatus, $show) |
|
1695
|
|
|
{ |
|
1696
|
|
|
$result = []; |
|
1697
|
|
|
|
|
1698
|
|
|
if ($this->done === false && $this->relid !== $release["releases_id"]) { |
|
1699
|
|
|
switch (true) { |
|
|
|
|
|
|
1700
|
|
|
case preg_match('/^(.+?(x264|XviD)\-TVP)\\\\/i', $release["textstring"], $result): |
|
1701
|
|
|
$this->updateRelease($release, $result["1"], $method = "fileCheck: TVP", $echo, $type, $namestatus, $show); |
|
1702
|
|
|
break; |
|
1703
|
|
|
case preg_match('/^(\\\\|\/)?(.+(\\\\|\/))*(.+?S\d{1,3}[.-_ ]?[ED]\d{1,3}.+)\.(.+)$/i', $release["textstring"], $result): |
|
1704
|
|
|
$this->updateRelease($release, $result["4"], $method = "fileCheck: Generic TV", $echo, $type, $namestatus, $show); |
|
1705
|
|
|
break; |
|
1706
|
|
|
case preg_match('/^(\\\\|\/)?(.+(\\\\|\/))*(.+?([\.\-_ ]\d{4}[\.\-_ ].+?(BDRip|bluray|DVDRip|XVID)).+)\.(.+)$/i', $release["textstring"], $result): |
|
1707
|
|
|
$this->updateRelease($release, $result["4"], $method = "fileCheck: Generic movie 1", $echo, $type, $namestatus, $show); |
|
1708
|
|
|
break; |
|
1709
|
|
|
case preg_match('/^([a-z0-9\.\-_]+(19|20)\d\d[a-z0-9\.\-_]+[\.\-_ ](720p|1080p|BDRip|bluray|DVDRip|x264|XviD)[a-z0-9\.\-_]+)\.[a-z]{2,}$/i', $release["textstring"], $result): |
|
1710
|
|
|
$this->updateRelease($release, $result["1"], $method = "fileCheck: Generic movie 2", $echo, $type, $namestatus, $show); break; |
|
|
|
|
|
|
1711
|
|
|
case preg_match('/(.+?([\.\-_ ](CD|FM)|[\.\-_ ]\dCD|CDR|FLAC|SAT|WEB).+?(19|20)\d\d.+?)\\\\.+/i', $release["textstring"], $result): |
|
1712
|
|
|
$this->updateRelease($release, $result["1"], $method = "fileCheck: Generic music", $echo, $type, $namestatus, $show); |
|
1713
|
|
|
break; |
|
1714
|
|
|
case preg_match('/^(.+?(19|20)\d\d\-([a-z0-9]{3}|[a-z]{2,}|C4))\\\\/i', $release["textstring"], $result): |
|
1715
|
|
|
$this->updateRelease($release, $result["1"], $method = "fileCheck: music groups", $echo, $type, $namestatus, $show); |
|
1716
|
|
|
break; |
|
1717
|
|
View Code Duplication |
case preg_match('/.+\\\\(.+\((19|20)\d\d\)\.avi)/i', $release["textstring"], $result): |
|
|
|
|
|
|
1718
|
|
|
$newname = str_replace('.avi', ' DVDRip XVID NoGroup', $result["1"]); |
|
1719
|
|
|
$this->updateRelease($release, $newname, $method = "fileCheck: Movie (year) avi", $echo, $type, $namestatus, $show); |
|
1720
|
|
|
break; |
|
1721
|
|
View Code Duplication |
case preg_match('/.+\\\\(.+\((19|20)\d\d\)\.iso)/i', $release["textstring"], $result): |
|
|
|
|
|
|
1722
|
|
|
$newname = str_replace('.iso', ' DVD NoGroup', $result["1"]); |
|
1723
|
|
|
$this->updateRelease($release, $newname, $method = "fileCheck: Movie (year) iso", $echo, $type, $namestatus, $show); |
|
1724
|
|
|
break; |
|
1725
|
|
|
case preg_match('/^(.+?IMAGESET.+?)\\\\.+/i', $release["textstring"], $result): |
|
1726
|
|
|
$this->updateRelease($release, $result["1"], $method = "fileCheck: XXX Imagesets", $echo, $type, $namestatus, $show); |
|
1727
|
|
|
break; |
|
1728
|
|
View Code Duplication |
case preg_match('/^VIDEOOT-[A-Z0-9]+\\\\([\w!.,& ()\[\]\'\`-]{8,}?\b.?)([-_](proof|sample|thumbs?))*(\.part\d*(\.rar)?|\.rar|\.7z)?(\d{1,3}\.rev|\.vol.+?|\.mp4)/', $release["textstring"], $result): |
|
|
|
|
|
|
1729
|
|
|
$this->updateRelease($release, $result["1"] . " XXX DVDRIP XviD-VIDEOOT", $method = "fileCheck: XXX XviD VIDEOOT", $echo, $type, $namestatus, $show); |
|
1730
|
|
|
break; |
|
1731
|
|
|
case preg_match('/^.+?SDPORN/i', $release["textstring"], $result): |
|
1732
|
|
|
$this->updateRelease($release, $result["0"], $method = "fileCheck: XXX SDPORN", $echo, $type, $namestatus, $show); |
|
1733
|
|
|
break; |
|
1734
|
|
View Code Duplication |
case preg_match('/\w[-\w.\',;& ]+1080i[._ -]DD5[._ -]1[._ -]MPEG2-R&C(?=\.ts)/i', $release["textstring"], $result): |
|
|
|
|
|
|
1735
|
|
|
$result = str_replace("MPEG2", "MPEG2.HDTV", $result["0"]); |
|
1736
|
|
|
$this->updateRelease($release, $result, $method = "fileCheck: R&C", $echo, $type, $namestatus, $show); |
|
1737
|
|
|
break; |
|
1738
|
|
|
case preg_match('/\w[-\w.\',;& ]+((s\d{1,2}[._ -]?[bde]\d{1,2})|\d{1,2}x\d{2}|ep[._ -]?\d{2})[._ -](480|720|1080)[ip][._ -](BD(-?(25|50|RIP))?|Blu-?Ray ?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|[HPS]D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |S?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[._ -]nSD[._ -](DivX|[HX][._ -]?264|MPEG2|XviD(HD)?|WMV)[._ -]NhaNC3[-\w.\',;& ]+\w/i', $release["textstring"], $result): |
|
1739
|
|
|
$this->updateRelease($release, $result["0"], $method = "fileCheck: NhaNc3", $echo, $type, $namestatus, $show); |
|
1740
|
|
|
break; |
|
1741
|
|
|
case preg_match('/\wtvp-[\w.\-\',;]+((s\d{1,2}[._ -]?[bde]\d{1,2})|\d{1,2}x\d{2}|ep[._ -]?\d{2})[._ -](720p|1080p|xvid)(?=\.(avi|mkv))/i', $release["textstring"], $result): |
|
1742
|
|
|
$result = str_replace("720p", "720p.HDTV.X264", $result['0']); |
|
1743
|
|
|
$result = str_replace("1080p", "1080p.Bluray.X264", $result['0']); |
|
1744
|
|
|
$result = str_replace("xvid", "XVID.DVDrip", $result['0']); |
|
1745
|
|
|
$this->updateRelease($release, $result, $method = "fileCheck: tvp", $echo, $type, $namestatus, $show); |
|
1746
|
|
|
break; |
|
1747
|
|
|
case preg_match('/\w[-\w.\',;& ]+\d{3,4}\.hdtv-lol\.(avi|mp4|mkv|ts|nfo|nzb)/i', $release["textstring"], $result): |
|
1748
|
|
|
$this->updateRelease($release, $result["0"], $method = "fileCheck: Title.211.hdtv-lol.extension", $echo, $type, $namestatus, $show); |
|
1749
|
|
|
break; |
|
1750
|
|
|
case preg_match('/\w[-\w.\',;& ]+-S\d{1,2}[EX]\d{1,2}-XVID-DL.avi/i', $release["textstring"], $result): |
|
1751
|
|
|
$this->updateRelease($release, $result["0"], $method = "fileCheck: Title-SxxExx-XVID-DL.avi", $echo, $type, $namestatus, $show); |
|
1752
|
|
|
break; |
|
1753
|
|
|
case preg_match('/\S.*[\w.\-\',;]+\s\-\ss\d{2}[ex]\d{2}\s\-\s[\w.\-\',;].+\./i', $release["textstring"], $result): |
|
1754
|
|
|
$this->updateRelease($release, $result["0"], $method = "fileCheck: Title - SxxExx - Eptitle", $echo, $type, $namestatus, $show); |
|
1755
|
|
|
break; |
|
1756
|
|
|
case preg_match('/\w.+?\)\.nds/i', $release["textstring"], $result): |
|
1757
|
|
|
$this->updateRelease($release, $result["0"], $method = "fileCheck: ).nds Nintendo DS", $echo, $type, $namestatus, $show); |
|
1758
|
|
|
break; |
|
1759
|
|
View Code Duplication |
case preg_match('/3DS_\d{4}.+\d{4} - (.+?)\.3ds/i', $release["textstring"], $result): |
|
|
|
|
|
|
1760
|
|
|
$this->updateRelease($release, "3DS " . $result["1"], $method = "fileCheck: .3ds Nintendo 3DS", $echo, $type, $namestatus, $show); |
|
1761
|
|
|
break; |
|
1762
|
|
|
case preg_match('/\w.+?\.(epub|mobi|azw|opf|fb2|prc|djvu|cb[rz])/i', $release["textstring"], $result): |
|
1763
|
|
|
$result = str_replace("." . $result["1"], " (" . $result["1"] . ")", $result['0']); |
|
1764
|
|
|
$this->updateRelease($release, $result, $method = "fileCheck: EBook", $echo, $type, $namestatus, $show); |
|
1765
|
|
|
break; |
|
1766
|
|
|
default: |
|
1767
|
|
|
return false; |
|
1768
|
|
|
} |
|
1769
|
|
|
return true; |
|
1770
|
|
|
} |
|
1771
|
|
|
return false; |
|
1772
|
|
|
} |
|
1773
|
|
|
|
|
1774
|
|
|
/** |
|
1775
|
|
|
* Look for a name based on mediainfo xml Unique_ID. |
|
1776
|
|
|
* |
|
1777
|
|
|
* @param array $release The release to be matched |
|
1778
|
|
|
* @param boolean $echo Should we show CLI output |
|
1779
|
|
|
* @param string $type The rename type |
|
1780
|
|
|
* @param int $namestatus Should we rename the release if match is found |
|
1781
|
|
|
* @param int $show Should we show the rename results |
|
1782
|
|
|
* |
|
1783
|
|
|
* @return bool Whether or not we matched the release |
|
1784
|
|
|
*/ |
|
1785
|
|
|
public function uidCheck($release, $echo, $type, $namestatus, $show) |
|
1786
|
|
|
{ |
|
1787
|
|
|
if ($this->done === false && $this->relid !== $release["releases_id"]) { |
|
1788
|
|
|
$result = $this->pdo->queryDirect(" |
|
|
|
|
|
|
1789
|
|
|
SELECT r.id AS releases_id, r.size AS relsize, r.name AS textstring, r.searchname, r.fromname, r.predb_id |
|
1790
|
|
|
FROM release_unique ru |
|
1791
|
|
|
STRAIGHT_JOIN releases r ON ru.releases_id = r.id |
|
1792
|
|
|
WHERE ru.uniqueid = UNHEX({$this->pdo->escapeString($release['uid'])}) |
|
1793
|
|
|
AND ru.releases_id != {$release['releases_id']} |
|
1794
|
|
|
AND (r.predb_id > 0 OR r.anidbid > 0)" |
|
1795
|
|
|
); |
|
1796
|
|
|
|
|
1797
|
|
|
if ($result instanceof \Traversable) { |
|
1798
|
|
|
foreach ($result AS $res) { |
|
1799
|
|
|
$floor = round(($res['relsize'] - $release['relsize']) / $res['relsize'] * 100, 1); |
|
1800
|
|
|
if ($floor >= -5 && $floor <= 5) { |
|
1801
|
|
|
$this->updateRelease( |
|
1802
|
|
|
$release, |
|
1803
|
|
|
$res['searchname'], |
|
1804
|
|
|
$method = "uidCheck: Unique_ID", |
|
1805
|
|
|
$echo, |
|
1806
|
|
|
$type, |
|
1807
|
|
|
$namestatus, |
|
1808
|
|
|
$show, |
|
1809
|
|
|
$res['predb_id'] |
|
1810
|
|
|
); |
|
1811
|
|
|
return true; |
|
1812
|
|
|
} |
|
1813
|
|
|
} |
|
1814
|
|
|
} |
|
1815
|
|
|
} |
|
1816
|
|
|
$this->_updateSingleColumn('proc_uid', self::PROC_UID_DONE, $release['releases_id']); |
|
1817
|
|
|
return false; |
|
1818
|
|
|
} |
|
1819
|
|
|
|
|
1820
|
|
|
/** |
|
1821
|
|
|
* Look for a name based on xxx release filename. |
|
1822
|
|
|
* |
|
1823
|
|
|
* @param array $release The release to be matched |
|
1824
|
|
|
* @param boolean $echo Should we show CLI output |
|
1825
|
|
|
* @param string $type The rename type |
|
1826
|
|
|
* @param int $namestatus Should we rename the release if match is found |
|
1827
|
|
|
* @param int $show Should we show the rename results |
|
1828
|
|
|
* |
|
1829
|
|
|
* @return bool Whether or not we matched the release |
|
1830
|
|
|
*/ |
|
1831
|
|
View Code Duplication |
public function xxxNameCheck($release, $echo, $type, $namestatus, $show) |
|
|
|
|
|
|
1832
|
|
|
{ |
|
1833
|
|
|
if ($this->done === false && $this->relid !== $release["releases_id"]) { |
|
1834
|
|
|
$result = $this->pdo->queryDirect(" |
|
1835
|
|
|
SELECT rf.name AS textstring, rel.categories_id, rel.name, rel.searchname, rel.fromname, rel.groups_id, |
|
1836
|
|
|
rf.releases_id AS fileid, rel.id AS releases_id |
|
1837
|
|
|
FROM releases rel |
|
1838
|
|
|
INNER JOIN release_files rf ON (rf.releases_id = rel.id) |
|
1839
|
|
|
WHERE (rel.isrenamed = %d OR rel.categories_id IN(%d, %d)) |
|
1840
|
|
|
AND rf.name %s", |
|
1841
|
|
|
self::IS_RENAMED_NONE, |
|
|
|
|
|
|
1842
|
|
|
Category::OTHER_MISC, |
|
|
|
|
|
|
1843
|
|
|
Category::OTHER_HASHED, |
|
1844
|
|
|
$this->pdo->likeString('SDPORN', true, true) |
|
1845
|
|
|
); |
|
1846
|
|
|
|
|
1847
|
|
|
if ($result instanceof \Traversable) { |
|
1848
|
|
|
foreach ($result AS $res) { |
|
1849
|
|
|
if (preg_match('/^.+?SDPORN/i', $res["textstring"], $match)) { |
|
1850
|
|
|
$this->updateRelease( |
|
1851
|
|
|
$release, |
|
1852
|
|
|
$match["0"], |
|
1853
|
|
|
$method = "fileCheck: XXX SDPORN", |
|
1854
|
|
|
$echo, |
|
1855
|
|
|
$type, |
|
1856
|
|
|
$namestatus, |
|
1857
|
|
|
$show |
|
1858
|
|
|
); |
|
1859
|
|
|
return true; |
|
1860
|
|
|
} |
|
1861
|
|
|
} |
|
1862
|
|
|
} |
|
1863
|
|
|
} |
|
1864
|
|
|
$this->_updateSingleColumn('proc_files', self::PROC_FILES_DONE, $release['releases_id']); |
|
1865
|
|
|
return false; |
|
1866
|
|
|
} |
|
1867
|
|
|
|
|
1868
|
|
|
/** |
|
1869
|
|
|
* Look for a name based on .srr release files extension. |
|
1870
|
|
|
* |
|
1871
|
|
|
* @param array $release The release to be matched |
|
1872
|
|
|
* @param boolean $echo Should we show CLI output |
|
1873
|
|
|
* @param string $type The rename type |
|
1874
|
|
|
* @param int $namestatus Should we rename the release if match is found |
|
1875
|
|
|
* @param int $show Should we show the rename results |
|
1876
|
|
|
* |
|
1877
|
|
|
* @return bool Whether or not we matched the release |
|
1878
|
|
|
*/ |
|
1879
|
|
View Code Duplication |
public function srrNameCheck($release, $echo, $type, $namestatus, $show) |
|
|
|
|
|
|
1880
|
|
|
{ |
|
1881
|
|
|
if ($this->done === false && $this->relid !== $release["releases_id"]) { |
|
1882
|
|
|
$result = $this->pdo->queryDirect(" |
|
1883
|
|
|
SELECT rf.name AS textstring, rel.categories_id, rel.name, rel.searchname, rel.fromname, rel.groups_id, |
|
1884
|
|
|
rf.releases_id AS fileid, rel.id AS releases_id |
|
1885
|
|
|
FROM releases rel |
|
1886
|
|
|
INNER JOIN release_files rf ON (rf.releases_id = rel.id) |
|
1887
|
|
|
WHERE (rel.isrenamed = %d OR rel.categories_id IN (%d, %d)) |
|
1888
|
|
|
AND rf.name %s", |
|
1889
|
|
|
self::IS_RENAMED_NONE, |
|
|
|
|
|
|
1890
|
|
|
Category::OTHER_MISC, |
|
|
|
|
|
|
1891
|
|
|
Category::OTHER_HASHED, |
|
1892
|
|
|
$this->pdo->likeString('.srr', true, false) |
|
1893
|
|
|
); |
|
1894
|
|
|
|
|
1895
|
|
|
if ($result instanceof \Traversable) { |
|
1896
|
|
|
foreach ($result AS $res) { |
|
1897
|
|
|
if (preg_match('/^(.+?)\.srr/i', $res["textstring"], $match)) { |
|
1898
|
|
|
$this->updateRelease( |
|
1899
|
|
|
$release, |
|
1900
|
|
|
$match["1"], |
|
1901
|
|
|
$method = "fileCheck: SRR extension", |
|
1902
|
|
|
$echo, |
|
1903
|
|
|
$type, |
|
1904
|
|
|
$namestatus, |
|
1905
|
|
|
$show |
|
1906
|
|
|
); |
|
1907
|
|
|
return true; |
|
1908
|
|
|
} |
|
1909
|
|
|
} |
|
1910
|
|
|
} |
|
1911
|
|
|
} |
|
1912
|
|
|
$this->_updateSingleColumn('proc_files', self::PROC_FILES_DONE, $release['releases_id']); |
|
1913
|
|
|
return false; |
|
1914
|
|
|
} |
|
1915
|
|
|
|
|
1916
|
|
|
/** |
|
1917
|
|
|
* Resets NameFixer status variables for new processing |
|
1918
|
|
|
*/ |
|
1919
|
|
|
public function reset() |
|
1920
|
|
|
{ |
|
1921
|
|
|
$this->done = $this->matched = false; |
|
1922
|
|
|
} |
|
1923
|
|
|
} |
|
1924
|
|
|
|
This check marks property names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString.