fix(videoGpt1): normalize seo pages and fallback services

This commit is contained in:
root
2026-04-17 13:02:00 +08:00
parent dd3cbf09cc
commit 56644e7f50
19 changed files with 253 additions and 173 deletions

View File

@@ -909,6 +909,12 @@ class SiteContext
protected function normalizeSeoKeywords(string $strValue): string
{
$strSanitized = @iconv('UTF-8', 'UTF-8//IGNORE', $strValue);
if ($strSanitized !== false) {
$strValue = $strSanitized;
}
$strValue = str_replace("\u{FFFD}", '', $strValue);
$strValue = preg_replace('/排<>+/u', '排行', $strValue) ?? $strValue;
$strValue = str_replace(['', '、', ';', '', '|', ''], ',', $strValue);
$arrRawParts = preg_split('/\s*,\s*/u', $strValue) ?: [];
$arrNoiseSuffixes = [
@@ -933,6 +939,7 @@ class SiteContext
'疗愈力',
'英雄塑造',
'人性挖掘',
'隐喻意义',
];
$arrStopWords = [
'在线',
@@ -970,6 +977,10 @@ class SiteContext
}
$strPart = trim($strPart, " \t\n\r\0\x0B-_|,。;、,;");
$strPart = preg_replace('/排<>+/u', '排行', $strPart) ?? $strPart;
if (preg_match('/榜排$/u', $strPart) || preg_match('/视频排$/u', $strPart)) {
$strPart .= '行';
}
if (in_array($strPart, $arrStopWords, true)) {
continue;
@@ -994,6 +1005,14 @@ class SiteContext
return '';
}
$strSanitized = @iconv('UTF-8', 'UTF-8//IGNORE', $strValue);
if ($strSanitized !== false) {
$strValue = $strSanitized;
}
$strValue = str_replace("\u{FFFD}", '', $strValue);
$strValue = preg_replace('/排<>+/u', '排行', $strValue) ?? $strValue;
$strSiteName = trim((string)($this->DomainModel->d_name ?? ''));
$strSiteKeywords = trim((string)(ConverterMovel::getVal('strSiteKeywords') ?? ''));
$strVideoName = trim((string)(ConverterMovel::getVal('strVideoName') ?? ''));
@@ -1019,6 +1038,9 @@ class SiteContext
'的叙事模型',
'的英雄之旅',
'的成长母题',
'的精神内核',
'的文化符号',
'的隐喻意义',
];
$strValue = str_replace($arrNoisePhrases, '', $strValue);
@@ -1044,6 +1066,18 @@ class SiteContext
$boolDescriptionLooksWeak = true;
}
if (preg_match('/精神内核|文化符号|隐喻意义|叙事模型|英雄之旅|成长母题/u', $strValue)) {
$boolDescriptionLooksWeak = true;
}
if ($strPage === 'play' && preg_match('/解析/u', $strValue)) {
$boolDescriptionLooksWeak = true;
}
if ($strPage === 'play' && mb_strlen($strValue) > 80) {
$boolDescriptionLooksWeak = true;
}
if ($boolDescriptionLooksWeak) {
return $this->buildSeoDescriptionFallback($strPage, $strSiteName, $strVideoName, $strVideoCategoryName);
}

View File

@@ -376,6 +376,21 @@ class VideoService
$arrFilter['v_parent_category_en'],
);
if (empty($arrVideo) || !is_array($arrVideo)) {
$arrVideo = $this->getVideoList([
'count' => $intCount,
'v_category_en' => $arrFilter['v_category_en'] ?? 'all',
'v_parent_category_en' => $arrFilter['v_parent_category_en'] ?? 'all',
'v_lang_en' => 'all',
'v_area_en' => 'all',
'v_year' => 'all',
'sort_type' => 'news',
'v_status' => $strVStatus,
'diff_key' => $strDiffKey !== '' ? $strDiffKey . ':rank_fallback' : 'rank_fallback',
'cache_life' => $intCacheLifeTime,
]);
}
return $arrVideo;
}
@@ -1180,11 +1195,9 @@ class VideoService
$arrPageKeys = $this->buildSeoCopyPageKeys($strScene, $arrOptions);
if ($this->shouldSuppressDefaultOnlySeoCopy($strScene, $strHost, $arrPageKeys)) {
return [];
}
$boolSuppressDefaultOnlySeoCopy = $this->shouldSuppressDefaultOnlySeoCopy($strScene, $strHost, $arrPageKeys);
$arrData = !empty($arrPageKeys)
$arrData = (!$boolSuppressDefaultOnlySeoCopy && !empty($arrPageKeys))
? SeoCopyStore::getPreferredPageData($strHost, $strScene, $arrPageKeys)
: [];