-
-
Save flawiddsouza/d9f24d2061ac6b3a7f76f30f0c063e86 to your computer and use it in GitHub Desktop.
Updated LyricsFetch.rb
This file contains hidden or 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
# from https://gist.github.com/Sidysky/11354662 | |
require 'open-uri' | |
puts "Artist:" | |
artist = $stdin.gets.chomp | |
artist = artist.delete " " | |
puts "Song Name:" | |
song = $stdin.gets.chomp | |
song = song.delete " " | |
url = "http://www.azlyrics.com/lyrics/" | |
url << artist.downcase | |
url << "/" | |
url << song.downcase.gsub("'", '') # gsub to remove single quotes from song title | |
url << ".html" | |
puts url | |
page_content = open(url).read | |
debut = page_content.index('<!-- Usage of azlyrics.com content by any third-party lyrics provider is prohibited by our licensing agreement. Sorry about that. -->') | |
fin = page_content.index('<br><br>') | |
debut = debut + 133 | |
fin = fin - 11 | |
lyrics = page_content[debut..fin] | |
lyrics = lyrics.gsub "<br>", " " | |
puts lyrics |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment