Switch from wikia to songlyrics.com

This commit is contained in:
Jaidyn Levesque 2019-12-09 12:29:17 -06:00
parent 747a1ba236
commit 28aac003d2
2 changed files with 25 additions and 14 deletions

View File

@ -2,9 +2,11 @@
WYRICS Git some lyrics 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. You can fetch them by search queries, or by their URL.
This used to use lyrics.wikia.com, but that's defunct now. ;c
---------------------------------------- ----------------------------------------

35
wyrics
View File

@ -2,7 +2,7 @@
######################################## ########################################
# name: wyrics # name: wyrics
# desc: fetch lyrics by URL or query # desc: fetch lyrics by URL or query
# from lyrics.fandom.com # from songlyrics.com
# main: Jaidyn Ann # main: Jaidyn Ann
# <jadedctrl@teknik.io> # <jadedctrl@teknik.io>
# lisc: CC 0 # lisc: CC 0
@ -71,9 +71,10 @@ function search {
local query="$1" local query="$1"
local query="$(echo "$query" | sed 's/ /+/g')" local query="$(echo "$query" | sed 's/ /+/g')"
gendl "https://lyrics.fandom.com/wiki/Special:Search?query=${query}" \ gendl "https://songlyrics.com/index.php?section=search&searchW=${query}" \
| sed '1,/Results/d' \ | sed '1,/serpresult/d' \
| grep "result-link" \ | grep "title=" \
| grep -v "<h3" \
| search_parse | search_parse
} }
@ -90,10 +91,10 @@ function search_parse {
i=$(add $i 1) i=$(add $i 1)
local url="$(echo "$line" \ local url="$(echo "$line" \
| sed 's/.*href=\"//' \ | sed 's/.*href=\"//' \
| sed 's/\" class.*//')" | sed 's/\".*//')"
local title="$(echo "$line" \ local title="$(echo "$line" \
| sed 's%.*">%%' \ | sed 's%.*title="%%' \
| sed 's%</a>%%')" | sed 's%".*%%')"
if echo "$title" | grep "http" > /dev/null; then if echo "$title" | grep "http" > /dev/null; then
i=$(subtract $i 1) i=$(subtract $i 1)
@ -181,15 +182,23 @@ function result_choose {
# -------------------------------------- # --------------------------------------
function blank_lines {
local html="$(reade)"
echo "$html" \
| sed 's%^<br />%<p></p>%' \
| sed 's%^<br/>%<p></p>%'
}
# STRING --> STRING # STRING --> STRING
# return the lyrics of a given URL # return the lyrics of a given URL
function lyrics { function lyrics {
local url="$1" local url="$1"
gendl "$url" \ gendl "$url" \
| grep "class=\'lyricbox" \ | sed '1,/iComment-text">/d' \
| sed 's/.*lyricbox.>//' \ | sed '/<\/div>/,$d' \
| sed 's/;<div.*//' \ | blank_lines \
| lynx -stdin -dump \ | lynx -stdin -dump \
| sed 's/^ //g' | sed 's/^ //g'
} }
@ -221,8 +230,8 @@ case "$1" in
lyrics "$url" lyrics "$url"
;; ;;
# *) # # *)
# usage # # usage
# ;; # # ;;
esac esac