Skip to content

Instantly share code, notes, and snippets.

@matiasgarciaisaia
Created April 28, 2016 19:11
Show Gist options
  • Save matiasgarciaisaia/09f1286ae730b7047d2c679b67690506 to your computer and use it in GitHub Desktop.
Save matiasgarciaisaia/09f1286ae730b7047d2c679b67690506 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'sinatra'
require 'tempfile'
set :bind, '0.0.0.0'
get '/' do
source_url = params['q']
puts "Downloading #{source_url} ..."
system("wget -nc #{source_url}")
filename = source_url.split('/')[-1]
dest = Tempfile.new(['audio', '.mp3'])
system("ffmpeg -y #{dest.path} -i #{filename}")
send_file dest.path
dest.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment