Skip to content

Instantly share code, notes, and snippets.

@flawiddsouza
Forked from olimagsax/LyricsFetch.rb
Last active May 9, 2016 05:15
Show Gist options
  • Save flawiddsouza/d9f24d2061ac6b3a7f76f30f0c063e86 to your computer and use it in GitHub Desktop.
Save flawiddsouza/d9f24d2061ac6b3a7f76f30f0c063e86 to your computer and use it in GitHub Desktop.

Revisions

  1. flawiddsouza revised this gist May 9, 2016. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions LyricsFetch.rb
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@
    url = "http://www.azlyrics.com/lyrics/"
    url << artist.downcase
    url << "/"
    url << song.downcase
    url << song.downcase.gsub("'", '') # gsub to remove single quotes from song title
    url << ".html"

    puts url
    @@ -23,8 +23,8 @@
    fin = page_content.index('<br><br>')

    debut = debut + 133
    fin = fin - 1
    fin = fin - 11

    lyrics = page_content[debut..fin]
    lyrics = lyrics.gsub "<br />", " "
    lyrics = lyrics.gsub "<br>", " "
    puts lyrics
  2. flawiddsouza revised this gist May 9, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion LyricsFetch.rb
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@
    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 + 24
    debut = debut + 133
    fin = fin - 1

    lyrics = page_content[debut..fin]
  3. flawiddsouza revised this gist May 9, 2016. 1 changed file with 6 additions and 11 deletions.
    17 changes: 6 additions & 11 deletions LyricsFetch.rb
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,11 @@
    #This is a little script for fetching lyrics :D
    #LyricsFetch by Sidysky

    # from https://gist.github.com/Sidysky/11354662

    require 'open-uri'
    require 'colorize.rb'



    puts "Artiste :".blue

    puts "Artist:"
    artist = $stdin.gets.chomp
    artist = artist.delete " "
    puts "Chanson :".blue
    puts "Song Name:"
    song = $stdin.gets.chomp
    song = song.delete " "

    @@ -24,8 +19,8 @@

    page_content = open(url).read

    debut = page_content.index('<!-- start of lyrics -->')
    fin = page_content.index('<!-- end of lyrics -->')
    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 + 24
    fin = fin - 1
  4. @olimagsax olimagsax revised this gist May 20, 2014. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions LyricsFetch.rb
    Original file line number Diff line number Diff line change
    @@ -3,13 +3,14 @@


    require 'open-uri'
    require 'colorize.rb'



    puts "Artiste :"
    puts "Artiste :".blue
    artist = $stdin.gets.chomp
    artist = artist.delete " "
    puts "Chanson :"
    puts "Chanson :".blue
    song = $stdin.gets.chomp
    song = song.delete " "

  5. @olimagsax olimagsax revised this gist Apr 29, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions LyricsFetch.rb
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    #This is a little script for fetching lyrics :D
    #LyricsFetch by Sidysky


    require 'open-uri'

  6. @olimagsax olimagsax renamed this gist Apr 27, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. @olimagsax olimagsax revised this gist Apr 27, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions LyricsFetch
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    #This is a little script for fetching lyrics :D

    require 'open-uri'


  8. @olimagsax olimagsax created this gist Apr 27, 2014.
    30 changes: 30 additions & 0 deletions LyricsFetch
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    require 'open-uri'



    puts "Artiste :"
    artist = $stdin.gets.chomp
    artist = artist.delete " "
    puts "Chanson :"
    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