PDA

View Full Version : How to retain active playlist when squeezebox service is restarted



tuc
2018-11-07, 01:56
Hi there,

I run LMS on a Raspberry Pi with two groups of players. Group1: 4 synced players (1 SB receiver and 3 SB boom), Group2: 1 player (1 SB boom).
When I occasionally either reboot the server or restart the squeezebox-server service, the active playlists on the players gets reset to some previosly used active playlist. Typically a playslist from a couple of days ago.

Is there any way I can restart the squeezebox-server service and retain the active playlist on all the players?
I have tried having a single group but the problem is the same.

Any tips or suggestions would be appreciated.
Best regards,
-thomas

PS: I am amazed at how well my Raspberry Pi 3 runs LMS only expending 2-5 Watts.:)

Paul Webster
2018-11-07, 02:17
Perhaps implies that the playlist is being stored in memory and being written to "disk" (much) later.
Are you using pCP to host your LMS?

tuc
2018-11-07, 02:49
Perhaps implies that the playlist is being stored in memory and being written to "disk" (much) later.
Are you using pCP to host your LMS?

Thanks for your quick reply.
Oops, I dont know what pCP is :rolleyes:

My LMS is running on a Raspberry Pi on my local network using a wired connection. So I think the answer to your question is 'no'.

Best
-thomas

Paul Webster
2018-11-07, 04:34
Did you install LMS by yourself or use 3rd-party package like piCorePlayer (pCP)?

DJanGo
2018-11-07, 05:30
Do you use Dont Stop The Music / Lastmix?

If yes - just add another / remove any track on your own to the playlist before you stop lms.
Adding tracks from dstm didnt didnt trigger "change the cached / stored playlist".

tuc
2018-11-07, 06:09
Did you install LMS by yourself or use 3rd-party package like piCorePlayer (pCP)?

Oh, I installed LMS myself. I hadn't looked into pCP. I will have a look now.
Cheers.
-thomas

Paul Webster
2018-11-07, 06:11
It should be possible to resolve your problem without you having to start from scratch.
Knowing it is a self-install helps to remove some lines of enquiry.

tuc
2018-11-07, 06:16
Do you use Dont Stop The Music / Lastmix?

If yes - just add another / remove any track on your own to the playlist before you stop lms.
Adding tracks from dstm didnt didnt trigger "change the cached / stored playlist".

I do use "Dont stop the music". I will try your suggestion. Thanks very much.

I have a crontab entry that makes the server reboot at night (perhaps overkill on a linux based system :-)) so it would be even better if I didn't have to do anything. Or perhaps I could do another crontab job that casued the playlist to be stored immediately before the reboot.

-thomas

DJanGo
2018-11-07, 12:02
I do use "Dont stop the music". I will try your suggestion. Thanks very much.

I have a crontab entry that makes the server reboot at night (perhaps overkill on a linux based system :-)) so it would be even better if I didn't have to do anything. Or perhaps I could do another crontab job that casued the playlist to be stored immediately before the reboot.

-thomas
add that line in front of your crontab reboot similar to this:

pl:ay:er:ma:ca:dd:re:ss -> the mac adresss of the player



printf "pl:ay:er:ma:ca:dd:re:ss playlist move 0 1\n pl:ay:er:ma:ca:dd:re:ss playlist move 1 0\nexit \n"|nc 127.0.0.1 9090

That moves the 1st file to 2.nd place and back again.
And that move is recon by lms and it saves the cached playlist.

tuc
2018-11-08, 02:50
add that line in front of your crontab reboot similar to this:

pl:ay:er:ma:ca:dd:re:ss -> the mac adresss of the player



printf "pl:ay:er:ma:ca:dd:re:ss playlist move 0 1\n pl:ay:er:ma:ca:dd:re:ss playlist move 1 0\nexit \n"|nc 127.0.0.1 9090

That moves the 1st file to 2.nd place and back again.
And that move is recon by lms and it saves the cached playlist.

