|
@@ -3,6 +3,7 @@
|
|
|
use App\Consts\BaseConst;
|
|
use App\Consts\BaseConst;
|
|
|
use GuzzleHttp\Client;
|
|
use GuzzleHttp\Client;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
+use Illuminate\Support\Facades\Cache;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
use Monolog\Handler\StreamHandler;
|
|
use Monolog\Handler\StreamHandler;
|
|
|
use Monolog\Logger;
|
|
use Monolog\Logger;
|
|
@@ -3438,7 +3439,8 @@ function handleEpisodeContentForAce($originalContent) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 提取主体列表 - 兼容多种格式
|
|
// 提取主体列表 - 兼容多种格式
|
|
|
- if (preg_match('/###\s*主体列表\s*\n(.*?)(?=\n\s*###[^#]|\z)/s', $originalContent, $charactersMatch)) {
|
|
|
|
|
|
|
+ // if (preg_match('/###\s*主体列表\s*\n(.*?)(?=\n\s*###[^#]|\z)/s', $originalContent, $charactersMatch)) {
|
|
|
|
|
+ if (preg_match('/###[ \t]*主体列表[ \t]*\r?\n(.*?)(?=###[^#\n]|\z)/s', $originalContent, $charactersMatch)) {
|
|
|
$charactersText = trim($charactersMatch[1]);
|
|
$charactersText = trim($charactersMatch[1]);
|
|
|
$characterLines = explode("\n", $charactersText);
|
|
$characterLines = explode("\n", $charactersText);
|
|
|
|
|
|
|
@@ -3549,7 +3551,8 @@ function handleEpisodeContentForAce($originalContent) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 提取场景列表 - 兼容多种格式
|
|
// 提取场景列表 - 兼容多种格式
|
|
|
- if (preg_match('/###\s*场景列表\s*\n(.*?)(?=\n\s*###[^#]|\z)/s', $originalContent, $scenesMatch)) {
|
|
|
|
|
|
|
+ // if (preg_match('/###\s*场景列表\s*\n(.*?)(?=\n\s*###[^#]|\z)/s', $originalContent, $scenesMatch)) {
|
|
|
|
|
+ if (preg_match('/###[ \t]*场景列表[ \t]*\r?\n(.*?)(?=###[^#\n]|\z)/s', $originalContent, $scenesMatch)) {
|
|
|
$scenesText = trim($scenesMatch[1]);
|
|
$scenesText = trim($scenesMatch[1]);
|
|
|
$sceneLines = explode("\n", $scenesText);
|
|
$sceneLines = explode("\n", $scenesText);
|
|
|
|
|
|
|
@@ -3586,7 +3589,7 @@ function handleEpisodeContentForAce($originalContent) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 提取道具列表 - 兼容多种格式
|
|
// 提取道具列表 - 兼容多种格式
|
|
|
- if (preg_match('/###\s*道具列表\s*\n(.*?)(?=\n\s*###[^#]|\z)/s', $originalContent, $propsMatch)) {
|
|
|
|
|
|
|
+ if (preg_match('/###[ \t]*道具列表[ \t]*\r?\n(.*?)(?=###[^#\n]|\z)/s', $originalContent, $propsMatch)) {
|
|
|
$propsText = trim($propsMatch[1]);
|
|
$propsText = trim($propsMatch[1]);
|
|
|
$propLines = explode("\n", $propsText);
|
|
$propLines = explode("\n", $propsText);
|
|
|
|
|
|
|
@@ -3612,12 +3615,10 @@ function handleEpisodeContentForAce($originalContent) {
|
|
|
'description' => $description
|
|
'description' => $description
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
- // 如果有道具图片提示词,添加到数组中
|
|
|
|
|
if ($picPrompt) {
|
|
if ($picPrompt) {
|
|
|
$propData['pic_prompt'] = $picPrompt;
|
|
$propData['pic_prompt'] = $picPrompt;
|
|
|
|
|
+ $result['props'][] = $propData;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- $result['props'][] = $propData;
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -5118,9 +5119,9 @@ function splitContent($content) {
|
|
|
// 获取当前章节标题
|
|
// 获取当前章节标题
|
|
|
$titleLine = trim($matches[0][$i][0]);
|
|
$titleLine = trim($matches[0][$i][0]);
|
|
|
// 去除标题开头的特殊符号
|
|
// 去除标题开头的特殊符号
|
|
|
- $cleanTitle = preg_replace('/^[#*·\-_=\s]+/', '', $titleLine);
|
|
|
|
|
|
|
+ $cleanTitle = preg_replace('/^[#*·\-_=\s]+/u', '', $titleLine);
|
|
|
// 去除标题结尾的冒号和特殊符号
|
|
// 去除标题结尾的冒号和特殊符号
|
|
|
- $cleanTitle = preg_replace('/[#*·::\s]+$/', '', $cleanTitle);
|
|
|
|
|
|
|
+ $cleanTitle = preg_replace('/[#*·::\s]+$/u', '', $cleanTitle);
|
|
|
$cleanTitle = trim($cleanTitle);
|
|
$cleanTitle = trim($cleanTitle);
|
|
|
|
|
|
|
|
// 获取当前标题的结束位置
|
|
// 获取当前标题的结束位置
|
|
@@ -5233,15 +5234,19 @@ function mapErrorMessage($errorMessage)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (stripos($errorMessage, 'The request failed because the output video may be related to copyright restrictions') !== false) {
|
|
if (stripos($errorMessage, 'The request failed because the output video may be related to copyright restrictions') !== false) {
|
|
|
- return '涉及到版权问题无法生成,请调整后重试';
|
|
|
|
|
|
|
+ return '输出视频可能涉及版权限制,请更换内容或降低相似度后重试。';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (stripos($errorMessage, 'sensitive') !== false) {
|
|
|
|
|
- return '含有敏感词,请调整后重试';
|
|
|
|
|
|
|
+ // 未命中预设错误:调用模型生成友好翻译并缓存,避免轮询场景重复消耗
|
|
|
|
|
+ try {
|
|
|
|
|
+ $cacheKey = 'unknown_error_translate_' . md5((string)$errorMessage);
|
|
|
|
|
+ return Cache::remember($cacheKey, 600, function () use ($errorMessage) {
|
|
|
|
|
+ $friendlyError = app(\App\Services\DeepSeek\DeepSeekService::class)->analyzeErrorMessage($errorMessage);
|
|
|
|
|
+ return $friendlyError ?: '未知异常,请重试';
|
|
|
|
|
+ });
|
|
|
|
|
+ } catch (\Throwable $e) {
|
|
|
|
|
+ return '未知异常,请重试';
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 默认返回
|
|
|
|
|
- return '未知异常,请重试';
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|