导入逻辑支持超过1小时的视频片段

This commit is contained in:
Jerry Yan 2024-06-08 21:35:08 +08:00
parent 4238cfdcf4
commit 31c21e3a04

View File

@ -91,7 +91,7 @@ class ProgramConstructController extends BaseController
"bvid" => "该BVID下已有{$count}个节目关联,请手动添加" "bvid" => "该BVID下已有{$count}个节目关联,请手动添加"
]); ]);
} }
$regex = "/^p(?P<part>\d{1,2})[-# _:,)]+(?P<time>(0?1[:])?\d{1,3}[:]\d{1,2})\s*(?P<content>.+)$/ui"; $regex = "/^(p(?P<part>\d{1,2})[-# _:,)]+)?(?P<time>(\d{1,2}[:])?\d{1,3}[:]\d{1,2})\s*(?P<content>.+)$/ui";
$video_parts = VideoParts::query()->where("bvid", "=", $bvid)->get(); $video_parts = VideoParts::query()->where("bvid", "=", $bvid)->get();
DB::beginTransaction(); DB::beginTransaction();
try { try {
@ -110,7 +110,7 @@ class ProgramConstructController extends BaseController
$program->name = trim($match["content"]); $program->name = trim($match["content"]);
$video_pivot = new ProgramVideos(); $video_pivot = new ProgramVideos();
$video_pivot->video_bvid = $bvid; $video_pivot->video_bvid = $bvid;
$video_pivot->start_part = $match["part"]; $video_pivot->start_part = $match["part"] ?? 1;
$video_pivot->start_time = $time; $video_pivot->start_time = $time;
$program->save(); $program->save();
$program->video_pivots()->save($video_pivot); $program->video_pivots()->save($video_pivot);