|
@@ -63,7 +63,7 @@ class AiVideoAutoPublish extends Command |
|
@@ -63,7 +63,7 @@ class AiVideoAutoPublish extends Command |
|
63
|
}
|
63
|
}
|
|
64
|
|
64
|
|
|
65
|
/**
|
65
|
/**
|
|
66
|
- * @remark :普通项目--自动发布
|
66
|
+ * @remark :自动发布aiVideo组装数据(写入一条记录)
|
|
67
|
* @name :auto_six_publish
|
67
|
* @name :auto_six_publish
|
|
68
|
* @author :lyh
|
68
|
* @author :lyh
|
|
69
|
* @method :post
|
69
|
* @method :post
|
|
@@ -73,7 +73,7 @@ class AiVideoAutoPublish extends Command |
|
@@ -73,7 +73,7 @@ class AiVideoAutoPublish extends Command |
|
73
|
$this->output('开始自动发布Video文章');
|
73
|
$this->output('开始自动发布Video文章');
|
|
74
|
$projectModel = new Project();
|
74
|
$projectModel = new Project();
|
|
75
|
$optimizeModel = new DeployOptimize();
|
75
|
$optimizeModel = new DeployOptimize();
|
|
76
|
- $projectList = $projectModel->list(['is_ai_video'=>1,'id'=>1,'delete_status'=>0,'site_status'=>0,'extend_type'=>0],'id',['id','project_type']);
|
76
|
+ $projectList = $projectModel->list(['is_ai_video'=>1,'delete_status'=>0,'site_status'=>0,'extend_type'=>0],'id',['id','project_type']);
|
|
77
|
foreach ($projectList as $item){
|
77
|
foreach ($projectList as $item){
|
|
78
|
$this->output("项目{$item['id']}开始自动发布");
|
78
|
$this->output("项目{$item['id']}开始自动发布");
|
|
79
|
//获取当前是否开启自动发布aiVideo
|
79
|
//获取当前是否开启自动发布aiVideo
|
|
@@ -129,10 +129,7 @@ class AiVideoAutoPublish extends Command |
|
@@ -129,10 +129,7 @@ class AiVideoAutoPublish extends Command |
|
129
|
return $data;
|
129
|
return $data;
|
|
130
|
}
|
130
|
}
|
|
131
|
$data['title'] = $info['title'];
|
131
|
$data['title'] = $info['title'];
|
|
132
|
- $data['remark'] = strip_tags($info['intro']);
|
|
|
|
133
|
- if(empty($data['remark'])){
|
|
|
|
134
|
- $data['remark'] = $data['title'];
|
|
|
|
135
|
- }
|
132
|
+ $data['remark'] = $info['intro'];
|
|
136
|
$data['images'] = array_filter(array_map(function ($item) use ($data) {
|
133
|
$data['images'] = array_filter(array_map(function ($item) use ($data) {
|
|
137
|
if (!empty($item['url'])) {
|
134
|
if (!empty($item['url'])) {
|
|
138
|
return [
|
135
|
return [
|
|
@@ -193,7 +190,6 @@ class AiVideoAutoPublish extends Command |
|
@@ -193,7 +190,6 @@ class AiVideoAutoPublish extends Command |
|
193
|
}
|
190
|
}
|
|
194
|
$item = $aiVideoAutoLogModel->read(['status'=>0,'trigger_id'=>null]);
|
191
|
$item = $aiVideoAutoLogModel->read(['status'=>0,'trigger_id'=>null]);
|
|
195
|
if($item === false){
|
192
|
if($item === false){
|
|
196
|
- echo date('Y-m-d H:i:s').':无生成图片的数据。'.PHP_EOL;
|
|
|
|
197
|
sleep(60);
|
193
|
sleep(60);
|
|
198
|
continue;
|
194
|
continue;
|
|
199
|
}
|
195
|
}
|
|
@@ -204,7 +200,7 @@ class AiVideoAutoPublish extends Command |
|
@@ -204,7 +200,7 @@ class AiVideoAutoPublish extends Command |
|
204
|
$midJourneyService = new MidJourneyService();
|
200
|
$midJourneyService = new MidJourneyService();
|
|
205
|
$result = $midJourneyService->imagine($content);
|
201
|
$result = $midJourneyService->imagine($content);
|
|
206
|
if($result && !empty($result['trigger_id'])){
|
202
|
if($result && !empty($result['trigger_id'])){
|
|
207
|
- echo '提交的数据详情。'.json_encode($result,true).$item['project_id'].PHP_EOL;
|
203
|
+ echo '提交的数据详情。'.json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES).$item['project_id'].PHP_EOL;
|
|
208
|
Redis::incr('ai_video_image');
|
204
|
Redis::incr('ai_video_image');
|
|
209
|
$aiVideoAutoLogModel->edit(['trigger_id'=>$result['trigger_id']],['id'=>$item['id']]);
|
205
|
$aiVideoAutoLogModel->edit(['trigger_id'=>$result['trigger_id']],['id'=>$item['id']]);
|
|
210
|
}
|
206
|
}
|
|
@@ -241,14 +237,17 @@ class AiVideoAutoPublish extends Command |
|
@@ -241,14 +237,17 @@ class AiVideoAutoPublish extends Command |
|
241
|
$aiVideoService = new AiVideoService($info['project_id']);
|
237
|
$aiVideoService = new AiVideoService($info['project_id']);
|
|
242
|
$projectModel = new DeployOptimize();
|
238
|
$projectModel = new DeployOptimize();
|
|
243
|
$video_setting = $projectModel->getValue(['project_id'=>$info['project_id']],'video_setting');
|
239
|
$video_setting = $projectModel->getValue(['project_id'=>$info['project_id']],'video_setting');
|
|
|
|
240
|
+ $frequency_setting = $projectModel->getValue(['project_id'=>$info['project_id']],'send_ai_video_frequency');
|
|
244
|
$storage = $aiVideoTaskModel->videoSetting()[$video_setting ?? 1];
|
241
|
$storage = $aiVideoTaskModel->videoSetting()[$video_setting ?? 1];
|
|
|
|
242
|
+ $frequency = $aiVideoTaskModel->videoFrequency()[$frequency_setting ?? 1];
|
|
|
|
243
|
+ $frequencyArr = explode('-',$frequency);
|
|
245
|
$result = $aiVideoService->createTask($info['title'],$info['remark'],$info['images'],[],$storage);
|
244
|
$result = $aiVideoService->createTask($info['title'],$info['remark'],$info['images'],[],$storage);
|
|
246
|
if($result['status'] == 200){
|
245
|
if($result['status'] == 200){
|
|
247
|
- $aiVideoTaskModel->addReturnId(['task_id'=>$result['data']['task_id'],'project_id'=>$info['project_id'],'storage'=>$storage]);
|
246
|
+ $next_auto_date = date('Y-m-d', strtotime('+' . mt_rand($frequencyArr[0] ?? 5,$frequencyArr[1] ?? 7) . 'days')); //每5-7天自动发布
|
|
|
|
247
|
+ $aiVideoTaskModel->addReturnId(['next_auto_date'=>$next_auto_date,'task_id'=>$result['data']['task_id'],'project_id'=>$info['project_id'],'storage'=>$storage]);
|
|
248
|
ProjectServer::useProject($info['project_id']);
|
248
|
ProjectServer::useProject($info['project_id']);
|
|
249
|
$aiVideoModel = new AiVideo();
|
249
|
$aiVideoModel = new AiVideo();
|
|
250
|
- $next_auto_date = date('Y-m-d', strtotime('+' . mt_rand(5,7) . 'days')); //每5-7天自动发布
|
|
|
|
251
|
- $aiVideoModel->addReturnId(['next_auto_date'=>$next_auto_date,'title'=>$info['title'],'task_id'=>$result['data']['task_id'],'description'=>$info['remark'],'project_id'=>$info['project_id'],'images'=>json_encode($info['images'],true),'anchor'=>json_encode([],true)]);
|
250
|
+ $aiVideoModel->addReturnId(['title'=>$info['title'],'task_id'=>$result['data']['task_id'],'description'=>$info['remark'],'project_id'=>$info['project_id'],'images'=>json_encode($info['images'],true),'anchor'=>json_encode([],true)]);
|
|
252
|
DB::disconnect('custom_mysql');
|
251
|
DB::disconnect('custom_mysql');
|
|
253
|
$aiVideoAutoLogModel->edit(['status'=>2],['id'=>$info['id']]);
|
252
|
$aiVideoAutoLogModel->edit(['status'=>2],['id'=>$info['id']]);
|
|
254
|
}
|
253
|
}
|
|
@@ -289,7 +288,7 @@ class AiVideoAutoPublish extends Command |
|
@@ -289,7 +288,7 @@ class AiVideoAutoPublish extends Command |
|
289
|
* @method :post
|
288
|
* @method :post
|
|
290
|
* @time :2025/8/1 16:25
|
289
|
* @time :2025/8/1 16:25
|
|
291
|
*/
|
290
|
*/
|
|
292
|
- public function getAiVideoParam($project_id = 3751)
|
291
|
+ public function getAiVideoParam($project_id)
|
|
293
|
{
|
292
|
{
|
|
294
|
//获取当前网站域名
|
293
|
//获取当前网站域名
|
|
295
|
$domainModel = new DomainInfo();
|
294
|
$domainModel = new DomainInfo();
|