From 28aac003d25f2ca30a07cb7ac8be05811778986f Mon Sep 17 00:00:00 2001 From: Jaidyn Levesque Date: Mon, 9 Dec 2019 12:29:17 -0600 Subject: [PATCH] Switch from wikia to songlyrics.com --- README.txt | 4 +++- wyrics | 35 ++++++++++++++++++++++------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/README.txt b/README.txt index 712d49a..6a3c2d2 100644 --- a/README.txt +++ b/README.txt @@ -2,9 +2,11 @@ WYRICS Git some lyrics =============================================================================== -Fetch lyrics for a song from lyrics.fandom.com with this script. +Fetch lyrics for a song from songlyrics.com with this script. You can fetch them by search queries, or by their URL. +This used to use lyrics.wikia.com, but that's defunct now. ;c + ---------------------------------------- diff --git a/wyrics b/wyrics index 9fcd688..2ca47d4 100755 --- a/wyrics +++ b/wyrics @@ -2,7 +2,7 @@ ######################################## # name: wyrics # desc: fetch lyrics by URL or query -# from lyrics.fandom.com +# from songlyrics.com # main: Jaidyn Ann # # lisc: CC 0 @@ -71,9 +71,10 @@ function search { local query="$1" local query="$(echo "$query" | sed 's/ /+/g')" - gendl "https://lyrics.fandom.com/wiki/Special:Search?query=${query}" \ - | sed '1,/Results/d' \ - | grep "result-link" \ + gendl "https://songlyrics.com/index.php?section=search&searchW=${query}" \ + | sed '1,/serpresult/d' \ + | grep "title=" \ + | grep -v "%%' \ - | sed 's%%%')" + | sed 's%.*title="%%' \ + | sed 's%".*%%')" if echo "$title" | grep "http" > /dev/null; then i=$(subtract $i 1) @@ -181,15 +182,23 @@ function result_choose { # -------------------------------------- +function blank_lines { + local html="$(reade)" + + echo "$html" \ + | sed 's%^
%

%' \ + | sed 's%^
%

%' +} + # STRING --> STRING # return the lyrics of a given URL function lyrics { local url="$1" gendl "$url" \ - | grep "class=\'lyricbox" \ - | sed 's/.*lyricbox.>//' \ - | sed 's/;/d' \ + | sed '/<\/div>/,$d' \ + | blank_lines \ | lynx -stdin -dump \ | sed 's/^ //g' } @@ -221,8 +230,8 @@ case "$1" in lyrics "$url" ;; -# *) -# usage -# ;; +# # *) +# # usage +# # ;; esac