feat: add metadata workbench and shared seo rules

This commit is contained in:
root
2026-04-18 20:23:30 +08:00
parent 2ea87050a5
commit cec1fdbc69
44 changed files with 5488 additions and 68 deletions

View File

@@ -219,6 +219,16 @@ class VideoInfoPage extends BasePage
'v_play_url' => $sortedPlayUrl,
];
$arrMetadataBackfill = $this->getVideoModel()->buildEmptyMetadataBackfillSet(
$arrExistsVideo,
$arrPageVideo,
'douban_crawler'
);
if (!empty($arrMetadataBackfill)) {
$arrUpdate = array_merge($arrUpdate, $arrMetadataBackfill);
}
$this->getVideoModel()->updateOne(
['v_name' => $arrPageVideo['v_name']],
['$set' => $arrUpdate]

View File

@@ -246,6 +246,16 @@ class VideoInfoPage extends BasePage
'v_play_url' => $sortedPlayUrl,
];
$arrMetadataBackfill = $this->getVideoModel()->buildEmptyMetadataBackfillSet(
$arrExistsVideo,
$arrPageVideo,
'fengchao_crawler'
);
if (!empty($arrMetadataBackfill)) {
$arrUpdate = array_merge($arrUpdate, $arrMetadataBackfill);
}
$this->getVideoModel()->updateOne(
['v_name' => $arrPageVideo['v_name']],
['$set' => $arrUpdate]

View File

@@ -233,6 +233,16 @@ class VideoInfoPage extends BasePage
'v_name_en' => zhToPinYin($arrPageVideo['v_name']),
];
$arrMetadataBackfill = $this->getVideoModel()->buildEmptyMetadataBackfillSet(
$arrExistsVideo,
$arrPageVideo,
'maotai_crawler'
);
if (!empty($arrMetadataBackfill)) {
$arrUpdate = array_merge($arrUpdate, $arrMetadataBackfill);
}
$this->getVideoModel()->updateOne(
['v_name' => $arrPageVideo['v_name']],
['$set' => $arrUpdate]

View File

@@ -252,6 +252,16 @@ class VideoInfoPage extends BasePage
'v_play_url' => $sortedPlayUrl,
];
$arrMetadataBackfill = $this->getVideoModel()->buildEmptyMetadataBackfillSet(
$arrExistsVideo,
$arrPageVideo,
'wuxian_crawler'
);
if (!empty($arrMetadataBackfill)) {
$arrUpdate = array_merge($arrUpdate, $arrMetadataBackfill);
}
$this->getVideoModel()->updateOne(
['v_name' => $arrPageVideo['v_name']],
['$set' => $arrUpdate]

View File

@@ -169,6 +169,10 @@ class VideoCategory
'name' => '体育',
'pinyin' => 'ti-yu',
],
95 => [
'name' => '短剧大全',
'pinyin' => 'duan-ju-da-quan',
],
];
static public $arrParent = [
@@ -212,5 +216,6 @@ class VideoCategory
19 => 19,
83 => 83,
94 => 94,
95 => 83,
];
}

View File

