PDA

View Full Version : Easy way to show "last played" date for a track?



haschmich
2019-05-27, 03:56
I am looking for an easy way to check on the last time a specific track has been playing. I want this because I try to configure my playlist generators (mainly MusicIP) in a way so that they avoid tracks that have been recently played, and being able to check the last played date of a track helps immensely in checking whether that worked as intended ;)

Now I know that information is available at least from TrackStat and MusicIP, not sure about vanilla LMS. For the currently playing track, the info is available in the TrackStat context info; for any track, I had noticed long time ago (LMS 7.7.1) that the "Browse by selected" context menu from the Custom Browse plugin would show me that info, accessible via the track's context menus. Now on 7.9.1 for the life of me I cannot get the "Browse by selected" to show up any longer; I'm afraid it's incompatible with the newer LMS versions.

So my question is, do you have any idea how to easily access the "last played" info for any track through the web UI - ideally also accessible through Craig's magnificent Material skin?

Btw, same question goes for the "total # of times played" info, but the "last played" is slightly more important to me.

mherger
2019-05-27, 04:16
> I am looking for an easy way to check on the last time a specific track
> has been playing. I want this because I try to configure my playlist
> generators (mainly MusicIP) in a way so that they avoid tracks that have
> been recently played, and being able to check the last played date of a
> track helps immensely in checking whether that worked as intended ;)

Please define "easy"... there's the persist.db database which has some
information about your tracks. Eg. there's the lastPlayed column, which
would give you that information. Whether that's easy depends on what you
want to do :-).

> So my question is, do you have any idea how to easily access the "last
> played" info for any track through the web UI - ideally also accessible
> through Craig's magnificent Material skin?

You'd have to write a CLI command to read $trackObj->lastplayed.
Wouldn't be too hard to do. But then you'd also have Craig to add
support for itl. A lot of small pieces, rather than an easy way.

> Btw, same question goes for the "total # of times played" info, but the
> "last played" is slightly more important to me.

That would be $trackObj->playcount (or the playCount column in the raw
table)

--

Michael

haschmich
2019-05-27, 09:02
Please define "easy"...

Thanks for the info, Michael. I guess you already guessed that this is beyond what I would consider "easy" ;) But I'm sure you would have told me if you knew about any existing plugin that would be able to do what I want.

Would it be possible to write a plugin that reads the attributes you mentioned and hooks them into the track context information (amongst the info about length, bitrate, date modified etc), or into a submenu like "More info" (similar to "View Tags")? If so, what would be the starting point for writing such a plugin? Do you know of an example that does a similar thing to build upon?

w3wilkes
2019-05-27, 09:50
You can read the "Persist" DB using SQLite Expert Personal (Free). Just curious, what is the format of the "lastPlayed" column? I see values like "1547337301" in the lastPlayed column.

Paul Webster
2019-05-27, 10:02
You can read the "Persist" DB using SQLite Expert Personal (Free). Just curious, what is the format of the "lastPlayed" column? I see values like "1547337301" in the lastPlayed column.

That is a "Unix time" - number of seconds since Unix base time of Jan 1 1970 00:00 ... in this case
Saturday, 12-Jan-19 23:55:01 UTC

w3wilkes
2019-05-27, 10:13
Thanks! A quick google search found a converter for "Unix Time".

mherger
2019-05-27, 21:28
> Thanks for the info, Michael. I guess you already guessed that this is
> beyond what I would consider "easy" ;) But I'm sure you would have told
> me if you knew about any existing plugin that would be able to do what I
> want.

I wouldn't know of one - which doesn't mean it doesn't exist somewhere.

> Would it be possible to write a plugin that reads the attributes you
> mentioned and hooks them into the track context information (amongst the
> info about length, bitrate, date modified etc), or into a submenu like
> "More info" (similar to "View Tags")? If so, what would be the starting
> point for writing such a plugin? Do you know of an example that does a
> similar thing to build upon?

Many plugins do register a "track information handler". Eg. MusicIP
would allow you to start a mix based on the currently playing track:

https://github.com/Logitech/slimserver/blob/public/7.9/Slim/Plugin/MusicMagic/Plugin.pm#L235

Such a handler is called with the $client on which it's been used, the
currently playing track's URL, and a track object, which would give you
access to those properties I mentioned in my previous mail. A very
simple example which would show the track number in such a menu would be:

https://github.com/Logitech/slimserver/blob/public/7.9/Slim/Menu/TrackInfo.pm#L862


--

Michael

kidstypike
2019-05-28, 00:45
"What Was That Tune?" plugin isn't quite what you require?

27446

mherger
2019-05-28, 01:14
> "*What Was That Tune?*" plugin isn't quite what you require?

That would show you what was last played on a device, but not when a
track was last played.

--

Michael

kidstypike
2019-05-28, 01:27
> "*What Was That Tune?*" plugin isn't quite what you require?

That would show you what was last played on a device, but not when a
track was last played.

--

Michael

Yes, I know, but as every track has WWTT in the context menu, you could adapt it to show the last played time/date (if any) in your spare time? :o

27447

mherger
2019-05-28, 01:32
> Yes, I know, but as every track has WWTT in the context menu, you could
> adapt it to show the last played time/date (if any) in your spare time?

No, that's imho a totally different use case.

But adding the information to the "More Info" item in a track's context
menu was simple enough. So I did it.

Here's the change, which might explain the "how could this be done":

https://github.com/Logitech/slimserver/commit/a9e9b9ff71d4bad3516d334da7dabbe65dfeef85

--

Michael

kidstypike
2019-05-28, 02:34
> Yes, I know, but as every track has WWTT in the context menu, you could
> adapt it to show the last played time/date (if any) in your spare time?

No, that's imho a totally different use case.

But adding the information to the "More Info" item in a track's context
menu was simple enough. So I did it.

Here's the change, which might explain the "how could this be done":

https://github.com/Logitech/slimserver/commit/a9e9b9ff71d4bad3516d334da7dabbe65dfeef85

--

Michael

I see it in default skin, doesn't appear in the Material skin.

27449

mherger
2019-05-28, 03:02
I see it in default skin, doesn't appear in the Material skin.

27449

I put it inside the More Info menu item. The Default skin does „flatten“ that menu, Material does not.

kidstypike
2019-05-28, 03:12
I put it inside the More Info menu item. The Default skin does „flatten“ that menu, Material does not.

Yes, sorry, I see it now. :o

27450

haschmich
2019-05-28, 13:53
But adding the information to the "More Info" item in a track's context
menu was simple enough. So I did it.

Here's the change, which might explain the "how could this be done":

https://github.com/Logitech/slimserver/commit/a9e9b9ff71d4bad3516d334da7dabbe65dfeef85


Cool, thanks! Looks easy enough indeed - once it's done ;)

Funnily enough, apparently erland's plugins applied some special magic, because for the currently playing song, they used to actually still display the *last* time the track was played... Or maybe there is just another attribute in the trackstat db that I could use instead?

27454

mherger
2019-05-28, 22:04
Cool, thanks! Looks easy enough indeed - once it's done ;)

Funnily enough, apparently erland's plugins applied some special magic, because for the currently playing song, they used to actually still display the *last* time the track was played... Or maybe there is just another attribute in the trackstat db that I could use instead?

27454

AFAIK Trackstat uses its own database and stats implementation.