Artist Info. (РЕШЕНО)

В общем можно ли сделать скрипт или ещё как нибудь чтобы, например при прослушивании в MOC или mpd в conky выводилась информация об исполнителе с Lastfm?

Пока вот всё что нашёл:

http://blog.yjl.im/2010/08/showing-your-lastfm-playcound-and-album.html
http://www.lastfm.ru/api

И ещё видел где то статейку но там про обложку и картинку артиста что тоже желательно.
Вообще нет идей?
Чем не устраивает статья?.. Оно и есть.
Вопрос решён.

выражаю благодарность DsXack за скрипты.

Вот скрипт для MPD.

################
# Settings
CACHE_FILE=/tmp/mpdlastfminfo
HOST=localhost
PORT=6600
MPD_TCP=/dev/tcp/$HOST/$PORT
api_key="ваш API с Lastfm"
#################
# End of Settings
_ret=
song_title=
song_artist=
ARTISTINFO_API="http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&lang=ru&api_key=$api_key"
##################
# Functions
function urlencode() {
        #echo "func:urlencode"
        # http://stackoverflow.com/questions/296536/urlencode-from-a-bash-script
        _ret="$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$1")"
        #echo "endfunc:urlencode"
}
function request() {
        #echo "func:request"
        # $1 command
        exec 5<> $MPD_TCP 2>/dev/null
        [[ $? -gt 0 ]] && return 1
        echo $1 >&5
        echo "close" >&5
        tmp=$(cat <&5)
        exec 5>&-
        # TODO check OK before return
        _ret=$(head -n -1 <<< "$tmp" | tail -n +2)
        return 0
        #echo "endfunc:request"
        }
        
function extract_field() {
        #echo "func:extract_fields"
        # $1 field_name
        # $2 search body
        _ret=$(grep "^$1: " <<< "$2" 2>/dev/null | sed "s/$1: //")
        #echo "endfunc:extract_fields"
        }        
        
function parse_song_info() {
        #echo "func:parsesonginfo"
        request currentsong
        [[ $? -gt 0 ]] && return 1
        _tmp=$_ret
        extract_field "Artist" "$_tmp"
        song_artist=$_ret
        #echo "song_artist = $song_artist"
        #echo "endfunc:parsesonginfo"
        }
        
function get_artist_info() {
        #echo "func:getartistinfo"
        URL="$ARTISTINFO_API"
        #urlencode "$song_artist"
        #[[ "$_ret" != "" ]] && URL="$URL&artist=$_ret"
        URL="$URL&artist=$song_artist"
        _ret=$(wget "$URL" -O -)
        #echo $URL
        #echo $_ret > ./artist_info.xml
        summary=$(echo -n $_ret | sed 's/]]>*.<\/summary>.*$//' | sed 's/.*<summary><!\[CDATA\[//' | sed 's/&quot;//g' | sed 's/<\/a>//g' | sed 's/<a.*>//g' | sed 's/<?xml.*>//' )
        perl ~/.config/openbox/bin/wrap.pl $summary
        }
                
##################
# End of Functions
# CHECK MPD
parse_song_info
if (( $? != 0 )); then
        echo "Something went wrong with MPD!"
        exit 1
fi
parse_time
song_hash="$(echo -n "${song_title}|${song_artist}" | md5sum | head -c 32)"
if [[ ! -f "$CACHE_FILE" ]]; then
        get_artist_info
else
        # Check the cache file
        cache="$(cat "$CACHE_FILE")"
        _song_hash="$(echo -n "$cache" | cut -f 1 -d \ )"
        if [[ "$_song_hash" != "$song_hash" ]]; then
                get_artist_info
        fi
fi

И вот дополнение что бы всё было не водну строку: ( обозвать как wrap.pl и положить в ~/.config/openbox/ )

#!/usr/bin/perl -W
use strict;
use Text::Wrap qw($columns &wrap);
$columns=211;
my $content = join(' ',@ARGV);
print wrap("", "", $content);
print "\n";

Ну и в conky добавить:
${execpi 20 /home/dl11/.config/openbox/bin/lastinfo.sh}


И вот скрин как выглядит это;
http://rghost.ru/3175013/image.png
 
Зарегистрироваться или войдите чтобы оставить сообщение.