lh 1 tydzień temu
rodzic
commit
93d7cc6b16

+ 27 - 2
app/Console/Commands/FixNewVideoTasks720pCommand.php

@@ -12,7 +12,8 @@ use Illuminate\Support\Facades\DB;
  * 2. 检查 sr_720p / 720p / 480p 成功任务的 result_url、compressed_url 是否真的是 720p:
  * 2. 检查 sr_720p / 720p / 480p 成功任务的 result_url、compressed_url 是否真的是 720p:
  *    - result 为 480p 档 -> 本地超分到 720p,重新压缩,更新任务两列 URL;
  *    - result 为 480p 档 -> 本地超分到 720p,重新压缩,更新任务两列 URL;
  *    - result 已是 720p+ 但 compressed 为 480p 档 -> 基于 result 重新压缩;
  *    - result 已是 720p+ 但 compressed 为 480p 档 -> 基于 result 重新压缩;
- *    - 同步关联 mp_episode_segments 的 origin_video_url / video_url(仅 URL,其余字段不动)。
+ *    - 同步关联 mp_episode_segments 的 origin_video_url / video_url(仅 URL,其余字段不动);
+ *    - 同步关联 mp_anime_records 中 assistant 记录(video_url 指向该任务旧 result_url)为修复后的 result_url。
  *
  *
  * 注意:本命令依赖 ffmpeg/ffprobe 且需在 APP_ENV != local 的环境执行
  * 注意:本命令依赖 ffmpeg/ffprobe 且需在 APP_ENV != local 的环境执行
  * (upgrade480pTo720p / compressVideo 在 local 会短路)。
  * (upgrade480pTo720p / compressVideo 在 local 会短路)。
@@ -150,7 +151,13 @@ class FixNewVideoTasks720pCommand extends Command
                     ]);
                     ]);
 
 
                 $segmentSynced = $this->syncSegmentUrls($task, $newResult, $newCompressed);
                 $segmentSynced = $this->syncSegmentUrls($task, $newResult, $newCompressed);
-                $this->line(sprintf('#%d 已更新任务 URL(分镜同步:%s)', $task->id, $segmentSynced ? '是' : '跳过/无关联'));
+                $recordSynced = $this->syncAnimeRecordUrls($task, $newResult);
+                $this->line(sprintf(
+                    '#%d 已更新任务 URL(分镜同步:%s;anime_records 同步:%d 条)',
+                    $task->id,
+                    $segmentSynced ? '是' : '跳过/无关联',
+                    $recordSynced
+                ));
                 $updated++;
                 $updated++;
             }
             }
         }
         }
@@ -224,6 +231,24 @@ class FixNewVideoTasks720pCommand extends Command
     }
     }
 
 
     /**
     /**
+     * 同步 mp_anime_records 中 assistant 对话记录的 video_url
+     * 仅更新 video_task_id 匹配、role=assistant 且 video_url 仍指向该任务旧 result_url 的行,
+     * 避免覆盖同 act 其他任务写入的记录。
+     *
+     * @param object $task
+     * @param string $newResultUrl
+     * @return int 更新的记录数
+     */
+    private function syncAnimeRecordUrls($task, string $newResultUrl): int
+    {
+        return DB::table('mp_anime_records')
+            ->where('video_task_id', $task->id)
+            ->where('role', 'assistant')
+            ->where('video_url', $task->result_url)
+            ->update(['video_url' => $newResultUrl]);
+    }
+
+    /**
      * 同步关联 mp_episode_segments 的 URL(仅 origin_video_url / video_url)
      * 同步关联 mp_episode_segments 的 URL(仅 origin_video_url / video_url)
      * 仅当分镜当前指向的就是该任务旧 URL 时才更新,避免覆盖同一分镜更新任务的产物。
      * 仅当分镜当前指向的就是该任务旧 URL 时才更新,避免覆盖同一分镜更新任务的产物。
      *
      *