|
...
|
...
|
@@ -10,6 +10,7 @@ |
|
|
|
namespace App\Console\Commands\Ai;
|
|
|
|
|
|
|
|
use App\Models\Ai\AiVideo;
|
|
|
|
use App\Models\Domain\DomainInfo;
|
|
|
|
use App\Models\Product\Keyword;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Models\Project\AiBlogTask as AiBlogTaskModel;
|
|
...
|
...
|
@@ -72,7 +73,7 @@ class AiVideoAutoPublish extends Command |
|
|
|
$this->output('开始自动发布Video文章');
|
|
|
|
$projectModel = new Project();
|
|
|
|
$optimizeModel = new DeployOptimize();
|
|
|
|
$projectList = $projectModel->list(['is_ai_video'=>1,'delete_status'=>0,'site_status'=>0,'extend_type'=>0],'id',['id']);
|
|
|
|
$projectList = $projectModel->list(['is_ai_video'=>1,'id'=>3751,'delete_status'=>0,'site_status'=>0,'extend_type'=>0],'id',['id']);
|
|
|
|
foreach ($projectList as $item){
|
|
|
|
$this->output("项目{$item['id']}开始自动发布");
|
|
|
|
//获取当前是否开启自动发布aiVideo
|
|
...
|
...
|
@@ -93,10 +94,13 @@ class AiVideoAutoPublish extends Command |
|
|
|
}
|
|
|
|
if($item['project_type'] == 1){
|
|
|
|
//todo::页面上获取数据
|
|
|
|
$data = $this->getAiVideoParam($item['id']);
|
|
|
|
}else{
|
|
|
|
//获取当前网站的标题
|
|
|
|
ProjectServer::useProject($item['id']);
|
|
|
|
$data = $this->getVideoInfo();
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
if(!empty($data)){
|
|
|
|
//写入一条零时生成视频记录
|
|
|
|
$aiVideoAutoLogModel = new AiVideoAutoLog();
|
|
...
|
...
|
@@ -105,8 +109,7 @@ class AiVideoAutoPublish extends Command |
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -285,10 +288,16 @@ class AiVideoAutoPublish extends Command |
|
|
|
* @method :post
|
|
|
|
* @time :2025/8/1 16:25
|
|
|
|
*/
|
|
|
|
public function getAiVideoParam($project_id)
|
|
|
|
public function getAiVideoParam($project_id = 3751)
|
|
|
|
{
|
|
|
|
//获取当前网站域名
|
|
|
|
$domain = 'www.cs-conveyor.com';
|
|
|
|
$domainModel = new DomainInfo();
|
|
|
|
$domain = $domainModel->getValue(['project_id'=>$project_id],'domain');
|
|
|
|
if(empty($domain)){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
$domain = str_replace('blog.', 'www.', $domain);
|
|
|
|
//todo::看是否获取建站的产品数据
|
|
|
|
try {
|
|
|
|
$sitemap_url = 'https://' . $domain . '/sitemap_post_tag.xml';
|
|
|
|
$sitemap_string = file_get_contents($sitemap_url);
|
|
...
|
...
|
@@ -310,16 +319,20 @@ class AiVideoAutoPublish extends Command |
|
|
|
$img = $dom->find('.layout .global_section img');
|
|
|
|
$images = [];
|
|
|
|
foreach ($img as $item) {
|
|
|
|
if (empty($item->src) || empty($item->alt))
|
|
|
|
if (empty($item->src) || empty($item->alt)){
|
|
|
|
continue;
|
|
|
|
array_push($images, ['src' => $item->src, 'alt' => $item->alt]);
|
|
|
|
}
|
|
|
|
array_push($images, ['url' => $item->src, 'alt' => $item->alt]);
|
|
|
|
}
|
|
|
|
if (empty($title) || empty($content) || empty($images)) {
|
|
|
|
$num++;
|
|
|
|
goto AGAIN;
|
|
|
|
}
|
|
|
|
return ['title'=>$title,'remark'=>$content,'images'=>$images];
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
$this->output('project_id: ' . $project_id . ', domain: ' . $domain . ', error: ' . $e->getMessage());
|
|
|
|
echo 'project_id: ' . $project_id . ', domain: ' . $domain . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|