nicolabotta writes

Not really an issue with upmpdcli, but a side effect: I was writing a script to create a symlink to the booklet of the currently playing album on an http server and I realized that, when mpd is controlled by an mpd client, the output of

mpc current --format '%file%'

is fine. For instance, I get something like

nicola@fitpc3:~/bin$ mpc current --format '%file%'
data/Alfred Brendel/Schubert Piano Sonatas D575, 894, 959 & 960/01 - Schubert - Piano Sonata No.18 in G, D.894 - 1. Molto moderato e cantabile.flac

which is what I expect and which I can pass to dirname. However, when mpd is controlled by upmpdcli, the output for the same file is

nicola@fitpc3:~/bin$ mpc current --format '%file%'
http://192.168.178.101:9790/minimserver/*/data/Alfred*20Brendel/Schubert*20Piano*20Sonatas*20D575,*20894,*20959*20*26*20960/01*20-*20Schubert*20-*20Piano*20Sonata*20No.18*20in*20G,*20D.894*20-*201.*20Molto*20moderato*20e*20cantabile.flac

which is pretty unusable for a script that works fine with pure mpd, something like:

#!/bin/sh

EXPECTED_NARGS=0
srcdir="/home/me/share/audio"
tgtdir="/mnt/hdd3/share/audio"
tmpsymlink="/home/me/tmp/booklet.pdf"

tgtsymlink="rpi:$tgtdir/booklet.pdf"

if [ $# -ne $EXPECTED_NARGS ]
then
    echo "Usage: `basename $0`"
else
    src="$srcdir/$(dirname "$(mpc current --format '%file%')")/booklet.pdf"
    if [ -f "$src" ]
    then
        rm -f "$tmpsymlink"
        tgt="$tgtdir/$(dirname "$(mpc current --format '%file%')")/booklet.pdf"
        ln -s "$tgt" "$tmpsymlink"
        rsync -lptgo --rsh="/usr/bin/sshpass -p MYPASSWD ssh -o StrictHostKeyChecking=no -l me" "$tmpsymlink" "$tgts\
ymlink"
    fi
fi

Thus, the question is whether there is a way for getting a clean output of the file which is actually played — something I can apply dirname to — when mpd is controlled by upmpdcli? Any ideas?

Thanks, Nicola

medoc92 writes

On Mon, 08 Feb 2016 14:19:45 -0800, nicolabotta notifications@github.com wrote:

> Not really an issue with upmpdcli, but a side effect: I was writing a script to create a symlink to the booklet of the currently playing album on an http server and I realized that, when mpd is controlled by an mpd client, the output of
>
>
 > mpc current --format '%file%'
 >
>
> is fine For instance, I get something like
>
>
 > nicola@fitpc3:~/bin$ mpc current --format '%file%'
 > data/Alfred Brendel/Schubert Piano Sonatas D575, 894, 959 & 960/01 - Schubert - Piano Sonata No18 in G, D894 - 1 Molto moderato e cantabileflac
 >
>
> which is what I expect and which I can pass to dirname However, when mpd is controlled by upmpdcli, the output for the same file is
>
>
 > nicola@fitpc3:~/bin$ mpc current --format '%file%'
 > http://192168178101:9790/minimserver/*/data/Alfred*20Brendel/Schubert*20Piano*20Sonatas*20D575,*20894,*20959*20*26*20960/01*20-*20Schubert*20-*20Piano*20Sonata*20No18*20in*20G,*20D894*20-*201*20Molto*20moderato*20e*20cantabileflac
 >
>
> which is pretty unusable for a script that works fine with pure mpd, something like:

Hi,

Unfortunately, the URL is all that upmpdcli knows about the file, it is determined by the upnp server, and should be considered opaque. With some servers like minidlna it is all numbers and not even persistent (the one for a given track may change after minidlna regenerates its db).

So, nope, no go. It ennoys me too because it means that it is pretty impossible to manage playlists except on the content server itself.

Minim URLs are persistent though.

Cheers,

If

>
 > #!/bin/sh
 >
 > EXPECTED_NARGS=0
 > srcdir="/home/me/share/audio"
 > tgtdir="/mnt/hdd3/share/audio"
 > tmpsymlink="/home/me/tmp/bookletpdf"
 >
 > tgtsymlink="rpi:$tgtdir/bookletpdf"
 >
 > if [ $# -ne $EXPECTED_NARGS ]
 > then
 >     echo "Usage: `basename $0`"
 > else
 >     src="$srcdir/$(dirname "$(mpc current --format '%file%')")/bookletpdf"
 >     if [ -f "$src" ]
 >     then
 >         rm -f "$tmpsymlink"
 >         tgt="$tgtdir/$(dirname "$(mpc current --format '%file%')")/bookletpdf"
 >         ln -s "$tgt" "$tmpsymlink"
 >         rsync -lptgo --rsh="/usr/bin/sshpass -p MYPASSWD ssh -o StrictHostKeyChecking=no -l me" "$tmpsymlink" "$tgts\
 > ymlink"
 >     fi
 > fi
 >
>
> Thus, the question is whether there is a way for getting a clean output of the file which is actually played -- something I can apply `dirname` to -- when mpd is controlled by upmpdcli? Any ideas?
>
> Thanks,
> Nicola
>
> ---
>
> Reply to this email directly or view it on GitHub:
> https://www.lesbonscomptes.com/upmpdcli/github-issues/upmpdcli-html/issue-27.html

nicolabotta writes

The funny thing is that, with Minimserver and Bubble UPnP, the problem of opening a .pdf reader with the album booklet is almost (but not quite) solved:

Tapping the cover art in the "Playing now" field of Bubble UPnP displays a list of metadata of the currently playing item. In particular, it displays its URL tag! One can tap the URL and open it in firefox or chrome. By manually replacing

http://192168178101:9790/minimserver/*/data/Alfred*20Brendel/Schubert*20Piano*20Sonatas*20D575,*20894,*20959*20*26*20960/01*20-*20Schubert*20-*20Piano*20Sonata*20No18*20in*20G,*20D894*20-*201*20Molto*20moderato*20e*20cantabileflac

with

http://192168178101:9790/minimserver/*/data/Alfred*20Brendel/Schubert*20Piano*20Sonatas*20D575,*20894,*20959*20*26*20960/booklet.pdf

in the browser’s navigation bar, one can open the booklet of the currently playing album assuming this is stored in the same directory as booklet.pdf.

This works fine and the only thing that would be needed to be able to access the booklet at a fingertip would be to automatize the above substitution.

medoc92 writes

If you are willing to work with something which is not guaranteed by a standard an might change in the future, why not transform the URL inside your script and use wget or curl to fetch it ?

nicolabotta writes

If you are willing to work with something which is not guaranteed by a standard an might change in the future, why not transform the URL inside your script and use wget or curl to fetch it ?

Right, this is the approach I was following when I realized that the output of mpc is quite different when mpd runs under the control of upmpdcli.

It is still a viable approach, of course. But I would have to massage the output of mpc a little bit more and make upmpdcli run the script (via onplay or onstart?) every time a new item is replayed. This is a little waste of resources. On the Android tablet, I would have to open a fixed web page containing the booklet or a symlink to it.

An alternative approach would be to open the URL displayed by Bubble UPnP on the Android tablet

whenever I want to access the booklet. This would require an Android script that substitutes the track specific .flac file with booklet.pdf. It would be a better solution but I have absolutely no idea how to write even the simplest Android script. I’ll probably take a look at that.

Best, Nicola

medoc92 writes

Closing because there does not seem to be anything to fix in upmpdcli here.