mirror of
https://github.com/YGGverse/YGGo.git
synced 2025-01-08 22:07:56 +00:00
fix image description duplicate
This commit is contained in:
parent
1c7cca1446
commit
2c5ca1b630
@ -336,7 +336,9 @@ try {
|
|||||||
if ($lastHostImageDescription = $db->getLastHostImageDescription($queueHostImage->hostImageId)) {
|
if ($lastHostImageDescription = $db->getLastHostImageDescription($queueHostImage->hostImageId)) {
|
||||||
|
|
||||||
$db->setHostImageDescription($queueHostImage->hostImageId,
|
$db->setHostImageDescription($queueHostImage->hostImageId,
|
||||||
crc32($hostImageData),
|
crc32($lastHostImageDescription->alt .
|
||||||
|
$lastHostImageDescription->title .
|
||||||
|
$hostImageData),
|
||||||
$lastHostImageDescription->alt,
|
$lastHostImageDescription->alt,
|
||||||
$lastHostImageDescription->title,
|
$lastHostImageDescription->title,
|
||||||
$hostImageData,
|
$hostImageData,
|
||||||
@ -618,10 +620,13 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add/update host image description
|
// Add/update host image description
|
||||||
|
$imageAlt = Filter::imageAlt($imageAlt);
|
||||||
|
$imageTitle = Filter::imageTitle($imageTitle);
|
||||||
|
|
||||||
$db->setHostImageDescription($hostImageId,
|
$db->setHostImageDescription($hostImageId,
|
||||||
null, // no data, download it in the crawler queue
|
crc32($imageAlt . $imageTitle),
|
||||||
Filter::imageAlt($imageAlt),
|
$imageAlt,
|
||||||
Filter::imageTitle($imageTitle),
|
$imageTitle,
|
||||||
null,
|
null,
|
||||||
time());
|
time());
|
||||||
|
|
||||||
|
Binary file not shown.
@ -259,14 +259,14 @@ class MySQL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function setHostImageDescription(int $hostImageId,
|
public function setHostImageDescription(int $hostImageId,
|
||||||
mixed $crc32data,
|
int $crc32id,
|
||||||
string $alt,
|
string $alt,
|
||||||
string $title,
|
string $title,
|
||||||
mixed $data,
|
mixed $data,
|
||||||
int $time) {
|
int $time) {
|
||||||
|
|
||||||
$query = $this->_db->prepare('INSERT INTO `hostImageDescription` (`hostImageId`,
|
$query = $this->_db->prepare('INSERT INTO `hostImageDescription` (`hostImageId`,
|
||||||
`crc32data`,
|
`crc32id`,
|
||||||
`alt`,
|
`alt`,
|
||||||
`title`,
|
`title`,
|
||||||
`timeAdded`) VALUES (?, ?, ?, ?, ?)
|
`timeAdded`) VALUES (?, ?, ?, ?, ?)
|
||||||
@ -275,24 +275,24 @@ class MySQL {
|
|||||||
`title` = ?,
|
`title` = ?,
|
||||||
`timeUpdated` = ?');
|
`timeUpdated` = ?');
|
||||||
|
|
||||||
$query->execute([$hostImageId, $crc32data, $alt, $title, $time, $alt, $title, $time]);
|
$query->execute([$hostImageId, $crc32id, $alt, $title, $time, $alt, $title, $time]);
|
||||||
|
|
||||||
return $this->_db->lastInsertId();
|
return $this->_db->lastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setHostImageDescriptionData(int $hostImageId,
|
public function setHostImageDescriptionData(int $hostImageId,
|
||||||
mixed $crc32data,
|
int $crc32id,
|
||||||
mixed $data,
|
mixed $data,
|
||||||
int $time) {
|
int $time) {
|
||||||
|
|
||||||
$query = $this->_db->prepare('INSERT INTO `hostImageDescription` (`hostImageId`,
|
$query = $this->_db->prepare('INSERT INTO `hostImageDescription` (`hostImageId`,
|
||||||
`crc32data`,
|
`crc32id`,
|
||||||
`data`,
|
`data`,
|
||||||
`timeAdded`) VALUES (?, ?, ?, ?)
|
`timeAdded`) VALUES (?, ?, ?, ?)
|
||||||
|
|
||||||
ON DUPLICATE KEY UPDATE `timeUpdated` = ?');
|
ON DUPLICATE KEY UPDATE `timeUpdated` = ?');
|
||||||
|
|
||||||
$query->execute([$hostImageId, $crc32data, $data, $time, $time]);
|
$query->execute([$hostImageId, $crc32id, $data, $time, $time]);
|
||||||
|
|
||||||
return $this->_db->lastInsertId();
|
return $this->_db->lastInsertId();
|
||||||
}
|
}
|
||||||
|
@ -346,7 +346,7 @@ if (!empty($q)) {
|
|||||||
$hostImage->uri;
|
$hostImage->uri;
|
||||||
|
|
||||||
// Get local image data
|
// Get local image data
|
||||||
if ($lastHostImageDescription = $db->getLastHostImageDescription($hostImage->hostImageId)) {
|
if ($lastHostImageDescription = $db->getLastHostImageDescription($result->id)) {
|
||||||
|
|
||||||
$hostImageURLencoded = $lastHostImageDescription->data;
|
$hostImageURLencoded = $lastHostImageDescription->data;
|
||||||
|
|
||||||
@ -359,13 +359,13 @@ if (!empty($q)) {
|
|||||||
// Skip item render on timeout
|
// Skip item render on timeout
|
||||||
$hostImageHttpCode = $hostImageCurl->getCode();
|
$hostImageHttpCode = $hostImageCurl->getCode();
|
||||||
|
|
||||||
$db->updateHostImageHttpCode($hostImage->hostImageId, (int) $hostImageHttpCode, time());
|
$db->updateHostImageHttpCode($result->id, (int) $hostImageHttpCode, time());
|
||||||
|
|
||||||
if (200 != $hostImageHttpCode) {
|
if (200 != $hostImageHttpCode) {
|
||||||
|
|
||||||
$db->updateHostImageHttpCode($hostImage->hostImageId, $hostImageHttpCode, time());
|
$db->updateHostImageHttpCode($result->id, $hostImageHttpCode, time());
|
||||||
|
|
||||||
$db->updateHostImageTimeBanned($hostImage->hostImageId, time());
|
$db->updateHostImageTimeBanned($result->id, time());
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -373,7 +373,7 @@ if (!empty($q)) {
|
|||||||
// Skip image processing on MIME type not provided
|
// Skip image processing on MIME type not provided
|
||||||
if (!$hostImageContentType = $hostImageCurl->getContentType()) {
|
if (!$hostImageContentType = $hostImageCurl->getContentType()) {
|
||||||
|
|
||||||
$db->updateHostImageTimeBanned($hostImage->hostImageId, time());
|
$db->updateHostImageTimeBanned($result->id, time());
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -391,9 +391,9 @@ if (!empty($q)) {
|
|||||||
|
|
||||||
if ($hostImageBanned) {
|
if ($hostImageBanned) {
|
||||||
|
|
||||||
$db->updateHostImageMime($hostImage->hostImageId, $hostImageContentType, time());
|
$db->updateHostImageMime($result->id, $hostImageContentType, time());
|
||||||
|
|
||||||
$hostImagesBanned += $db->updateHostImageTimeBanned($hostImage->hostImageId, time());
|
$hostImagesBanned += $db->updateHostImageTimeBanned($result->id, time());
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -401,7 +401,7 @@ if (!empty($q)) {
|
|||||||
// Skip image processing without returned content
|
// Skip image processing without returned content
|
||||||
if (!$hostImageContent = $hostImageCurl->getContent()) {
|
if (!$hostImageContent = $hostImageCurl->getContent()) {
|
||||||
|
|
||||||
$db->updateHostImageTimeBanned($hostImage->hostImageId, time());
|
$db->updateHostImageTimeBanned($result->id, time());
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -409,14 +409,14 @@ if (!empty($q)) {
|
|||||||
// Convert remote image data to base64 string to prevent direct URL call
|
// Convert remote image data to base64 string to prevent direct URL call
|
||||||
if (!$hostImageExtension = @pathinfo($hostImageURL, PATHINFO_EXTENSION)) {
|
if (!$hostImageExtension = @pathinfo($hostImageURL, PATHINFO_EXTENSION)) {
|
||||||
|
|
||||||
$db->updateHostImageTimeBanned($hostImage->hostImageId, time());
|
$db->updateHostImageTimeBanned($result->id, time());
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$hostImageBase64 = @base64_encode($hostImageContent)) {
|
if (!$hostImageBase64 = @base64_encode($hostImageContent)) {
|
||||||
|
|
||||||
$db->updateHostImageTimeBanned($hostImage->hostImageId, time());
|
$db->updateHostImageTimeBanned($result->id, time());
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -424,11 +424,11 @@ if (!empty($q)) {
|
|||||||
$hostImageURLencoded = 'data:image/' . str_replace(['svg'], ['svg+xml'], $hostImageExtension) . ';base64,' . $hostImageBase64;
|
$hostImageURLencoded = 'data:image/' . str_replace(['svg'], ['svg+xml'], $hostImageExtension) . ';base64,' . $hostImageBase64;
|
||||||
|
|
||||||
// Save image content on data settings enabled
|
// Save image content on data settings enabled
|
||||||
$db->updateHostImage($hostImage->hostImageId,
|
$db->updateHostImage($result->id,
|
||||||
Filter::mime($hostImageContentType),
|
Filter::mime($hostImageContentType),
|
||||||
time());
|
time());
|
||||||
|
|
||||||
$db->setHostImageDescriptionData($hostImage->hostImageId,
|
$db->setHostImageDescriptionData($result->id,
|
||||||
crc32($hostImageURLencoded),
|
crc32($hostImageURLencoded),
|
||||||
$hostImage->crawlMetaOnly ? null : $hostImageURLencoded,
|
$hostImage->crawlMetaOnly ? null : $hostImageURLencoded,
|
||||||
time());
|
time());
|
||||||
|
Loading…
Reference in New Issue
Block a user