Last active
May 9, 2016 04:54
-
-
Save olimagsax/11354662 to your computer and use it in GitHub Desktop.
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
#This is a little script for fetching lyrics :D | |
#LyricsFetch by Sidysky | |
require 'open-uri' | |
require 'colorize.rb' | |
puts "Artiste :".blue | |
artist = $stdin.gets.chomp | |
artist = artist.delete " " | |
puts "Chanson :".blue | |
song = $stdin.gets.chomp | |
song = song.delete " " | |
url = "http://www.azlyrics.com/lyrics/" | |
url << artist.downcase | |
url << "/" | |
url << song.downcase | |
url << ".html" | |
puts url | |
page_content = open(url).read | |
debut = page_content.index('<!-- start of lyrics -->') | |
fin = page_content.index('<!-- end of lyrics -->') | |
debut = debut + 24 | |
fin = fin - 1 | |
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