From 88043379f3c505c21b73b7408cd64c638f29ab4f Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Tue, 20 Dec 2022 20:55:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E8=8A=82=E7=9B=AE=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E8=87=AA=E5=8A=A8=E4=BF=AE=E5=A4=8D=E6=97=B6=E9=97=B4?= =?UTF-8?q?=EF=BC=8C=E5=8F=96=E6=B6=88=E6=89=8B=E5=8A=A8=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=EF=BC=8C=E5=8F=96=E6=B6=88=E4=B8=BB=E5=8A=A8=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=88=86P?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/ProgramConstructController.php | 1 - .../Controllers/ProgramVideoConstructController.php | 2 +- app/Models/VideoParts.php | 1 + app/Util/ProgramVideoUtil.php | 13 +++++++++---- .../views/program/construct/video/create.blade.php | 9 --------- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/app/Http/Controllers/ProgramConstructController.php b/app/Http/Controllers/ProgramConstructController.php index d191b62..db653cb 100644 --- a/app/Http/Controllers/ProgramConstructController.php +++ b/app/Http/Controllers/ProgramConstructController.php @@ -112,7 +112,6 @@ class ProgramConstructController extends BaseController $video_pivot->video_bvid = $bvid; $video_pivot->start_part = $match["part"]; $video_pivot->start_time = $time; - $video_pivot->stop_part = $match["part"]; $program->save(); $program->video_pivots()->save($video_pivot); } diff --git a/app/Http/Controllers/ProgramVideoConstructController.php b/app/Http/Controllers/ProgramVideoConstructController.php index d652893..9dc7201 100644 --- a/app/Http/Controllers/ProgramVideoConstructController.php +++ b/app/Http/Controllers/ProgramVideoConstructController.php @@ -32,7 +32,6 @@ class ProgramVideoConstructController extends BaseController "stop_part" => ["required", "int", "gte:start_part"], "start_time" => ["required", "date_format:H:i:s"], "stop_time" => ["required", "date_format:H:i:s"], - "created_at" => ["date"], ]); $program_video = new ProgramVideos(); $createPayload = $request->only(["start_part", "start_time", "stop_part", "stop_time"]); @@ -54,6 +53,7 @@ class ProgramVideoConstructController extends BaseController $program_video->created_at = $request->post("created_at"); } $program->video_pivots()->save($program_video); + ProgramVideoUtil::fix_created_at_by_part_info($program_video->video_bvid); return redirect(route("program.construct.video.list", [ "program"=>$program_video->program_id ])); diff --git a/app/Models/VideoParts.php b/app/Models/VideoParts.php index 72275ab..b9a46fb 100644 --- a/app/Models/VideoParts.php +++ b/app/Models/VideoParts.php @@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model; /** * @property \Carbon\Carbon $duration + * @property int $part_num */ class VideoParts extends Model { diff --git a/app/Util/ProgramVideoUtil.php b/app/Util/ProgramVideoUtil.php index ac97aac..b12b0ce 100644 --- a/app/Util/ProgramVideoUtil.php +++ b/app/Util/ProgramVideoUtil.php @@ -80,10 +80,15 @@ class ProgramVideoUtil $base_time, $start_time->secondsSinceMidnight() ); - if ($cur_part->duration->diffInMinutes($start_time) < 20) { - $program_video->stop_part += 1; - if ($program_video->stop_part > $video_parts->pluck("part_num")->max()) { - $program_video->stop_part = $video_parts->pluck("part_num")->max(); + if (!$program_video->stop_part) { + // 没有再去修复 + if ($cur_part->duration->diffInMinutes($start_time) < 20) { + $program_video->stop_part = $cur_part->part_num + 1; + if ($program_video->stop_part > $video_parts->pluck("part_num")->max()) { + $program_video->stop_part = $video_parts->pluck("part_num")->max(); + } + } else { + $program_video->stop_part = $cur_part->part_num; } } $program_video->save(); diff --git a/resources/views/program/construct/video/create.blade.php b/resources/views/program/construct/video/create.blade.php index f90a1ba..cab7fab 100644 --- a/resources/views/program/construct/video/create.blade.php +++ b/resources/views/program/construct/video/create.blade.php @@ -28,10 +28,6 @@ @endif -