From 23305e173846cdcacbe84c185c125c40ad36809b Mon Sep 17 00:00:00 2001 From: koogua Date: Sat, 4 Jun 2022 16:12:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E6=97=B6=E9=95=BF=E8=A1=A5=E5=85=85=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ app/Console/Tasks/VodEventTask.php | 29 ++++++++++++++++++++++++++--- app/Library/AppInfo.php | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e4e1fb8..4d9bf02b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### [v1.5.4](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.4)(2022-06-30) + +- 优化章节排序初始值和步长 + ### [v1.5.3](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.3)(2022-05-30) - 优化章节排序初始值和步长 diff --git a/app/Console/Tasks/VodEventTask.php b/app/Console/Tasks/VodEventTask.php index 5dd243d5..be34f31d 100644 --- a/app/Console/Tasks/VodEventTask.php +++ b/app/Console/Tasks/VodEventTask.php @@ -56,6 +56,13 @@ class VodEventTask extends Task $attrs = $chapter->attrs; + /** + * 获取不到时长,尝试通过接口获得 + */ + if ($duration == 0) { + $duration = $this->getFileDuration($fileId); + } + /** * 获取不到时长视为失败 */ @@ -78,7 +85,7 @@ class VodEventTask extends Task $chapter->update(['attrs' => $attrs]); - $this->updateVodAttrs($chapter); + $this->updateCourseVodAttrs($chapter->course_id); } protected function handleProcedureStateChangedEvent($event) @@ -95,6 +102,13 @@ class VodEventTask extends Task $attrs = $chapter->attrs; + /** + * 获取不到时长,尝试通过接口获得 + */ + if ($attrs['duration'] == 0) { + $attrs['duration'] = $this->getFileDuration($fileId); + } + $processResult = $event['ProcedureStateChangeEvent']['MediaProcessResultSet'] ?? []; /** @@ -156,11 +170,20 @@ class VodEventTask extends Task return $vodService->confirmEvents($handles); } - protected function updateVodAttrs(ChapterModel $chapter) + protected function updateCourseVodAttrs($courseId) { $courseStats = new CourseStatService(); - $courseStats->updateVodAttrs($chapter->course_id); + $courseStats->updateVodAttrs($courseId); + } + + protected function getFileDuration($fileId) + { + $service = new VodService(); + + $metaInfo = $service->getOriginVideoInfo($fileId); + + return $metaInfo['duration'] ?? 0; } } diff --git a/app/Library/AppInfo.php b/app/Library/AppInfo.php index 036f5fac..1ead1181 100644 --- a/app/Library/AppInfo.php +++ b/app/Library/AppInfo.php @@ -16,7 +16,7 @@ class AppInfo protected $link = 'https://koogua.com'; - protected $version = '1.5.2'; + protected $version = '1.5.4'; public function __get($name) {