Make it possible to maintain upmpdcli-radio.conf via Moode’s interface - Printable Version +- Moode Forum (https://moodeaudio.org/forum) +-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3) +--- Forum: Feature requests (https://moodeaudio.org/forum/forumdisplay.php?fid=8) +--- Thread: Make it possible to maintain upmpdcli-radio.conf via Moode’s interface (/showthread.php?tid=741) |
Make it possible to maintain upmpdcli-radio.conf via Moode’s interface - Zigzag - 12-04-2018 I mainly use as a UPnP renderer c/o Upmpdcli. One of Upmpdcli’s features that particularly appeals to me is its ability to stream internet radios, but this is dependent on editing and maintaining ‘upmpdcli-radio.conf’, where the appropriate urls etc. reside. While by no means is this a substantial burden, but Upmpdcli’s radio stations are currently completely freestanding from Moode’s own very good system and the actual process of editing ‘upmpdcli-radio.conf’ is typically done via ssh and requires halting and restarting the Upmpdcli service, which isn’t quick or ideal. I would therefore love to see this process of editing and maintaining ‘upmpdcli-radio.conf’ incorporated into Moode’s own radio listing, as available via its interface. As an idea, if a user had set up Moode to act as a UPnP renderer, and had selected a radio station that featured in Moode’s radio listing but wasn’t included in ‘upmpdcli-radio.conf’, an ‘add radio to UPnP’ option would be available by right clicking the mouse. If this option was chosen, ‘upmpdcli-radio.conf’ would automatically be modified behind the scenes, by appending the appropriate radio station and by also adding the ArtUrl line, so that Upmpdcli will be able to use the same radio station artwork/logo as Moode. Similarly, if the selected radio station was already included in ‘upmpdcli-radio.conf’ a ‘remove radio from UPnP’ would be available instead, and if this was chosen the appropriate references to that radio station would be removed from ‘upmpdcli-radio.conf’. RE: Make it possible to maintain upmpdcli-radio.conf via Moode’s interface - TheOldPresbyope - 12-04-2018 @Zigzag Would it suffice to have a script in moOde which synchronizes the upmpdcli.conf entries with the contents of moOde's Radio directory? It seems to me this approach would involved less fiddling with the UI-related code and less clicking on the part of the user. Just idly musing while waiting for my coffee to finish brewing. Regards, Kent RE: Make it possible to maintain upmpdcli-radio.conf via Moode’s interface - Zigzag - 12-05-2018 Thanks for coming back to me TheOldPresbyope. Yup, your alternative of having a script that synchronizes the entries of upmpdcli.conf with the contents of moOde's Radio directory would more than suffice. My suggestion was OTT - I hope this idea of having a script instead is much easier to implement. RE: Make it possible to maintain upmpdcli-radio.conf via Moode’s interface - TheOldPresbyope - 12-10-2018 (12-05-2018, 10:44 AM)Zigzag Wrote: Thanks for coming back to me TheOldPresbyope. Yup, your alternative of having a script that synchronizes the entries of upmpdcli.conf with the contents of moOde's Radio directory would more than suffice. My suggestion was OTT - I hope this idea of having a script instead is much easier to implement. So I took advantage of some downtime yesterday to explore possibilities for a script. 1. Getting basic station info from the .pls files in moOde's RADIO directory into upmpdcli-radio.conf (referenced by upmpdcli.conf in moOde) is reasonably trivial. Attached is a zip file of the 184 upmpdcli-radio.conf entries---station name and stream URL---I generated for the stations which are in the upcoming r4.4 RADIO directory. I imagine it would be straightforward for Tim to generate the same entries once he has the RADIO directory locked up in the late stages of preparing a moOde image. You could either append these entries to your existing /etc/upmpdcli-radio.conf or replace it with them. Caveat: I did not try to validate the stream URLs. 2. Getting station-artwork references into upmpdcli-radio.conf is harder. In moOde, the logos you see are stored in the local filesystem (IIRC, moOde has code to make use of any remote links stored in its sqlite3 database but I see none in use at the moment). Since upmpdcli requires a URL to pass to UPnP Control Points ("artUrl=" in the station entry), I referenced the nginx server already running in moOde to serve these logo files. This mostly works but there are two issues:
And of course the sky's the limit if one starts with a clean sheet of paper but that's not going to happen. Regards, Kent PS - this is for the version 1.2.x upmpdcli we are using. The newer v1.3.x has additional functionality including some scripting capabilities for radio entries which might be useful once we move to it. Still looks a bit experimental though. PPS - before someone feels the necessity to pipe up, yes, I know there are APIs to fetch station artwork, indeed complete station info, from resources like Dirble (commercial) or Radio Browser (free) but they don't fit into the current framework. Maybe someday. RE: Make it possible to maintain upmpdcli-radio.conf via Moode’s interface - TheOldPresbyope - 12-12-2018 Ok, so I resolved my logo-filename issue. Logos now display in both Bubble DS and Linn Kazoo, which are the only suitable apps I have. Below is a Python 3 script (won't work in Python 2.7 without a mod) which reads all the .pls files in the moOde RADIO directory and prints its output to the command line. This output can be redirected to a file which can replace or be concatenated with /etc/upmpdcli-radio.conf. Put it in pi's home directory on your moOde player; read the limitations in the comments; and assuming you've made it executable invoke it either as Code: ./gen-upmpdcli-radio.py to see its output, or as something like Code: ./gen-upmpdcli-radio.py > upmpdcli-radio.conf to save the output to a file. If you choose not to make it executable, then invoke as "Python3 gen-upmpdcli-radio.py ...." This script does not directly overwrite /etc/upmpdcli-radio.conf on purpose but if you are adventuresome, you could do so by invoking it as root and redirecting to that file. Regards, Kent gen-upmpdcli-radio.py Code: #!/usr/bin/python3 RE: Make it possible to maintain upmpdcli-radio.conf via Moode’s interface - Zigzag - 01-17-2019 Sorry TheOldPresbyope I've been away for a while - many thanks your script RE: Make it possible to maintain upmpdcli-radio.conf via Moode’s interface - clemarc@gmail.com - 12-31-2019 Hi everybody, I've tried the python script, but for some reasons, it does not work with all radio streams... So, I made my own in a bash / awk script that I share with you. #!/bin/bash pls_source=/var/lib/mpd/music/RADIO/*.pls SUDO='' if (( $EUID != 0 )) then SUDO='sudo' fi replicate_radio() { upmpd_conf=/etc/upmpdcli-radio.conf mv $upmpd_conf $upmpd_conf.old awk -F= '/File1=/ {url=$2;"hostname" | getline hostname;n=split(FILENAME,current_file,"/");split(current_file[n],file_no_ext,".pls");gsub(/\ /,"%20", file_no_ext[1])}\ /Title/ {print "[radio " $2 "]\nurl = "url "\nartUrl = http://" hostname ".local/images/radio-logos/thumbs/" file_no_ext[1] ".jpg\n"}' "$@" >>$upmpd_conf systemctl restart upmpdcli.service } FUNC=$(declare -f replicate_radio) $SUDO bash -c "$FUNC; replicate_radio $pls_source" AWK is so powerful !! ;-) RE: Make it possible to maintain upmpdcli-radio.conf via Moode’s interface - TheOldPresbyope - 12-31-2019 @"clemarc@gmail.com" Thanks for your contribution. My one-shot solution was written a year ago---moOde was v4.3 or so---and I would not be surprised if more than one detail has changed since. Regards, Kent |