blob: 190e41371934346a97d8f39088e9416bf5c69339 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#!/bin/sh
export GOOGLYRICS=/usr/share/apps/amarok/scripts/googlyrics/googlyrics
rm -f "$3"
txtfound=0
artist=`echo $1 | sed 's/ /%20/'g`
title=`echo $2 | sed 's/ /%20/'g`
if test ! -x $GOOGLYRICS
then
echo $GOOGLYRICS nicht gefunden > $3
exit 2
fi
export success=0
echo fetchLyrics $artist $title | $GOOGLYRICS 2>&1 |
sed 's/\x0d//g' |
sed 's/\xc2\xb4/\x27/g' |
sed 's/\xc3\x82\x27/\x27/g' |
sed 's/\xc3\x82/\x27/g' |
sed 's/\xc3\xb9/\x27/g' |
sed 's/\xe2\x80\x99/\x27/g' |
grep -ive 'NEW.*ringtones' |
grep -v '--------------' |
recode HTML..utf8 |
sed 's/\xc2\x91/\x27/g' | # in unicode, those two are reserved for
sed 's/\xc2\x92/\x27/g' | # private use, but still some sites use them...
while read line
do
# did we find a text yet?
if expr "$line" : '<br>Regex success' >/dev/null 2>&1
then
success=1
continue
fi
# googlyrics tries to send the finished text to amarok:
if expr "$line" : 'object not accessible' >/dev/null 2>&1
then
killall googlyrics >/dev/null 2>&1
break
fi
# googlyrics starts main loop again:
if expr "$line" : '.*scalar chomp.*STDIN' >/dev/null 2>&1
then
killall googlyrics >/dev/null 2>&1
break
fi
test $success = 0 && continue
# suppress other googlyrics error messages
expr "$line" : '.*'$GOOGLYRICS >/dev/null 2>&1 && continue
notempty=0
test x"$line" = x || notempty=1;
test $notempty -eq 1 && txtfound=1;
test $txtfound -eq 1 && echo $line
done > "$3".loading 2>/dev/null
# use .loading because the file is already there when googlyrics starts
# but muggle thinks we are done as soon as $3 exists
if test -s "$3".loading
then
mv "$3".loading "$3"
else
rm -f "$3".loading
fi
test -s "$3" # we want the exit code
|