新建节目时,自动修复时间,取消手动修复,取消主动修改分P

This commit is contained in:
Jerry Yan 2022-12-20 20:55:51 +08:00
parent 5e497e8677
commit 88043379f3
5 changed files with 11 additions and 15 deletions

View File

@ -112,7 +112,6 @@ class ProgramConstructController extends BaseController
$video_pivot->video_bvid = $bvid; $video_pivot->video_bvid = $bvid;
$video_pivot->start_part = $match["part"]; $video_pivot->start_part = $match["part"];
$video_pivot->start_time = $time; $video_pivot->start_time = $time;
$video_pivot->stop_part = $match["part"];
$program->save(); $program->save();
$program->video_pivots()->save($video_pivot); $program->video_pivots()->save($video_pivot);
} }

View File

@ -32,7 +32,6 @@ class ProgramVideoConstructController extends BaseController
"stop_part" => ["required", "int", "gte:start_part"], "stop_part" => ["required", "int", "gte:start_part"],
"start_time" => ["required", "date_format:H:i:s"], "start_time" => ["required", "date_format:H:i:s"],
"stop_time" => ["required", "date_format:H:i:s"], "stop_time" => ["required", "date_format:H:i:s"],
"created_at" => ["date"],
]); ]);
$program_video = new ProgramVideos(); $program_video = new ProgramVideos();
$createPayload = $request->only(["start_part", "start_time", "stop_part", "stop_time"]); $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->created_at = $request->post("created_at");
} }
$program->video_pivots()->save($program_video); $program->video_pivots()->save($program_video);
ProgramVideoUtil::fix_created_at_by_part_info($program_video->video_bvid);
return redirect(route("program.construct.video.list", [ return redirect(route("program.construct.video.list", [
"program"=>$program_video->program_id "program"=>$program_video->program_id
])); ]));

View File

@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model;
/** /**
* @property \Carbon\Carbon $duration * @property \Carbon\Carbon $duration
* @property int $part_num
*/ */
class VideoParts extends Model class VideoParts extends Model
{ {

View File

@ -80,10 +80,15 @@ class ProgramVideoUtil
$base_time, $base_time,
$start_time->secondsSinceMidnight() $start_time->secondsSinceMidnight()
); );
if ($cur_part->duration->diffInMinutes($start_time) < 20) { if (!$program_video->stop_part) {
$program_video->stop_part += 1; // 没有再去修复
if ($program_video->stop_part > $video_parts->pluck("part_num")->max()) { if ($cur_part->duration->diffInMinutes($start_time) < 20) {
$program_video->stop_part = $video_parts->pluck("part_num")->max(); $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(); $program_video->save();

View File

@ -28,10 +28,6 @@
@endif @endif
<input class="form-input border-0 border-b-2 w-full" type="file" name="start_image"> <input class="form-input border-0 border-b-2 w-full" type="file" name="start_image">
</label> </label>
<label class="block my-2">
节目开打时间
<input class="form-input border-0 border-b-2 w-full" type="datetime-local" step="1" name="created_at" value="{{ old("created_at", $program_video->created_at) }}">
</label>
<label class="block my-2"> <label class="block my-2">
结束P数 结束P数
<input class="form-input border-0 border-b-2 w-full" type="number" name="stop_part" value="{{ old("stop_part", $program_video->stop_part) }}"> <input class="form-input border-0 border-b-2 w-full" type="number" name="stop_part" value="{{ old("stop_part", $program_video->stop_part) }}">
@ -61,11 +57,6 @@
href="https://www.bilibili.com/video/{{$program_video->video_bvid}}?p={{$program_video->stop_part}}&t={{$program_video->stop_sec}}" href="https://www.bilibili.com/video/{{$program_video->video_bvid}}?p={{$program_video->stop_part}}&t={{$program_video->stop_sec}}"
title="P{{$program_video->stop_part}}#{{$program_video->stop_time}}" title="P{{$program_video->stop_part}}#{{$program_video->stop_time}}"
>打开至结束位置</a> >打开至结束位置</a>
@if($program_video->created_at)
<a class="px-6 py-2 inline-block rounded-full bg-cyan-600 text-white"
href="{{ url(route("program.construct.video.manual_fix_created_at.view", ["program_video" => $program_video->id])) }}"
>手动修复开打时间</a>
@endif
@if($program_video->video->parts()->count() > 0) @if($program_video->video->parts()->count() > 0)
<a class="px-6 py-2 inline-block rounded-full bg-cyan-600 text-white" <a class="px-6 py-2 inline-block rounded-full bg-cyan-600 text-white"
href="{{ url(route("program.construct.video.auto_fix_created_at", ["bvid" => $program_video->video_bvid])) }}" href="{{ url(route("program.construct.video.auto_fix_created_at", ["bvid" => $program_video->video_bvid])) }}"