Skip to content

Instantly share code, notes, and snippets.

@AliSajid
Forked from djanatyn/get_gameboy_music.rb
Created May 7, 2012 10:31
Show Gist options
  • Save AliSajid/2627128 to your computer and use it in GitHub Desktop.
Save AliSajid/2627128 to your computer and use it in GitHub Desktop.
stupid ruby script
#!/usr/bin/env ruby
require 'net/http'
# looks to see if you're a link to a chiptune
# if so, returns the chiptune url and the name of the chiptune.
# if not, returns nil.
def get_list(url)
uri = URI.parse(url)
response = Net::HTTP.get_response(uri)
list = URI.extract(response.body)
list = list.keep_if {|x| x.to_s.is_album?}
end
def get_album(list)
list.each do |url|
uri = URI.parse(url)
response = Net::HTTP.get_response(uri)
song_list = URI.extract(response.body)
song_list = song_list.keep_if {|x| x.to_s.is_music?}
end
end
def get_song(url)
uri = URI::parse(url)
# Write your own code here to parse the song url. Use the SE file
# writing mwthods to write it to a file.
#
f = open("#{Interpolate File name here}")
begin
http.request_get("#{Interpolate File name here}") do |resp|
resp.read_body do |segment|
f.write(segment)
end
end
ensure
f.close()
end
end
def is_album?
self.include?("/music/gbs")
end
def is_music?
self.include(".gbs")
end
list = get_list("http://www.zophar.net/music/gbs.html")
list.each do |url|
song_list = get_album(url)
song_list.each do |song|
get_song(song)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment