diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb
index 8f024c1c6..0ee83e839 100644
--- a/app/helpers/courses_helper.rb
+++ b/app/helpers/courses_helper.rb
@@ -238,7 +238,9 @@ module CoursesHelper
# 获取课堂的资源数
def get_attachment_count(course, category_id)
- category_id.to_i == 0 ? course.attachments.size : course.attachments.where(course_second_category_id: category_id).size
+ identity = current_user.course_identity(course)
+ attachments = category_id.to_i == 0 ? course.attachments : course.attachments.where(course_second_category_id: category_id)
+ identity > Course::ASSISTANT_PROFESSOR ? attachments.published.size : attachments.size
end
# 获取课堂的视频数
diff --git a/app/libs/aliyun_vod/service/base.rb b/app/libs/aliyun_vod/service/base.rb
index ebbcce694..f10f079b4 100644
--- a/app/libs/aliyun_vod/service/base.rb
+++ b/app/libs/aliyun_vod/service/base.rb
@@ -23,6 +23,7 @@ module AliyunVod::Service::Base
result
rescue => ex
::Util.logger_error(ex)
+ ""
#raise AliyunVod::Error, ex.message
end
diff --git a/app/libs/aliyun_vod/service/video_manage.rb b/app/libs/aliyun_vod/service/video_manage.rb
index ef8e707b3..f80f31788 100644
--- a/app/libs/aliyun_vod/service/video_manage.rb
+++ b/app/libs/aliyun_vod/service/video_manage.rb
@@ -26,7 +26,7 @@ module AliyunVod::Service::VideoManage
result
end
- # 读取视频编码格式
+ # 读取视频编码格式与视频格式
def get_meta_code_info(video_id)
params = {
Action: 'GetMezzanineInfo',
@@ -36,11 +36,14 @@ module AliyunVod::Service::VideoManage
result = request(:post, params)
Rails.logger.info("#######:#{result['Mezzanine']['VideoStreamList'][0]['CodecName']}")
- result['Mezzanine']['VideoStreamList'][0]['CodecName']
+ codecnamne = result['Mezzanine']['VideoStreamList'].first['CodecName']
+ file_url = result['Mezzanine']['FileURL']
+ format = file_url&.split(".")&.last
+ {codecnamne: codecnamne, format: format}
rescue => e
Rails.logger.info "读取视频编码信息失败: #{video_id}, #{e.message}"
- ""
+ {codecnamne: "", format: ""}
end
# 删除视频信息
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index 3ff9a6a90..1a9b50c3b 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -24,6 +24,7 @@ class Attachment < ApplicationRecord
scope :simple_columns, -> { select(:id, :filename, :filesize, :created_on, :cloud_url, :author_id, :content_type, :container_type, :container_id) }
scope :search_by_container, -> (ids) {where(container_id: ids)}
scope :unified_setting, -> {where("unified_setting = ? ", 1)}
+ scope :published, -> {where(is_publish: 1)}
validates_length_of :description, maximum: 100, message: "不能超过100个字符"
diff --git a/app/services/videos/batch_publish_service.rb b/app/services/videos/batch_publish_service.rb
index cad8cfbd9..553ffe4f2 100644
--- a/app/services/videos/batch_publish_service.rb
+++ b/app/services/videos/batch_publish_service.rb
@@ -29,14 +29,14 @@ class Videos::BatchPublishService < ApplicationService
video.status = "published"
end
- # 标清转码为h264
+ # 非MP4 H264编码的都转码
code_info = AliyunVod::Service.get_meta_code_info(video.uuid)
- if code_info.present? && code_info.start_with?('h264', 'h265')
+ Rails.logger.info("code_info: #{code_info[:format]}, #{code_info[:codecnamne]}")
+ if code_info[:format] == "mp4" && code_info[:codecnamne].present? && code_info[:codecnamne].start_with?('h264')
video.transcoded = true
- #Rails.logger.info("####video.uuid:#{video.uuid}")
- #result = AliyunVod::Service.get_play_info(video.uuid)
- # Rails.logger.info("####video.result:#{result}")
- #video.play_url = result['PlayInfoList']['PlayInfo'][0]['PlayURL']
+ result = AliyunVod::Service.get_play_info(video.uuid) rescue nil
+ play_url = result['PlayInfoList']['PlayInfo'].first['PlayURL'] if result.present?
+ video.play_url = play_url
else
AliyunVod::Service.submit_transcode_job(video.uuid, Video::NORMAL_TRANSCODE_GROUP_ID)
end
diff --git a/app/services/videos/dispatch_callback_service.rb b/app/services/videos/dispatch_callback_service.rb
index 2e3d85987..4ff94a1c4 100644
--- a/app/services/videos/dispatch_callback_service.rb
+++ b/app/services/videos/dispatch_callback_service.rb
@@ -18,9 +18,7 @@ class Videos::DispatchCallbackService < ApplicationService
video.save!
when 'SnapshotComplete' then # 封面截图完成
return if video.cover_url.present?
- result = AliyunVod::Service.get_play_info(video.uuid) rescue nil
- play_url = result['PlayInfoList']['PlayInfo'][0]['PlayURL'] if result
- video.update!(cover_url: params['CoverUrl'], play_url: play_url)
+ video.update!(cover_url: params['CoverUrl'])
when 'StreamTranscodeComplete' then # 转码完成
#return if video.play_url.present?
video.update!(play_url: params['FileUrl'], transcoded: true)
diff --git a/lib/gitlab-cli/.rakeTasks b/lib/gitlab-cli/.rakeTasks
index ea716fd52..f349995e9 100644
--- a/lib/gitlab-cli/.rakeTasks
+++ b/lib/gitlab-cli/.rakeTasks
@@ -4,4 +4,4 @@ You are allowed to:
1. Remove rake task
2. Add existing rake tasks
To add existing rake tasks automatically delete this file and reload the project.
--->