Created
March 1, 2017 03:56
-
-
Save foodforarabbit/a884889587cee421d2e7c303d20cf011 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# brightcove via brightcove-api to s3 via carrierwave / fog | |
total = Model.count | |
Model.all.each_with_index do |model, idx| | |
puts model.id | |
puts idx.to_f / total | |
if model.brightcove_id | |
puts model.brightcove_id | |
brightcove_service = BrightcoveService.new({:brightcove_video_id => model.brightcove_id}) | |
result = brightcove_service.search_brightcove_for_video_renditions | |
rendition = result["renditions"].select{|x| x["videoContainer"] == "MP4"}.sort_by{|x| x["encodingRate"]}.last | |
url = rendition["url"] | |
unless url.empty? | |
model.remote_s3video_url = url | |
if model.save | |
model.brightcove_id = nil | |
model.save | |
end | |
end | |
end | |
puts model.id | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment