vidpush/app/models/amazon_copy.rb

20 lines
383 B
Ruby
Raw Normal View History

require 'httparty'
require 'tempfile'
class AmazonCopy
def download_video videolisting
file = Tempfile.new ["video_",".mp4"], "#{Rails.root}/tmp"
begin
file.write HTTParty.get(videolisting.get_video_url).parsed_response.force_encoding("utf-8")
file.flush
ensure
file.close
end
file.unlink
end
handle_asynchronously :download_video
end