Wow, so cool! Thanks!
Just to be sure. I am talking about the active playlist, not a saved playlist with a name and located in the "playlist" folder as pointed to in the LMS settings.
So I just want to keep whatever happened to be playing at the end of the day (before reboot) in order to press "play" in the morning (after reboot) and the songs from yesterday will play.

Cheers
-thomas

DJanGo
2018-11-08, 03:20
Wow, so cool! Thanks!
Just to be sure.
We are talking/writing about the same.

A saved Playlist is an entirely different kind of flying altogether! ;-)

tuc
2018-11-08, 08:11
We are talking/writing about the same.

A saved Playlist is an entirely different kind of flying altogether! ;-)

Again thank you!
I have now digested the command you provided (at least to some degree:-)). It is the first time I have thought about what the CLI can really do - amazing!

It made me think about another feature that I have been wishing for for a long time:
Sometimes I (or friends) accidentally zap the active playlist by pressing "play" to an item found by a search in the music library. I would like to be able to "go back" to the previous active playlist. Now, this is quite tricky since it would require every update to the active playlist to be "saved to disk" and also require functionality to make the "playlist saved to disk available".

As a poor man's solution: Saving the current playlist once a day among the "real" playlist pointed to by LMS settings. Such a playlist could have a filename containing the date. I would then delete older playlist. This could be achieved through CLI and crontab (I just don't know how to turn an active playlist into a named playlist).

If you are still up for helping me ...

Best
-thomas

PS: I will try your solution to my original post later today and let you know how it went.
PPS: Long live LMS :-)

DJanGo
2018-11-08, 13:03
Sometimes I (or friends) accidentally zap the active playlist by pressing "play" to an item found by a search in the music library. I would like to be able to "go back" to the previous active playlist. Now, this is quite tricky since it would require every update to the active playlist to be "saved to disk" and also require functionality to make the "playlist saved to disk available".
PPS: Long live LMS :-)


PS: I will try your solution to my original post later today and let you know how it went.
PPS: Long live LMS :-)

first please make sure you've got an answer

which nc
which sed

otherwise you need to install nc / sed before any further action.

save the script, make it executable and let it run

The last line is not working because of the # in front
If you remove that # your lms starts scanning your playlists - snce your runing a rpi i wasnt sure if you really want that.

Feel free to test it before you add it as a cronjob. You should end in a playlist in your playlistfolder for every player named playername_hour.m3u.
If you run it always @ the same hour it should do what you want.



#!/bin/bash

##vars
port=9090
server=127.0.0.1
hour=`date +%H`
playlistdir=$(grep "playlistdir:" /var/lib/squeezeboxserver/prefs/server.prefs|grep '/'|cut -d ' ' -f2)
players=$(printf "player count ?\nexit\n" | nc $server $port | cut -d ' ' -f 3)

for((i=0; i<$players; i++))
do
playerID=$(printf "player id $i ?\nexit\n"|nc $server $port|cut -d ' ' -f 4|sed 's/%3A/:/g')
player_ID=$(echo $playerID|sed 's/://g')
playername=$(printf "$playerID name ?\nexit\n" | nc $server $port | cut -d ' ' -f 3)
playlist=$(echo $day $playername|sed 's/ /_/g')
printf "$playerID playlist move 0 1\n $playerID playlist move 1 0\nexit \n"|nc $server $port
if [ `wc -l /var/lib/squeezeboxserver/prefs/clientplaylist_$player_ID.m3u | awk '{print $1}'` -ge "4" ]
then
cp -p /var/lib/squeezeboxserver/prefs/clientplaylist_$player_ID.m3u $playlistdir/$playlist.m3u
fi
done

scanstatus=$(printf "rescan ?\nexit\n"|nc $server $port|cut -d ' ' -f2)
if [ "$scanstatus" = "1" ]
then
echo "lms is already scanning ..aborting"
exit 0
fi

#find "$playlistdir/" -iname "*_$hour.m3u" -mtime 0 && squeezeboxserver-scanner --playlists --novideo --noimage --priority 20 >/dev/null

DJanGo
2018-11-09, 00:53
save the script, make it executable and let it run

btw: there is a "issue" in the script....

