Guest - Testers are needed for the reworked CDateTime core component. See... https://forum.kodi.tv/showthread.php?tid=378981 (September 29) x
Is it possible to create a complex query in a smart playlist
#1
Hi,
I've been using Kodi for several years now, with 2 Matrix clients sharing a MYSQL database, and a fileshare located on a VM. It has been excellent so far.

From what I've seen the smart playlists are simply a MYSQL query to return the results, which, by the way works great, however there are some limitations.

One thing I've always wanted to do is create a more complex query using AND/OR's.

For example, a smart playlist might look something like this

Path Contains 'myAwsomeFolder'
MyRating > 8

and you can have all conditions required to be true, or any of the conditions required to be true

What I'd like to do is something like this:

Path Contains ('myAwsomeFolder' OR 'myAwsomeFolder2' OR 'myAwsomeFolder3')
AND MyRating > 8

Is this something that is possible within the UI? Perhaps with the Nexus upgrade? Perhaps something more advanced that can be done?

Thanks!
Reply
#2
Focusing on your above example only...

I would have thought that Path Contains 'myAwsomeFolder' would also capture Path Contains ('myAwsomeFolder' OR 'myAwsomeFolder2' OR 'myAwsomeFolder3')
The operator is contains and myAwsomeFolder2 does contain myAwsomeFolder

Do you have other sources in addition to myAwsomeFolder? Wouldn't you want to list all movies that match MyRating > 8?
My Signature
Links to : Official:Forum rules (wiki) | Official:Forum rules/Banned add-ons (wiki) | Debug Log (wiki)
Links to : HOW-TO:Create Music Library (wiki) | HOW-TO:Create_Video_Library (wiki)  ||  Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)
Reply
#3
Haha, ok, bad example

how about

Path Contains ('abc' OR 'def' OR 'xyz')
AND MyRating > 8
Reply
#4
In reality what I'm trying to is much more complex, as I have numerous folders by genres.

In some cases I want to have a smart playlist, for example that contains the best of multiple genres
so

where (path contains 'house' OR path contains 'lounge' OR path contains 'hip hop')
AND
UserRating > 8
Reply
#5
You can probably do something like
xml:
<rule field="path" operator="contains">
    <value>abc</value>
    <value>def</value>
    <value>xyz</value>
</rule>
Learning Linux the hard way !!
Reply
#6
@black_eagle you beat me to it with your your suggestion!  Wink
Only thing different I was going to add was another rule for user rating is greater than 8 which would be applied to the first 3 rules.
Reply
#7
I think you're still limited to either matching ALL or matching ANY of the rules.

I want to match either rule 1 and 2, and rule 3, but I have the match field.

xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="songs">
    <name>lounge and beats best</name>
    <match>all</match>
    <rule field="path" operator="contains">
        <value>lounge</value>
    </rule>
    <rule field="path" operator="contains">
        <value>beats</value>
    </rule>
    <rule field="userrating" operator="greaterthan">
        <value>7</value>
    </rule>
    <limit>1000</limit>
    <order direction="ascending">random</order>
</smartplaylist>

I wonder though, if I tried adding a second match rule in if it'd work?

xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="songs">
    <name>lounge and beats best</name>
    <match>any</match>
    <rule field="path" operator="contains">
        <value>lounge</value>
    </rule>
    <rule field="path" operator="contains">
        <value>beats</value>
    </rule>
<match>all</match>
    <rule field="userrating" operator="greaterthan">
        <value>7</value>
    </rule>
    <limit>1000</limit>
    <order direction="ascending">random</order>
</smartplaylist>
Reply
#8
Tested my above theory - the second match is ignored. So I don't think we've got a solution yet
Reply
#9
See https://forum.kodi.tv/showthread.php?tid...pid3027605 for my working example of combining Smartplaylists to pull this off.

Taking the example in previous posts, this (untested) should work by setting up 2 Smartplaylists like:

1) First setup a list (I use "z_" prefix, and this way you can "hide" this playlist (unless you want it displayed):
I'll call this one z_lounge_and_beats_paths.xsp :

xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="songs">
    <name>lounge and beats path</name>
    <match>any</match>
    <rule field="path" operator="contains">
        <value>lounge</value>
    </rule>
    <rule field="path" operator="contains">
        <value>beats</value>
    </rule>
</smartplaylist>

2) Setup the "real" combined smartlist
I'll call this lounge_and_beats_best.xsp :

xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="songs">
    <match>all</match>
    <rule field="playlist" operator="is">
        <value>lounge and beats path</value>
    </rule>
    <rule field="userrating" operator="greaterthan">
        <value>7</value>
    </rule>
    <limit>1000</limit>
    <order direction="ascending">random</order>
</smartplaylist>

To hide the helper smartplaylists (prefix "z_" above) , use configuration:

xml:

<advancedsettings>
  <video>
    <excludefromlisting action="append">
     <regexp>z_.*xsp</regexp>
   </excludefromlisting>
  </video>
</advancedsettings>
Reply
#10
Rainbow 
Brilliant!

That was exactly what I was looking for!

Thanks so much!
Reply

Logout Mark Read Team Forum Stats Members Help
Is it possible to create a complex query in a smart playlist0