Created
June 3, 2010 18:26
-
-
Save penryu/424268 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
# the tags' href is in the form "mm.dd.yy Un-URI-encoded File Title.mp3" | |
MP3_basename = %r{([^/]+)\.mp3$} | |
res = doc.css("a").collect do |node| | |
begin | |
href = node['href'] | |
title = MP3_basename.match(href)[1].sub(/^(\d\d)\.(\d\d)\.\d\d /,'\1-\2 ') | |
node['href'] = "%s/%s" % [BASEHREF, href] | |
node.inner_html = Nokogiri::HTML.fragment(title) # to HTML-encode | |
node | |
rescue | |
nil | |
end | |
end.compact.sort_by {|node| node['href'] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment