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