作者 lyh

gxAiblog自动发布

@@ -147,7 +147,6 @@ class AiVideoTask extends Command @@ -147,7 +147,6 @@ class AiVideoTask extends Command
147 if($route != $result['data']['url']){ 147 if($route != $result['data']['url']){
148 $aiVideoService->updateDetail(['url'=>$route,'task_id'=>$item['task_id']]); 148 $aiVideoService->updateDetail(['url'=>$route,'task_id'=>$item['task_id']]);
149 } 149 }
150 - $description = explode(".",$result['data']['content']);  
151 $saveData = [ 150 $saveData = [
152 'title'=>$result['data']['title'], 151 'title'=>$result['data']['title'],
153 'image'=>$result['data']['thumb'], 152 'image'=>$result['data']['thumb'],
@@ -160,7 +159,7 @@ class AiVideoTask extends Command @@ -160,7 +159,7 @@ class AiVideoTask extends Command
160 'status'=>$aiVideoTaskModel::STATUS_FINISH, 159 'status'=>$aiVideoTaskModel::STATUS_FINISH,
161 'seo_title'=>$result['data']['title'], 160 'seo_title'=>$result['data']['title'],
162 'seo_keyword'=>implode(',',$result['data']['keyword']), 161 'seo_keyword'=>implode(',',$result['data']['keyword']),
163 - 'seo_description'=>$description[0] ?? '', 162 + 'seo_description'=>$result['data']['description'] ?? '',
164 ]; 163 ];
165 $aiVideoModel->edit($saveData,['task_id'=>$item['task_id']]); 164 $aiVideoModel->edit($saveData,['task_id'=>$item['task_id']]);
166 //需要更新的路由 165 //需要更新的路由
@@ -50,14 +50,43 @@ class lyhDemo extends Command @@ -50,14 +50,43 @@ class lyhDemo extends Command
50 protected $description = '更新路由'; 50 protected $description = '更新路由';
51 51
52 public function handle(){ 52 public function handle(){
53 - $projectModel = new Project();  
54 - $lists = $projectModel->list(['delete_status' => 0,'extend_type'=>0,'type'=>['in',[1,2,3,4,6]]], 'id', ['id']);  
55 - foreach ($lists as $val) {  
56 - echo date('Y-m-d H:i:s') . '开始--项目的id:'. $val['id'] . PHP_EOL;  
57 - ProjectServer::useProject($val['id']); 53 +// $projectModel = new Project();
  54 +// $lists = $projectModel->list(['delete_status' => 0,'extend_type'=>0,'type'=>['in',[1,2,3,4,6]]], 'id', ['id']);
  55 +// foreach ($lists as $val) {
  56 +// echo date('Y-m-d H:i:s') . '开始--项目的id:'. $val['id'] . PHP_EOL;
  57 +// ProjectServer::useProject($val['id']);
  58 +// DB::disconnect('custom_mysql');
  59 +// echo date('Y-m-d H:i:s') . '结束--项目的id:'. $val['id'] . PHP_EOL;
  60 +// }
  61 + $this->_action();
  62 + return true;
  63 + }
  64 +
  65 + public function _action(){
  66 + $aiBlogTaskModel = new AiBlogTask();
  67 + $lists = $aiBlogTaskModel->list(['type'=>2,'status'=>2,'project_id'=>467]);
  68 + foreach ($lists as $item){
  69 + echo date('Y-m-d H:i:s') . '开始--项目的id:'. $item['project_id'] . PHP_EOL;
  70 + ProjectServer::useProject($item['project_id']);
  71 + $aiBlogModel = new AiBlog();
  72 + $aiBlogInfo = $aiBlogModel->read(['task_id'=>$item['task_id']],['id','route']);
  73 + if($aiBlogInfo === false){
  74 + continue;
  75 + }
  76 + try {
  77 + $aiBlogService = new AiBlogService($item['project_id']);
  78 + $aiBlogService->task_id = $item['task_id'];
  79 + //拉取文章数据
  80 + $result = $aiBlogService->getDetail();
  81 + if(isset($result) && ($result['status'] == 200)){
  82 + $aiBlogModel->edit(['seo_description'=>$result['data']['description']],['task_id'=>$item['task_id']]);
  83 + }
  84 + }catch (\Exception $e){
  85 + echo '跳过。'.PHP_EOL;
  86 + DB::disconnect('custom_mysql');
  87 + }
58 DB::disconnect('custom_mysql'); 88 DB::disconnect('custom_mysql');
59 - echo date('Y-m-d H:i:s') . '结束--项目的id:'. $val['id'] . PHP_EOL; 89 + echo date('Y-m-d H:i:s') . '结束--项目的id:'. $item['project_id'] . PHP_EOL;
60 } 90 }
61 - return true;  
62 } 91 }
63 } 92 }