Smart Playlist Query
#1
If I create a smart playlist with the filter not played in the Last X weeks, will this potentially select music that has been newly added to the library and never been played, or does it need to have been played to set the last played date field

Basically I want to filter on a particular genre, then choose music that has not been played in the last 2 weeks or has never been played at all, but there does not seem to be any way to OR the two rules.

Any suggestions gratefully received
Reply
#2
Quote:will this potentially select music that has been newly added to the library and never been played
Could you use ('Date Added' or 'Date Created') in conjuction with Playcount to achieve the same thing?

1. [Genre =  X, Playcount = 0] would catch all unplayed Genre X songs?
2. [Genre =  X, Playcount = 0, 'Date Added' in the last two weeks] would catch all unplayed Genre X songs added in the last two weeks?

Your first question contradicts your second question?
Quote:then choose music that has not been played in the last 2 weeks or has never been played at all
Would [Genre =  X, Playcount = 0, 'Date Modified' greater than two weeks] help here?
Reply
#3
I probably have not explained myself very well, I want to create a smart playlist with the following filters

[Genre = X ] AND [ (Last played > 2 weeks) OR (Playcount = 0)]

so that the smart playlist will select songs of genre X AND (which have never been played in the last 2 weeks OR have not been played at all).

there does not seem to be any way to use AND and OR in the playlist selection

Either the songs match ALL the rules or ANY of the rules

Hence my question when new items are added to the library what is the last played date set to ?
Reply
#4
Just added a new album to my library and checked the database as I would expect the LastPlayed field of the songs is set to NULL
Reply
#5
To achieve mixed AND/OR logic you can nest smart playlists. You can take this too far with rulle comninations that push the SQL creation into wacky error, but for what you want it will work just fine. You can pick "playlist" in the field list when creating rule.

Basically create a smart playlist that does (Last played > 2 weeks) OR (Playcount = 0) say called "Played2weeks", and then another which has rules [Genre = X ] AND [Playlist = "Played2weeks"]
Reply
#6
(2022-05-08, 09:18)tkgafs Wrote: Hence my question when new items are added to the library what is the last played date set to ?
Sorry missed this (got too interested in combining AND and OR rules).

Unplayed music last played is NULL, however the smart playlist rules for last played BEFORE are cleverly implemented to accomodate the null values. So there is no need for you to have "OR playcount = 0" rule.
Reply
#7
Brilliant, no need to worry then !!

its hard to test something like this with a large library.

I didnt realise there was the ability to nest rulesets, I'll have a play around with other stuff like this now knowing that.

When you say "last played BEFORE are cleverly implemented to accomodate the null values" I take it this will work with Before or After date fields
Reply
#8
Yes you can nest rule sets, but honestly it is not super smart so you can also cause it to generate some slow SQL if you get too clever with it, so be kind with what nesting you do. If you are curious and can read SQL then turn on debug and see what query is being used for your smart playlist in the log, it is easier than trying to check things by just looking at results with a large library.
Quote:When you say "last played BEFORE are cleverly implemented to accomodate the null values" I take it this will work with Before or After date fields.
To be precise nulls are implemented for equals, not equals and less than operators on year, and less than, before, and not in the last operators on Last played field. Other date fields, like Date added, are never null, and after/greater than does not include null because it comes before everything.
Reply
#9
Any differences with SQLite vs MySQL?

scott s.
.
maintainer of skin  Aeon MQ5 mods for post-Gotham Kodi releases:
Matrix see: Aeon MQ5 Mod Matrix release thread
Nexus see: Aeon MQ5 Mod Nexus release thread
Aeon MQ 5 skin and addon repo 11.1.0
Reply
#10
(2022-05-09, 02:39)scott967 Wrote: Any differences with SQLite vs MySQL?
With the ways NULL values in last played and year fields are handled in queries for smart playlists, no. Both local and client server set ups are the same. There may have been a change between Kodi versions at some point, check Git history of CSmartPlaylistRule::FormatWhereClause if really interested.
Reply
#11
(2022-05-09, 08:56)DaveBlake Wrote:
(2022-05-09, 02:39)scott967 Wrote: Any differences with SQLite vs MySQL?
With the ways NULL values in last played and year fields are handled in queries for smart playlists, no. Both local and client server set ups are the same. There may have been a change between Kodi versions at some point, check Git history of CSmartPlaylistRule::FormatWhereClause if really interested.
Was thinking mainly of NULL.

scott s.
.
maintainer of skin  Aeon MQ5 mods for post-Gotham Kodi releases:
Matrix see: Aeon MQ5 Mod Matrix release thread
Nexus see: Aeon MQ5 Mod Nexus release thread
Aeon MQ 5 skin and addon repo 11.1.0
Reply

Logout Mark Read Team Forum Stats Members Help
Smart Playlist Query0