Enable IYUU PTGen v2.0.0

Signed-off-by: Qi HU <github@spcsky.com>
This commit is contained in:
Qi HU
2025-12-18 13:35:05 +08:00
parent 0307cb3e78
commit b921beffd7
+14 -2
View File
@@ -350,9 +350,17 @@ HTML;
public function isIyuu(array $bodyArr): bool public function isIyuu(array $bodyArr): bool
{ {
$version = (string)($bodyArr['version'] ?? '');
switch ($version) {
case '2.0.0':
return isset($bodyArr['ret'])
&& intval($bodyArr['ret']) === 200
&& isset($bodyArr['data']['format'])
&& is_string($bodyArr['data']['format'])
&& $bodyArr['data']['format'] !== '';
default:
return false; return false;
//Not support, due to change frequently }
// return isset($bodyArr['ret']) && $bodyArr['ret'] == 200;
} }
public function listRatings(array $ptGenData, string $imdbLink, string $desc = ''): array public function listRatings(array $ptGenData, string $imdbLink, string $desc = ''): array
@@ -574,6 +582,10 @@ HTML;
do_log("$log, site: $site can not be updated: " . $exception->getMessage(), 'error'); do_log("$log, site: $site can not be updated: " . $exception->getMessage(), 'error');
} }
} }
if (empty($ptGenInfo)) {
do_log("$log, no pt gen info updated");
return false;
}
$siteIdAndRating = $this->listRatings($ptGenInfo, $torrent->url, $extra->descr); $siteIdAndRating = $this->listRatings($ptGenInfo, $torrent->url, $extra->descr);
foreach ($siteIdAndRating as $key => $value) { foreach ($siteIdAndRating as $key => $value) {
if (!isset($ptGenInfo[$key]['data']) || !is_array($ptGenInfo[$key]['data'])) { if (!isset($ptGenInfo[$key]['data']) || !is_array($ptGenInfo[$key]['data'])) {