作者 李宇航

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

Lyh server



查看合并请求 !2485
... ... @@ -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']]);
}
}
}
... ...
... ... @@ -10,6 +10,7 @@
namespace App\Http\Controllers\Api;
use App\Enums\Common\Code;
use App\Models\Project\AiVideoAutoLog;
class AiVideoController extends BaseController
{
... ... @@ -23,6 +24,8 @@ class AiVideoController extends BaseController
public function ImageCallBack(){
$data = $this->param;
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($data, true) . PHP_EOL, FILE_APPEND);
// $aiVideoAutoLogModel = new AiVideoAutoLog();
// $aiVideoAutoLogModel->edit(['result'=>$data],['trigger_id'=>$data['trigger_id']]);
$this->response('success');
}
}
... ...
... ... @@ -108,7 +108,6 @@ class CosService
{
if(!$key){
$url_arr = parse_url($file_url);
if($same_name){
$path_arr = explode('/',$url_arr['path']);
$filename = end($path_arr);
... ...