restore gpt seo copy pipeline and stabilize seo tkd output

This commit is contained in:
root
2026-04-16 22:45:00 +08:00
parent 09b2137fa6
commit 2a905bbf0f
18 changed files with 3587 additions and 85 deletions

View File

@@ -11,7 +11,7 @@ class Video extends TagLib
'listexp' => ['attr' => 'count,v_category_en,v_parent_category_en,sort_type,v_status,v_sex,diff_key,cache_life,d_key,d_val,export_name', 'close' => 0],
'pager' => ['attr' => 'page,limit,v_category_en,v_parent_category_en,sort_type,v_status,v_sex,key,diff_key,cache_life,d_key,d_val,p_val,func,export_name', 'close' => 1],
'pagerexp' => ['attr' => 'page,limit,v_class,v_category_en,v_parent_category_en,sort_type,v_status,v_sex,key,diff_key,cache_life,d_key,d_val,p_val,func,export_name', 'close' => 0],
'info' => ['attr' => 'v_id,v_forge_id,v_key', 'close' => 0],
'info' => ['attr' => 'v_id,v_forge_id,v_key,v_pinyin', 'close' => 0],
'sort' => ['attr' => 'd_key,d_val'],
'ranksort' => ['attr' => 'd_key,d_val'],
'status' => ['attr' => 'd_key,d_val'],
@@ -29,6 +29,7 @@ class Video extends TagLib
'imgalt' => ['attr' => 'video,tp_style,slot,item_type,export_name', 'close' => 0],
'seoaddon' => ['attr' => 'video,tp_style,export_name', 'close' => 0],
'seocopy' => ['attr' => 'scene,video,parent_category,category,keyword,sort_type,page,total,pages,visible,play_type,play_index,export_name', 'close' => 0],
];
@@ -132,6 +133,72 @@ EOD;
return $strParse;
}
/**
* 页面补料块(优先 seo_copy缺失走 fallback
*
* 用法:
* {video:seocopy scene="home" export_name="seoCopy" /}
* {video:seocopy scene="detail" video="$arrVideo" export_name="seoCopy" /}
*/
public function tagSeoCopy($tag)
{
$strScene = $this->customBuildVar($tag['scene'] ?? 'home');
$strVideo = $this->customBuildVar($tag['video'] ?? '[]');
$strParentCategory = $this->customBuildVar($tag['parent_category'] ?? '');
$strCategory = $this->customBuildVar($tag['category'] ?? '');
$strKeyword = $this->customBuildVar($tag['keyword'] ?? '');
$strSortType = $this->customBuildVar($tag['sort_type'] ?? '');
$intPage = $this->customBuildVar($tag['page'] ?? 1);
$intTotal = $this->customBuildVar($tag['total'] ?? 0);
$intPages = $this->customBuildVar($tag['pages'] ?? 1);
$intVisible = $this->customBuildVar($tag['visible'] ?? 0);
$strPlayType = $this->customBuildVar($tag['play_type'] ?? '');
$intPlayIndex = $this->customBuildVar($tag['play_index'] ?? 1);
$export_name = $tag['export_name'] ?? '';
$strDataName = randomString(8);
if (!empty($export_name) && !preg_match('/^[A-Za-z_]\w*$/', $export_name)) {
$export_name = '';
}
$strParse = <<<EOD
<?php
\${$strDataName} = app(\\app\\services\\VideoService::class)->getSeoCopyBlock({$strScene}, [
'video' => {$strVideo},
'parent_category' => {$strParentCategory},
'category' => {$strCategory},
'keyword' => {$strKeyword},
'sort_type' => {$strSortType},
'page' => {$intPage},
'total' => {$intTotal},
'pages' => {$intPages},
'visible' => {$intVisible},
'play_type' => {$strPlayType},
'play_index' => {$intPlayIndex},
'pager_data' => [
'page' => {$intPage},
'total' => {$intTotal},
'pages' => {$intPages},
],
]);
EOD;
if (empty($export_name)) {
$strParse .= <<<EOD
echo json_encode(\${$strDataName}, JSON_UNESCAPED_UNICODE);
?>
EOD;
} else {
$strParse .= <<<EOD
\${$export_name} = \${$strDataName};
?>
EOD;
}
return $strParse;
}
/**
* tagRankListExp
@@ -439,16 +506,20 @@ EOT;
$v_key = $tag['v_key'] ?? 'arrVideo';
$v_pinyin = $tag['v_pinyin'] ?? '';
$v_id = $this->customBuildVar($v_id);
$v_fid = $this->customBuildVar($v_fid);
$v_pinyin = $this->customBuildVar($v_pinyin);
$arrDataName = randomString(5);
$strParse = <<<EOT
<?php
\${$arrDataName} = app(\\app\\services\\VideoService::class)->getVideoByVId(
\${$arrDataName} = app(\\app\\services\\VideoService::class)->getVideoByRouteContext(
{$v_id},
{$v_fid}
{$v_fid},
{$v_pinyin}
);
\${$v_key} = \${$arrDataName} ?? [];