View Full Version : Bad information displayed - Spotty plugin

2018-02-22, 08:11

I am new on this forum. I have tried to search for a good title, maybe it is not the best title.

I am french dude with not a perfect english, so i do apologize for my mistakes.

I am coming on your forum because I am a user of LMS for one year now and I have an issue that I do not how to fix alone.

First of all :
LMS Version : Logitech Media Server Version: 7.9.1 - 1503129892 @ Thu Aug 31 04:39:14 UTC 2017
Spotty plugin version : 2.1.9
Spotty plugin configuratin : https://i.imgur.com/KpGOENk.png

I hope i will be understandable :
I am using a plugin on my web server which is managing my home-automation to control LMS (I am not the author of the plugin, you will see this soon, because of my poor dev skills :o ).

This plugin is catching information from LMS to display those in a widget.

If I start a playlist from spotty plugin, the display is good :

LMS rendering (right clic on the music which is played)

Home Automation Plugin rendering :

If I add an LMS playlist to the LMS's favorites (like this each modification done on spotify is applied when starting the playlist from the favorites, Best user experience ever , thanks for this), i have an issue with the name displayed :
LMS rendering :

Home Automation Plugin rendering :

As you can see, the information are gathered from the first line displayed, well i do assume so.

I have open the code of the Plugin.pm which collects the information and send them to the Home Automation plugin, I have tried to understand how to get the title, Artist and Album name from the above screenshots, which are good, to have them send to the home automation plugin with no success.

Here is the code in Plugin.pm :

sub commandCallbackNewsong {
my $request = shift;
my $client = $request->client();
if( !defined( $client)) {
if( $request->isCommand([['playlist'], ['newsong']]) ) {

my $sTitle = $client->playingSong();
my $sName = 'Aucun';
my $artist = '';
my $album = '';
my $tracknum = '';
my $duration = 0;
my $played = 0;

eval { $sName = uri_escape(encode('utf-8',decode($enc,$sTitle->track()->title))) || '';}; warn $@ if $@;
eval { $artist = uri_escape(encode('utf-8',decode($enc,$sTitle->track()->artistName))) || 'Plugin';}; warn $@ if $@;
eval { $album = uri_escape(encode('utf-8',decode($enc,$sTitle->track()->albumname))) || 'Plugin';}; warn $@ if $@;

#I have removed the part which sends the information from $sName,$artist,$album) this point is ok, because i receive from $sName the value : spotify://track:fds56f4sd65f4dsf56sd


I have two thoughts on how to fix this (but maybe it is impossible, or maybe i am wrong in my understanding of how it works in spotty plugin)

- Having spotty plugin displaying the good information, the concatenate of Song Name BY Artist Name From Album Name when accessing to an LMS favorite

- Having access to the information (Artist Name / Album Name / Song Name) in the Plugin.pm which is used to send information to the home automation Server ?

I am pretty sure this is easy for one who knows how LMS works, but after hours of reading in the forum, in the wiki, and testing some codes I did not find the solution.

Many thanks for your help,

Sorry for this long post, but I try to be the more complete in order to give you all the researches I have done.

TaG ;)

2018-02-22, 09:17
I would suggest you use the "status" query (as documented in the CLI documentation (http://htmlpreview.github.io/?https://raw.githubusercontent.com/Logitech/slimserver/public/7.9/HTML/EN/html/docs/cli-api.html) rather than to try to grab the information from the track object yourself. That's what all the other UIs do, and it does the difficult part for you.

# request the current player's status. Starting with the current track ('-'), grab information for one single track:
my $r = $client->execute(['status', '-', 1, 'tags:aKl']);

# playlist_loop of the response is a list of track information hashes. We only have requested on - grab it:
my $track = $r->getResult('playlist_loop')->[0];

# extract the nice pieces of information from the $track hash ref:
my $artist = $track->{artist};
my $album = $track->{album};
my $title = $track->{title};

2018-02-22, 13:08
Hello Michael,

I do really thank you very much for your help !!!!

It is working well now :) !!!!!!


LMS Side :

I will ask for the modification in the plugin concerned by this point.

Really amazing !!!

Thanks again !!!!

I will continue to enjoy using your plugin for a long long long time :D

Do you want me to rename the title of the post ?

Really thank you :

2018-02-22, 21:58
Excellent work sir .

Should not the author of the home automation plugin be notified ? He will probably accept your changes in to the plugin.

2018-02-23, 08:26
This really helps me in solving my problems with the device.