Skip to content

Instantly share code, notes, and snippets.

@koduki
Created June 27, 2010 04:06
Show Gist options
  • Save koduki/454627 to your computer and use it in GitHub Desktop.
Save koduki/454627 to your computer and use it in GitHub Desktop.
#!/bin/env ruby
## -*- coding: utf-8 -*-
#
require 'open-uri'
require 'nokogiri'
def name url
"/music/ふぃあ通/" + url.split("/").last
end
html = Nokogiri(open('http://www.fear.co.jp/radio/fearradio.htm').read)
urls = html.search("//a[contains(@href, '.asx')]/@href")
urls
.map{|url| "http://www.fear.co.jp/radio/" + url.to_s }
.map{|url| open(url).read.force_encoding("sjis").encode('utf-8')}
.map{|asx| Nokogiri(asx)}
.map{|html| html.at("//ref/@href").to_s}
.each{|url| FileUtils.mv(open(url), open(name(url),"w"))}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment