Sunday, May 15, 2022

Radio Now Playing plugin for LMS

-Enhancing the Squeezebox (LMS) with information about what is now playing

Over the years I have developed a few plugins for the Logitech Media Server (LMS aka slimserver).
A "plugin" is software that is added to LMS that brings additional functionality.

My first, back in 2017, was to show what is now playing on FIP - artist, track name, image and duration.
It was quite hard work to get the first one done because there is not very much documentation on how to do this in LMS and it is a long time since I have written some Perl and even when I did, it really was not very much.

Anyway - I managed to get it working and had some good responses from listeners.

I built on that and made a more generic one for Radio France (and therefore retired the FIP one) - which included their stations in the various groups (for example FIP, France Musique, France Bleu).
I made contact with a couple of people in Radio France to explain what I was doing and they seemed OK with it ... so I built more into it ... to include the ability to browse the radio schedules and replay shows from the last few days.

A few requests came in asking for stations from other broadcasters ... and I was able to make a few of them as well. Over time this meant that I had released plugins for:
ABC Australia
CBC Canada (English and totally different French service)
Planet Radio (Bauer Media) - Jazz FM, Planet Rock, Absolute etc
Supla (Finland)
KCRW
RTE (Ireland)

Each one was heavily based on one of the earlier ones but as time went on the code was diverging and becoming painful to look after. If I had to fix or enhance something then there was a chance that the change would need to be applied to 2 or 3 other code bases.
In the back of my mind was building something more generic that would allow me to add or change things in one set of code and also add new stations by simply adding a new configuration file.

I September 2021 I released the first version of this new plugin - called Radio Now Playing.

The first station that I included in it was Juke Radio - a new station from another LMS user. They were starting up and wanted to get their cover art (album covers) to appear in LMS but were not in a position to feed the image URL into their flac audio stream. So I offered to help and used this as the starting point for the more generic plugin. As I write this, that station is currently off-air - but it gave me the incentive to turn my original idea into something real.

Since then I have migrated some of the stations from individual plugins to this new one (Supla, KCRW and RTE) plus added a lot more. At the moment there are around 40 - 50 different station groups with many of them having multiple stations meaning that there are hundreds of stations in the plugin.




All sorts of different techniques are used by the plugin to get the data that it needs to show.
The most common approach is to use the JSON data that the broadcaster presents to their own web interface.
It might be as simple as a HTTP GET to return something like:
{
    "artist": "Someone",
    "title": "Something",
    "image": "h t t p :// somewhere / xxx.jpg"
}
although it is usually a lot more complex than that.

The approach has meant that sometimes it is really very easy to add in something new.
For example - a request to the Squeezebox forum asking about a station that had been removed from the usual radio listing service was added (along with 2 sister stations) in about 15 minutes without a single change to the underlying code - just the addition of a configuration file.

From here .... the only way is up






No comments: