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
-