Thank you for your donation!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is it possible to display now playing artwork for radio streams?
#11
"This will only work with Lumin and Kazoo"

Sorry, I missed this bit last night, my mistake.

No wonder it didn't work. I'll have to learn to comprehend what is written....
Reply
#12
(07-08-2018, 06:45 PM)serverbaboon Wrote: Ok I  have a simple script (very little error checking)  to get the artwork for the currently playing track on Radio Paradise at the bottom of the page, I don't seem to be able to upload the file.

Once you have entered the code save it as rp3.py.

Transfer this file to you PI either by winscp or equivelant to /home/pi or by copying using what ever file share browser you have to \\x.x.x.x\SDCARD.

ssh to your Raspberry PI

move your file to /usr/local/bin, give the file execute permissions and test.
The stuff in brackets are notes .

Code:
cd /usr/local/bin
sudo mv /mnt/SDCARD/rp3.py .              ( or if you used scp sudo mv /home/pi/rp3.py .)
sudo chmod +x rp3.py

./rp3.py

https://img.radioparadise.com/covers/l/B0006ZXJ3E.jpg


(if you get an error about request missing)

sudo pip install requests


You need to make sure that your Radio Paradise entry in the Radio Config file for UPMPDCLI references this script, make sure the Radio Paradise section in the file /etc/upmpdcli-radio.conf looks something like this and save.

To edit type you can use nano at the terminal prompt.

sudo nano etc/upmpdcli-radio.conf



Code:
[radio Radio Paradise]
url = http://stream-uk1.radioparadise.com/aac-320
artUrl = https://www.radioparadise.com/graphics/fb_logo.png
artScript = /usr/local/bin/rp3.py

You will need to restart upmpdcli or reboot the raspberry pi.

To restart upmpdcli you can type.

sudo service upmpdcli restart and press return.

One thing I have noticed is that Kazoo can be a little unstable if you are messing around stopping and starting things, plus if you leave it running when you are off wireless it has this habit of changing its default network it scans to be your telephone providers ip address which is annoying. Basically always exit Kazoo and check the wireless network before blaming Moode/UPMPDCLI.

The code is below, if you are doing this on a windows box you MUST make sure that you file editor can save in Linux format not Windows CRLF format.
The Python XML libraries have some vulnerabilities so there is a cursory attempt to make sure the xml isn't to big, this is a poor test and the vulnrabilities more sophisticated so don't use this code for anything else.

Basically Radio Paradise publish an XML file with the current track data in it, we get it with python requests take the resulting xml and search for the cove art key.

http://radioparadise.com/xml/now.xml

The current version of upmpdcli in Moode uses Python 2.


Code:
#!/usr/bin/python

# Extract the artwork url for the currently playing track Radio Paradise.
# Will repeat the warning from the Python website about the lack of checking on the xml modules.

from __future__ import print_function

import requests
import xml.etree.ElementTree as etree

rpdata = "http://radioparadise.com/xml/now.xml"

try:
   StreamInfo = requests.get(rpdata, timeout=2)
except requests.exceptions.ConnectTimeout:
   exit(1)
else:
   if int(StreamInfo.headers['Content-Length']) > 1024:
       exit(2)

rp = StreamInfo.text

rptree = etree.fromstring(rp)

print(rptree.find('song/coverart').text)

# Uncomment the below for troubleshooting to display the XML
# print(rp)
Hi, Sorry, work has been full on so I've only just seen your script serverbaboon - many thanks for doing this.
Reply


Forum Jump: