Skip to content

Instantly share code, notes, and snippets.

@jamiecobbett
Created March 16, 2012 18:00
Show Gist options
  • Save jamiecobbett/2051518 to your computer and use it in GitHub Desktop.
Save jamiecobbett/2051518 to your computer and use it in GitHub Desktop.
Do you feel the need to hear the memorable intro from Beats International's "Dub Be Good To Me", but don't want to use YouTube or a silly MP3?
require 'rubygems'
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML.parse(open("http://www.songmeanings.net/songs/view/101453/"))
doc.css('script').remove
song_text_node = doc.at("#songText2")
lines_by_paragraph = song_text_node.inner_html.gsub(/\n/, "").split(/<br><br>/).map do |paragraph|
paragraph.split(/<br>/)
end
lines_by_paragraph.each do |paragraph|
paragraph.reject! do |line|
line =~/\[chorus:?\]/i
end
end
beats_international_intro = lines_by_paragraph[0]
`say "#{beats_international_intro.join(" ")}"`
@jamiecobbett
Copy link
Author

Would have been shorter and simpler if I had been willing to accept the first verse in with the intro

@jamiecobbett
Copy link
Author

Known bugs:

  • Ruby 1.8.7 not supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment