Skip to content

Instantly share code, notes, and snippets.

@olimagsax
Last active May 9, 2016 04:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save olimagsax/11354662 to your computer and use it in GitHub Desktop.
Save olimagsax/11354662 to your computer and use it in GitHub Desktop.
#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