Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Make it possible to maintain upmpdcli-radio.conf via Moode’s interface
#7
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 !! ;-)
Reply


Messages In This Thread
RE: Make it possible to maintain upmpdcli-radio.conf via Moode’s interface - by clemarc@gmail.com - 12-31-2019, 05:20 PM

Forum Jump: