From: Andrew Timberlake Date: 2009-01-14T12:15:16+09:00 Subject: Re: Downloading an MP3 from the internet ------=_Part_356346_18688994.1231902965349 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Wed, Jan 14, 2009 at 3:15 AM, Nathaniel Escribano wrote: > I am trying to write a simple script that downloads a music file from the > internet. > For example: if i want to download > > http://cdn.stereogum.com/mp3/My%20Morning%20Jacket%20-%20Celebration%20(Live).mp3 > how exactly would you do it? > > I found someone who was able to download a flickr photo using this script: > > require 'net/http' > > Net::HTTP.start("farm1.static.flickr.com") { |http| > resp = http.get("/92/218926700_ecedc5fef7_o.jpg") > open("fun.jpg", "wb") { |file| > file.write(resp.body) > } > } > puts 'Downloaded' > > With a slight modification shouldn't this work for the music file? > What makes downloading a photo any different than an mp3 file? > > require 'net/http' > > Net::HTTP.start("cdn.stereogum.com") { |http| > resp = http.get("/mp3/My Morning Jacket - Celebration (Live).mp3") > open("Celebration.mp3", "wb") { |file| > file.write(resp.body) > } > } > puts "the song has been downloaded" > > Why doesn't it work? What needs to be changed? > Any help would be great! Thanks. > Probably because you're not encoding the path -- Andrew Timberlake http://ramblingsonrails.com http://www.linkedin.com/in/andrewtimberlake "I have never let my schooling interfere with my education" - Mark Twain ------=_Part_356346_18688994.1231902965349--