Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function extract_XML_value() {
- # $1 entity name
- # $2 string to find
- echo -n "$2" | egrep -o "<$1>[^<]+" | sed -e "s/<$1>//"
- }
- artist=`mpc -f '%artist%' current | sed -e "s/\\ /+/g"`
- album=`mpc -f '%album%' current | sed -e "s/\\ /+/g"`
- lastfm_key="5c74acc7a4b3db44a25e75ff8fc89543"
- url="ws.audioscrobbler.com"
- path="/2.0/?method=album.getinfo&api_key=$lastfm_key&artist=$artist&album=$album"
- f_image_extralarge="$artist""_""$album""_""xl.png"
- image_dir="/home/xqwutaitezr/music/covers"
- function retrieve () {
- _ret=$(wget "$url$path" -O -)
- mkdir -p $image_dir
- image_extralarge=$(extract_XML_value 'image size="extralarge"' "$_ret" 2>/dev/null)
- [[ "$image_extralarge" != "" ]] && [[ ! -f "$image_dir/$f_image_extralarge" ]] && wget "$image_extralarge" -O "$image_dir/$f_image_extralarge" > /dev/null
- }
- if [[ $(mpc status | grep "playing" | wc -l ) -gt 0 ]]
- then
- if [[ ! -f "$image_dir/$f_image_extralarge" ]]
- then
- retrieve
- fi
- ahoviewer $image_dir/$f_image_extralarge &
- fi
- echo $f_image_extralarge
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement