From 98c6201771be9b717d100440a198c200352f7ab9 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Tue, 24 Nov 2009 15:51:06 +0000 Subject: [PATCH] leoslyrics.sh plugin: Add bash leoslyrics plugin Simple version of the Leo's Lyrics plugin that uses bash and wget. This also caches the lyrics in ~/.lyrics so that they are later retrieved by the hd.sh plugin. --- Makefile.am | 2 +- lyrics/15-leoslyrics.sh | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 lyrics/15-leoslyrics.sh diff --git a/Makefile.am b/Makefile.am index 1fdb616..50003aa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -186,7 +186,7 @@ sparse-check: # lyrics plugins # -lyrics_plugins = lyrics/10-hd.sh lyrics/20-lyricwiki.rb lyrics/30-leoslyrics.py +lyrics_plugins = lyrics/10-hd.sh lyrics/15-leoslyrics.sh lyrics/20-lyricwiki.rb lyrics/30-leoslyrics.py if ENABLE_LYRICS_SCREEN diff --git a/lyrics/15-leoslyrics.sh b/lyrics/15-leoslyrics.sh new file mode 100755 index 0000000..7a119bb --- /dev/null +++ b/lyrics/15-leoslyrics.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -e + +search="http://api.leoslyrics.com/api_search.php?auth=ncmpc" +lyrics="http://api.leoslyrics.com/api_lyrics.php?auth=ncmpc" +cache="$HOME/.lyrics/$1 - $2.txt" + +hid=$(wget -q -O- "$search&artist=$1&songtitle=$2" | + sed -n 's/.*hid="\([^"]*\)".*exactMatch="true".*/\1/p' | + head -n 1) + +test "$hid" + +mkdir -p "$(dirname "$cache")" + +wget -q -O- "$lyrics&hid=$hid" | awk ' + // { go=1; sub(".*", "") }; + /<\/text>/ { go=0; sub(".*", "") }; + go { sub(" ", ""); print }; +' | tee "$cache" -- 2.30.2