You are not logged in.

#1 2016-07-28 10:36:35

mokman
Member
Registered: 2015-10-27
Posts: 21

trying to fetch cover art from remote mpd

hello!

i am trying to fetch remote cover art from the mpd folder structure.
i manipulated this scipt to my needs but am not able to ls the folderstructure.

#!/bin/bash
IFS=$'\t' mpd_array=( $(MPD_HOST=192.168.0.52 MPD_PORT=6600 \
          mpc --format "\t%artist%\t%album%\t%file%\t") );

filename="conky_cover.png";
placeholder="/home/mok/.config/conky/missingcover.png"

if [[ ! -f /tmp/"${mpd_array[1]}".album ]] ; then
  rm -f /tmp/*.album &> /dev/null;
  >/tmp/"${mpd_array[1]}".album;

  album=`dirname "sftp://pi@192.168.0.52/home/pi/media/berre/Musik/${mpd_array[2]}"`;
  cover=$album"/"`ls $album | egrep "cover.jpg" | head -n 1`;

  if [[ ! -f $cover ]]; then
    cp $placeholder /tmp/$filename;
  else
    convert $cover -resize "280>x" -alpha On -channel A \
                   -evaluate set 25% /tmp/$filename;
  fi
fi

the Music folder is also available over http via lighttpd. maybe someone can point out to me how to do this?

Last edited by mokman (2016-07-28 10:37:39)

Offline

#2 2016-07-28 12:52:41

Awebb
Member
Registered: 2010-05-06
Posts: 6,286

Re: trying to fetch cover art from remote mpd

You are already on the right path. You already have all the tools you need, dirname, the --format %file% switch. Use ...

mpc current --format %file%

... to avoid mpc serving you garbage output you don't need. I'm not sure your array approach is elegant in this case, because it has already mislead you. Then all you need to do, is feed that path to something that fetches the cover, you already know about sftp, you already have a http server. Use sftp, scp, curl, wget, whatever you prefer. I'm not entirely sure, why you're stuck at exactly this spot, because you have basically solved it already:

server path + mpd root = target.

Offline

#3 2016-07-28 15:58:14

mokman
Member
Registered: 2015-10-27
Posts: 21

Re: trying to fetch cover art from remote mpd

thanks for your reply! i indeed finished my task quite fast using wget.

Offline

#4 2016-07-28 16:00:45

Awebb
Member
Registered: 2010-05-06
Posts: 6,286

Re: trying to fetch cover art from remote mpd

That's nice to hear. Care to share the final code?

Offline

Board footer

Powered by FluxBB