Skip to content

Instantly share code, notes, and snippets.

@djanatyn
Created May 7, 2012 10:26
Show Gist options
  • Save djanatyn/2627102 to your computer and use it in GitHub Desktop.
Save djanatyn/2627102 to your computer and use it in GitHub Desktop.
stupid ruby script
#!/usr/bin/ruby -w
require 'open-uri'
# 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_url(line)
return line.match(%r{<td align="left"><a href="(.*)">(.*)</a></td>}) ? [$1,$2] : nil
end
open('http://www.zophar.net/music/gbs.html') do |index|
index.each_line do |line|
url = get_url(line)
if url
open(url[0]) do |music_page|
music_page.each_line do |line2|
download = get_url(line2)
if download
`wget '#{download[0]}' -O 'gbs/#{url[1]}.gbs'`
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment