Created
January 17, 2016 13:41
-
-
Save nilsding/556d55b2730acc01093b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# fetch_slam.rb - download all mp3s from comeonandsl.am | |
# (c) 2016 nilsding | |
# usage: ./fetch_slam.rb | |
# this script requires the HTTParty gem, install it via `gem install httparty' | |
require 'httparty' | |
require 'cgi' | |
AUDIO_BASE = 'http://comeonandsl.am/audio/' | |
slams = HTTParty.get('http://comeonandsl.am/data/slams.js').body.split(',').select{|x| x.end_with? "mp3\""}.map{|x| x.gsub(/^(?:var rgSlams=\[)?{file:"|"$/, '')} | |
x = 0 | |
slams.each_with_index do |jam, i| | |
File.open File.join(File.expand_path('../', __FILE__), jam), 'wb' do |f| | |
out_str = "[#{i + 1}/#{slams.length}] #{jam}" | |
$stdout.print "#{' ' * x}\r#{out_str}\r" | |
$stdout.flush | |
x = out_str.length | |
f.write HTTParty.get(AUDIO_BASE + CGI.escape(jam)).parsed_response | |
end | |
end | |
puts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment