作者 李宇航

合并分支 'lyh-server' 到 'master'

Lyh server



查看合并请求 !2503
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 namespace App\Console\Commands\Ai; 10 namespace App\Console\Commands\Ai;
11 11
12 use App\Models\Ai\AiVideo; 12 use App\Models\Ai\AiVideo;
  13 +use App\Models\Domain\DomainInfo;
13 use App\Models\Product\Keyword; 14 use App\Models\Product\Keyword;
14 use App\Models\Product\Product; 15 use App\Models\Product\Product;
15 use App\Models\Project\AiBlogTask as AiBlogTaskModel; 16 use App\Models\Project\AiBlogTask as AiBlogTaskModel;
@@ -72,7 +73,7 @@ class AiVideoAutoPublish extends Command @@ -72,7 +73,7 @@ class AiVideoAutoPublish extends Command
72 $this->output('开始自动发布Video文章'); 73 $this->output('开始自动发布Video文章');
73 $projectModel = new Project(); 74 $projectModel = new Project();
74 $optimizeModel = new DeployOptimize(); 75 $optimizeModel = new DeployOptimize();
75 - $projectList = $projectModel->list(['is_ai_video'=>1,'delete_status'=>0,'site_status'=>0,'extend_type'=>0],'id',['id']); 76 + $projectList = $projectModel->list(['is_ai_video'=>1,'id'=>3751,'delete_status'=>0,'site_status'=>0,'extend_type'=>0],'id',['id']);
76 foreach ($projectList as $item){ 77 foreach ($projectList as $item){
77 $this->output("项目{$item['id']}开始自动发布"); 78 $this->output("项目{$item['id']}开始自动发布");
78 //获取当前是否开启自动发布aiVideo 79 //获取当前是否开启自动发布aiVideo
@@ -93,20 +94,22 @@ class AiVideoAutoPublish extends Command @@ -93,20 +94,22 @@ class AiVideoAutoPublish extends Command
93 } 94 }
94 if($item['project_type'] == 1){ 95 if($item['project_type'] == 1){
95 //todo::页面上获取数据 96 //todo::页面上获取数据
  97 + $data = $this->getAiVideoParam($item['id']);
96 }else{ 98 }else{
97 //获取当前网站的标题 99 //获取当前网站的标题
98 ProjectServer::useProject($item['id']); 100 ProjectServer::useProject($item['id']);
99 $data = $this->getVideoInfo(); 101 $data = $this->getVideoInfo();
100 - if(!empty($data)){  
101 - //写入一条零时生成视频记录  
102 - $aiVideoAutoLogModel = new AiVideoAutoLog();  
103 - $aiVideoAutoLogModel->addReturnId(  
104 - ['project_id'=>$item['id'],'title'=>$data['title'],'remark'=>$data['remark'],'images'=>json_encode($data['images'],true),'date'=>date('Y-m-d')]  
105 - );  
106 - } 102 + DB::disconnect('custom_mysql');
  103 + }
  104 + if(!empty($data)){
  105 + //写入一条零时生成视频记录
  106 + $aiVideoAutoLogModel = new AiVideoAutoLog();
  107 + $aiVideoAutoLogModel->addReturnId(
  108 + ['project_id'=>$item['id'],'title'=>$data['title'],'remark'=>$data['remark'],'images'=>json_encode($data['images'],true),'date'=>date('Y-m-d')]
  109 + );
107 } 110 }
108 - DB::disconnect('custom_mysql');  
109 } 111 }
  112 + return true;
110 } 113 }
111 114
112 /** 115 /**
@@ -285,10 +288,16 @@ class AiVideoAutoPublish extends Command @@ -285,10 +288,16 @@ class AiVideoAutoPublish extends Command
285 * @method :post 288 * @method :post
286 * @time :2025/8/1 16:25 289 * @time :2025/8/1 16:25
287 */ 290 */
288 - public function getAiVideoParam($project_id) 291 + public function getAiVideoParam($project_id = 3751)
289 { 292 {
290 //获取当前网站域名 293 //获取当前网站域名
291 - $domain = 'www.cs-conveyor.com'; 294 + $domainModel = new DomainInfo();
  295 + $domain = $domainModel->getValue(['project_id'=>$project_id],'domain');
  296 + if(empty($domain)){
  297 + return true;
  298 + }
  299 + $domain = str_replace('blog.', 'www.', $domain);
  300 + //todo::看是否获取建站的产品数据
292 try { 301 try {
293 $sitemap_url = 'https://' . $domain . '/sitemap_post_tag.xml'; 302 $sitemap_url = 'https://' . $domain . '/sitemap_post_tag.xml';
294 $sitemap_string = file_get_contents($sitemap_url); 303 $sitemap_string = file_get_contents($sitemap_url);
@@ -310,16 +319,20 @@ class AiVideoAutoPublish extends Command @@ -310,16 +319,20 @@ class AiVideoAutoPublish extends Command
310 $img = $dom->find('.layout .global_section img'); 319 $img = $dom->find('.layout .global_section img');
311 $images = []; 320 $images = [];
312 foreach ($img as $item) { 321 foreach ($img as $item) {
313 - if (empty($item->src) || empty($item->alt)) 322 + if (empty($item->src) || empty($item->alt)){
314 continue; 323 continue;
315 - array_push($images, ['src' => $item->src, 'alt' => $item->alt]); 324 + }
  325 + array_push($images, ['url' => $item->src, 'alt' => $item->alt]);
316 } 326 }
317 if (empty($title) || empty($content) || empty($images)) { 327 if (empty($title) || empty($content) || empty($images)) {
318 $num++; 328 $num++;
319 goto AGAIN; 329 goto AGAIN;
320 } 330 }
  331 + return ['title'=>$title,'remark'=>$content,'images'=>$images];
321 } catch (\Exception $e) { 332 } catch (\Exception $e) {
  333 + $this->output('project_id: ' . $project_id . ', domain: ' . $domain . ', error: ' . $e->getMessage());
322 echo 'project_id: ' . $project_id . ', domain: ' . $domain . ', error: ' . $e->getMessage() . PHP_EOL; 334 echo 'project_id: ' . $project_id . ', domain: ' . $domain . ', error: ' . $e->getMessage() . PHP_EOL;
  335 + return [];
323 } 336 }
324 } 337 }
325 338