|
...
|
...
|
@@ -20,6 +20,7 @@ use Illuminate\Console\Command; |
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
use App\Models\Project\AiVideoTask;
|
|
|
|
use Illuminate\Support\Facades\Redis;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :ai视频自动发布
|
|
...
|
...
|
@@ -45,7 +46,10 @@ class AiVideoAutoPublish extends Command |
|
|
|
protected $description = '自动发布AI Video';
|
|
|
|
|
|
|
|
public function handle(){
|
|
|
|
|
|
|
|
$action = $this->argument('action');
|
|
|
|
if($action == 'auto_publish'){
|
|
|
|
$this->auto_publish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -104,7 +108,7 @@ class AiVideoAutoPublish extends Command |
|
|
|
$random = rand(1, 2);
|
|
|
|
if($random == 1){//取产品
|
|
|
|
$productModel = new Product();
|
|
|
|
$info = $productModel->formatQuery(['title'=>['!=',null],'intro'=>['!=',null]])->select(['title','gallery','intro'])->inRandomOrder()->first();
|
|
|
|
$info = $productModel->formatQuery(['status'=>1,'title'=>['!=',null],'intro'=>['!=',null]])->select(['title','gallery','intro'])->inRandomOrder()->first();
|
|
|
|
if(empty($info)){
|
|
|
|
return $data;
|
|
|
|
}
|
|
...
|
...
|
@@ -139,23 +143,30 @@ class AiVideoAutoPublish extends Command |
|
|
|
* @time :2025/8/2 10:37
|
|
|
|
*/
|
|
|
|
public function auto_send_video(){
|
|
|
|
$number = Redis::get('ai_video_image') ?? 0;
|
|
|
|
$aiVideoAutoLogModel = new AiVideoAutoLog();
|
|
|
|
while (true){
|
|
|
|
$aiVideoAutoLogModel = new AiVideoAutoLog();
|
|
|
|
$lists = $aiVideoAutoLogModel->list(['status'=>0]);
|
|
|
|
if(empty($lists)){
|
|
|
|
if($number > 5){
|
|
|
|
sleep(300);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$item = $aiVideoAutoLogModel->read(['status'=>0]);
|
|
|
|
if(empty($info)){
|
|
|
|
sleep(60);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
foreach ($lists as $item){
|
|
|
|
if(count($item['images']) < 6){
|
|
|
|
//需要生成图片
|
|
|
|
$content = "{$item['remark']},{$item['title']},4K,高清 --no logo --ar 16:9";
|
|
|
|
$midJourneyService = new MidJourneyService();
|
|
|
|
$result = $midJourneyService->imagine($content);
|
|
|
|
dd($result);
|
|
|
|
}else{
|
|
|
|
//提交到待执行
|
|
|
|
$aiVideoAutoLogModel->edit(['status'=>1],['id'=>$item['id']]);
|
|
|
|
if(count($item['images']) < 6){
|
|
|
|
//需要生成图片
|
|
|
|
$content = "{$item['remark']},{$item['title']},4K,高清 --no logo --ar 16:9";
|
|
|
|
$midJourneyService = new MidJourneyService();
|
|
|
|
$result = $midJourneyService->imagine($content);
|
|
|
|
if($result && !empty($result['trigger_id'])){
|
|
|
|
Redis::incr('ai_video_image');
|
|
|
|
$aiVideoAutoLogModel->edit(['trigger_id'=>$result['trigger_id']],['id'=>$item['id']]);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
//提交到待执行
|
|
|
|
$aiVideoAutoLogModel->edit(['status'=>1],['id'=>$item['id']]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
...
|
...
|
|