Skip to content

Instantly share code, notes, and snippets.

@penryu
Created June 3, 2010 18:26
Show Gist options
  • Save penryu/424268 to your computer and use it in GitHub Desktop.
Save penryu/424268 to your computer and use it in GitHub Desktop.
# 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