Created
April 28, 2016 19:11
-
-
Save matiasgarciaisaia/09f1286ae730b7047d2c679b67690506 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
#!/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