@@ -127,7 +127,8 @@ class VideoInfoPage extends BasePage
}
$arrPlayUrl = $cleanPlayUrl;
$arrVideo['type_id_1'] = VideoCategory::$arrParent[$arrVideo['type_id']];
$arrVideo['type_id'] = (int)($arrVideo['type_id'] ?? 0);
$arrVideo['type_id_1'] = VideoCategory::$arrParent[$arrVideo['type_id']] ?? $arrVideo['type_id'];
$arrVideo['vod_actor'] = trim($arrVideo['vod_actor']);
$arrVideo['vod_director'] = trim($arrVideo['vod_director']);
@@ -159,10 +160,16 @@ class VideoInfoPage extends BasePage
$arrVideo['vod_content'] = mb_rtrim($arrVideo['vod_content'], '\ ');
$arrVideo['vod_content'] = ensureUtf8($arrVideo['vod_content']);
$arrVideo['v_category'] = VideoCategory::$arrCategory[$arrVideo['type_id']]['name'];
$arrVideo['v_category_en'] = VideoCategory::$arrCategory[$arrVideo['type_id']]['pinyin'];
$arrVideo['v_parent_category'] = VideoCategory::$arrCategory[$arrVideo['type_id_1']]['name'];
$arrVideo['v_parent_category_en'] = VideoCategory::$arrCategory[$arrVideo['type_id_1']]['pinyin'];
$arrCurrentCategory = VideoCategory::$arrCategory[$arrVideo['type_id']] ?? VideoCategory::$arrCategory[$arrVideo['type_id_1']] ?? [
'name' => '短剧大全',
'pinyin' => 'duan-ju-da-quan',
];
$arrParentCategory = VideoCategory::$arrCategory[$arrVideo['type_id_1']] ?? $arrCurrentCategory;
$arrVideo['v_category'] = $arrCurrentCategory['name'];
$arrVideo['v_category_en'] = $arrCurrentCategory['pinyin'];
$arrVideo['v_parent_category'] = $arrParentCategory['name'];
$arrVideo['v_parent_category_en'] = $arrParentCategory['pinyin'];
foreach ($arrVideo as $strKey => $mixedVal) {
$strKey = str_replace('vod', 'v', $strKey);
@@ -249,6 +256,16 @@ class VideoInfoPage extends BasePage
'v_play_url' => $sortedPlayUrl,
];
$arrMetadataBackfill = $this->getVideoModel()->buildEmptyMetadataBackfillSet(
$arrExistsVideo,
$arrPageVideo,
'youzhi_crawler'
);
if (!empty($arrMetadataBackfill)) {
$arrUpdate = array_merge($arrUpdate, $arrMetadataBackfill);
}
$this->getVideoModel()->updateOne(
['v_name' => $arrPageVideo['v_name']],
['$set' => $arrUpdate]

View File

@@ -88,7 +88,7 @@ class VideoSiteMapLogic
*/
public function getDomain(): array
{
if (empty($this->arrDomain)) {
if (empty($this->arrDomainModel)) {
$this->arrDomainModel = DomainModel::getAllDomainOnCache();
}
return $this->arrDomainModel;
@@ -100,8 +100,26 @@ class VideoSiteMapLogic
*
* @return void
*/
public function generateSiteMap()
public function generateSiteMap(array $arrTaskData = [])
{
$arrDomains = array_values(array_unique(array_filter(array_map(
static fn($mValue): string => DomainModel::normalizeStoredDomain((string)$mValue),
(array)($arrTaskData['domains'] ?? [])
))));
if (!empty($arrDomains)) {
$arrAllDomainModel = DomainModel::getAllDomainOnCache();
$this->arrDomainModel = array_values(array_filter(
$arrAllDomainModel,
static fn($DomainModel): bool => in_array((string)$DomainModel->d_domain, $arrDomains, true)
));
}
if (empty($this->getDomain())) {
echo 'No domains matched for sitemap generation.' . PHP_EOL;
return;
}
// 1. 只查一次总数(非常重要)
$arrResult = $this->VideoModel->findPaginatedWithCache([], 1, 1);
$this->intTotal = $arrResult['total'];

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace app\task\module;
use app\common\helper\VideoMetadataMissingRefreshHelper;
use app\model\PlanTaskModel;
use app\task\logic\SiteMapLogic;
use app\task\logic\VideoSiteMapLogic;
@@ -94,6 +95,9 @@ class PlanTask
case 'PUSH_BAIDU_VIDEO_URL':
self::pushBaiduVideoUrl();
break;
case 'REFRESH_VIDEO_METADATA_TASK_POOL':
self::refreshVideoMetadataTaskPool();
break;
}
@@ -115,6 +119,28 @@ class PlanTask
$QueueManage->set($arrTask);
}
/**
* 安全刷新视频缺字段工作台与任务池。
*
* 说明:
* 1. 只生成扫描产物和派单产物
* 2. 不自动补结构化事实字段
* 3. 不自动调用 AI API
* 4. 适合作为计划任务安全入口
*
* @return array
*/
public static function refreshVideoMetadataTaskPool(): array
{
return VideoMetadataMissingRefreshHelper::refresh([
'sample' => 8,
'queue_limit' => 50,
'prompt_limit' => 10,
'batch_size' => 10,
'batch_limit' => 10,
]);
}
/**
* Undocumented function
*