File: 15-leoslyrics.sh

package info (click to toggle)
ncmpc 0.17-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 2,024 kB
  • ctags: 1,171
  • sloc: ansic: 11,792; sh: 1,178; makefile: 259; python: 61; ruby: 24
file content (21 lines) | stat: -rwxr-xr-x 535 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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("&#xD;", ""); print    };
' | tee "$cache"