summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 32f9124)
raw | patch | inline | side by side (parent: 32f9124)
author | Andy Spencer <andy753421@gmail.com> | |
Tue, 24 Nov 2009 15:51:06 +0000 (15:51 +0000) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 24 Nov 2009 16:07:04 +0000 (17:07 +0100) |
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.
This also caches the lyrics in ~/.lyrics so that they are later retrieved by
the hd.sh plugin.
Makefile.am | patch | blob | history | |
lyrics/15-leoslyrics.sh | [new file with mode: 0755] | patch | blob |
diff --git a/Makefile.am b/Makefile.am
index 1fdb6167d9bffb251551efcc8d4ac9c5a2511275..50003aa5fd852573e67cbc05856b32238cd4346d 100644 (file)
--- a/Makefile.am
+++ b/Makefile.am
# 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
--- /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 '
+ /<text>/ { go=1; sub(".*<text>", "") };
+ /<\/text>/ { go=0; sub("</text>.*", "") };
+ go { sub("
", ""); print };
+' | tee "$cache"