it always move the first tracks to 2.nd postion when there is a 2nd Track and moves it back to its org. position to ensure dstm filled playlists are updated.
By doing this the filestamp of the playlist is changed before copied to the playlistdir.
And that makes the check for newer files later a little bit useless.

Other than that it should work

tuc
2018-11-09, 01:35
We are talking/writing about the same.

A saved Playlist is an entirely different kind of flying altogether! ;-)

I tried your one-liner yesterday and it works!
Thanks a lot.
-thomas

tuc
2018-11-09, 05:40
btw: there is a "issue" in the script....

it always move the first tracks to 2.nd postion when there is a 2nd Track and moves it back to its org. position to ensure dstm filled playlists are updated.
By doing this the filestamp of the playlist is changed before copied to the playlistdir.
And that makes the check for newer files later a little bit useless.

Other than that it should work

DJanGo you are a star!
I will experiment with how to use your script (how often to run it, how often to rescan playlist etc.).
FYI: nc is already installed (it used in your one-liner solution too). I think sed is also installed but I will install it if not (same for awk).

Thanks for the inspiration to use shell scripts and CLI togehter. Perhaps I can think of other ways of enhancing LMS functionality with these tools in hand.
Have a great weekend.
-thomas

gregklanderman
2018-11-10, 09:08
That moves the 1st file to 2.nd place and back again.
And that move is recon by lms and it saves the cached playlist.

Nice that you found that work-around, but it really seems to just be a bug in DSTM.
I haven't used DSTM but I think maybe Michael wrote that plugin?
I would post on the plugins forum and see if you can get him to just fix it..

Greg

gregklanderman
2018-11-10, 09:46
It made me think about another feature that I have been wishing for for a long time:
Sometimes I (or friends) accidentally zap the active playlist by pressing "play" to an item found by a search in the music library. I would like to be able to "go back" to the previous active playlist. Now, this is quite tricky since it would require every update to the active playlist to be "saved to disk" and also require functionality to make the "playlist saved to disk available".


Great idea, I cannot tell you how many times I've accidentally hit play instead of add over these many years.

I'm not sure you really have to intercept every update to the current playlist, possibly just intercepting the clear playlist that happens when you "play" would be sufficient, and you probably only need to keep the single most recent one. I'd be happy to have it saved to a fixed name under the playlists menu.

Greg

tuc
2018-11-10, 11:58
Great idea, I cannot tell you how many times I've accidentally hit play instead of add over these many years.

I'm not sure you really have to intercept every update to the current playlist, possibly just intercepting the clear playlist that happens when you "play" would be sufficient, and you probably only need to keep the single most recent one. I'd be happy to have it saved to a fixed name under the playlists menu.

Greg

YES! Great Greg. I asked this question some years back and the replies I got was that it was really difficult. Intercepting the "clear playlist" seems less difficult. I just have no experience with LMS code and I am not sure if one could achieve it without revising the actual LMS code (i.e. not sure if plugin can do it alone)

-thomas

JJZolx
2018-11-10, 15:23
Sound familiar?

https://forums.slimdevices.com/showthread.php?95219-Recurring-playlist'

DJanGo
2018-11-10, 16:46
Nice that you found that work-around, but it really seems to just be a bug in DSTM.

i am pretty sure its a feature not a bug

eg /plugins/playhistory (also from Michael) do show these tracks.

There was a discussion about "i started with this track and dtsm drifts away from my track" so the feature (i believe so) is - "if you dont touch the playlist made from dtsm and you restart your server - dtsm will start from scratch with your "touched" playlist not with its own.

Anyway i am happy with it (and i even have No worries to hack the "add track button" out of my skin)
If you think its a issue ask Michael about it.

DJanGo
2018-11-17, 02:21
And i found another usecase for it..

I do run Alarms on some players.

Whenever that Alarm is active it wipes the last playlist from that player and adds the alarmplaylist/file as its playlist.
So it doesnt matter if that particular DSTM is a bug or a feature.

If you really what do "save" your last active playlist when using alarms - you need to save it by hand or script.