Skip to content

Instantly share code, notes, and snippets.

@foodforarabbit
Created March 1, 2017 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foodforarabbit/a884889587cee421d2e7c303d20cf011 to your computer and use it in GitHub Desktop.
Save foodforarabbit/a884889587cee421d2e7c303d20cf011 to your computer and use it in GitHub Desktop.
# 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