From 81de79240842e393a3c085d9d7813ae53e942c35 Mon Sep 17 00:00:00 2001 From: anke1460 Date: Thu, 19 Mar 2020 02:46:36 +0800 Subject: [PATCH] fix --- app/services/videos/batch_publish_service.rb | 4 ++-- lib/tasks/get_video_data.rake | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/services/videos/batch_publish_service.rb b/app/services/videos/batch_publish_service.rb index 1c3795102..3ddc54967 100644 --- a/app/services/videos/batch_publish_service.rb +++ b/app/services/videos/batch_publish_service.rb @@ -31,7 +31,7 @@ class Videos::BatchPublishService < ApplicationService # 非MP4 H264编码的都转码 code_info = AliyunVod::Service.get_meta_code_info(video.uuid) - + result = AliyunVod::Service.get_play_info(video.uuid) rescue nil 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') @@ -45,7 +45,7 @@ class Videos::BatchPublishService < ApplicationService end if result.present? - video.duration = result["VideoBase"]["Duration"] if result["VideoBase"]["Duration"] + video.duration = result['PlayInfoList']['PlayInfo'][0]['Duration'] if result['PlayInfoList']['PlayInfo'][0]['Duration'].present? end video.save! diff --git a/lib/tasks/get_video_data.rake b/lib/tasks/get_video_data.rake index 3de199502..efb89e99e 100644 --- a/lib/tasks/get_video_data.rake +++ b/lib/tasks/get_video_data.rake @@ -80,9 +80,9 @@ namespace :video do videos = Video.published.where("duration = 0") videos.find_each do |v| result = AliyunVod::Service.get_play_info(v.uuid) - if result.present? && result["VideoBase"]["Duration"].present? - p '-----#{v.id} , #{result["VideoBase"]["Duration"]]}' - v.update(duration: result["VideoBase"]["Duration"]) + if result.present? && result['PlayInfoList']['PlayInfo'][0]['Duration'].present? + p "-----#{v.id} , #{result['PlayInfoList']['PlayInfo'][0]['Duration']}" + v.update(duration: result['PlayInfoList']['PlayInfo'][0]['Duration']) end end