|
|
@@ -3478,6 +3478,12 @@ class AnimeService
|
|
|
Utils::throwError('20003:未找到该剧集的分镜数据');
|
|
|
}
|
|
|
|
|
|
+ // 获取当前完整视频url
|
|
|
+ $completeVideoUrl = DB::table('mp_anime_episodes')
|
|
|
+ ->where('anime_id', $animeId)
|
|
|
+ ->where('id', $episodeId)
|
|
|
+ ->value('complete_video_url');
|
|
|
+
|
|
|
// 检查是否所有分镜都有配音
|
|
|
$missingVideos = $segments->filter(function($segment) {
|
|
|
return empty($segment->audio_url);
|
|
|
@@ -3512,16 +3518,24 @@ class AnimeService
|
|
|
'updated_at' => $now
|
|
|
]);
|
|
|
|
|
|
+ if (!$taskId) {
|
|
|
+ Utils::throwError('20003:创建任务失败');
|
|
|
+ }
|
|
|
+
|
|
|
// 更新剧集表的任务ID和状态
|
|
|
- DB::table('mp_anime_episodes')
|
|
|
+ $boolen = DB::table('mp_anime_episodes')
|
|
|
->where('anime_id', $animeId)
|
|
|
- ->where('episode_id', $episodeId)
|
|
|
+ ->where('id', $episodeId)
|
|
|
->update([
|
|
|
'complete_video_task_id' => $taskId,
|
|
|
'complete_video_task_status' => '执行中',
|
|
|
'updated_at' => $now
|
|
|
]);
|
|
|
|
|
|
+ if (!$boolen) {
|
|
|
+ Utils::throwError('20003:更新剧集表失败');
|
|
|
+ }
|
|
|
+
|
|
|
dLog('anime')->info('创建完整视频合成任务', [
|
|
|
'task_id' => $taskId,
|
|
|
'anime_id' => $animeId,
|
|
|
@@ -3539,22 +3553,22 @@ class AnimeService
|
|
|
$error_msg = isset($response_arr['msg']) ? $response_arr['msg'] : '未知错误';
|
|
|
dLog('anime')->error('火山合成完整视频失败', ['error' => $error_msg, 'task_id' => $taskId]);
|
|
|
|
|
|
- // 更新任务状态为失败
|
|
|
- DB::table('mp_complete_video_tasks')
|
|
|
- ->where('id', $taskId)
|
|
|
- ->update([
|
|
|
- 'generate_status' => '执行失败',
|
|
|
- 'error_message' => $error_msg,
|
|
|
- 'updated_at' => date('Y-m-d H:i:s')
|
|
|
- ]);
|
|
|
+ // // 更新任务状态为失败
|
|
|
+ // DB::table('mp_complete_video_tasks')
|
|
|
+ // ->where('id', $taskId)
|
|
|
+ // ->update([
|
|
|
+ // 'generate_status' => '执行失败',
|
|
|
+ // 'error_message' => $error_msg,
|
|
|
+ // 'updated_at' => date('Y-m-d H:i:s')
|
|
|
+ // ]);
|
|
|
|
|
|
- // 同步更新剧集表状态
|
|
|
- DB::table('mp_anime_episodes')
|
|
|
- ->where('complete_video_task_id', $taskId)
|
|
|
- ->update([
|
|
|
- 'complete_video_task_status' => '执行失败',
|
|
|
- 'updated_at' => date('Y-m-d H:i:s')
|
|
|
- ]);
|
|
|
+ // // 同步更新剧集表状态
|
|
|
+ // DB::table('mp_anime_episodes')
|
|
|
+ // ->where('complete_video_task_id', $taskId)
|
|
|
+ // ->update([
|
|
|
+ // 'complete_video_task_status' => '执行失败',
|
|
|
+ // 'updated_at' => date('Y-m-d H:i:s')
|
|
|
+ // ]);
|
|
|
|
|
|
Utils::throwError('20003:火山合成完整视频失败: ' . $error_msg);
|
|
|
}
|
|
|
@@ -3611,10 +3625,11 @@ class AnimeService
|
|
|
// 检查任务是否完成
|
|
|
if ($task->generate_status === '执行成功') {
|
|
|
// 同步更新剧集表状态
|
|
|
- DB::table('mp_anime_episodes')
|
|
|
+ $boolen3 = DB::table('mp_anime_episodes')
|
|
|
->where('anime_id', $animeId)
|
|
|
- ->where('episode_id', $episodeId)
|
|
|
+ ->where('id', $episodeId)
|
|
|
->update([
|
|
|
+ 'complete_video_url' => $task->complete_video_url,
|
|
|
'complete_video_task_status' => '执行成功',
|
|
|
'updated_at' => date('Y-m-d H:i:s')
|
|
|
]);
|
|
|
@@ -3625,6 +3640,23 @@ class AnimeService
|
|
|
'attempts' => $attempt
|
|
|
]);
|
|
|
|
|
|
+ // 如果更新成功则远程删除之前的文件
|
|
|
+ if ($boolen3 && $completeVideoUrl) {
|
|
|
+ $encode_url = urlencode($completeVideoUrl);
|
|
|
+ $client = new Client(['timeout' => 300, 'verify' => false]);
|
|
|
+ // 根据ID通过API通知合成音频
|
|
|
+ // $result = $client->get("http://47.240.171.155:5000/api/fileDelete?url={$encode_url}");
|
|
|
+ $result = $client->get("http://122.9.129.83:5000/api/fileDelete?url={$encode_url}");
|
|
|
+ $response = $result->getBody()->getContents();
|
|
|
+ $response_arr = json_decode($response, true);
|
|
|
+ Log::info('火山删除音频返回: '.$response);
|
|
|
+ if (!isset($response_arr['status']) || (int)$response_arr['status'] !== 0) {
|
|
|
+ $error_msg = isset($response_arr['msg']) ? $response_arr['msg'] : '未知错误';
|
|
|
+ Log::info('火山删除音频失败: '.$error_msg);
|
|
|
+ // Utils::throwError('20003:火山删除音频失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return [
|
|
|
'task_id' => $taskId,
|
|
|
'anime_id' => $animeId,
|
|
|
@@ -3640,7 +3672,7 @@ class AnimeService
|
|
|
// 同步更新剧集表状态
|
|
|
DB::table('mp_anime_episodes')
|
|
|
->where('anime_id', $animeId)
|
|
|
- ->where('episode_id', $episodeId)
|
|
|
+ ->where('id', $episodeId)
|
|
|
->update([
|
|
|
'complete_video_task_status' => '执行失败',
|
|
|
'updated_at' => date('Y-m-d H:i:s')
|