From f1f0658e5376ec407907070a58d85e13d51b23a1 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 6 Feb 2020 19:27:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/get_video_data.rake | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/tasks/get_video_data.rake b/lib/tasks/get_video_data.rake index 7908a133c..05c33fb27 100644 --- a/lib/tasks/get_video_data.rake +++ b/lib/tasks/get_video_data.rake @@ -45,13 +45,18 @@ namespace :video do task :get_play_url => :environment do Video.all.each do |video| - result = AliyunVod::Service.get_play_info(video.uuid) - puts result - play_url = result["PlayInfoList"]["PlayInfo"].first["PlayURL"] - puts play_url - # play_url = (result.dig('PlayInfoList', 'PlayInfo') || []).first&.[]('PlayURL') + if video.uuid.present? - video.update!(play_url: play_url) if play_url.present? + end + result = AliyunVod::Service.get_play_info(video.uuid) rescue nil + if result.present? && result["PlayInfoList"]["PlayInfo"].present? + puts result + play_url = result["PlayInfoList"]["PlayInfo"].first["PlayURL"] + puts play_url + # play_url = (result.dig('PlayInfoList', 'PlayInfo') || []).first&.[]('PlayURL') + + video.update!(play_url: play_url) if play_url.present? + end end end end \ No newline at end of file