SQL Database and Smart Playlists
#1
So I was thinking of jumping into some development and one place that I would like to take a look at is smart playlists. However, I dont know where anything is stored so I was hoping people could help me out.

1) Where is the local SQL database stored? Do I need any credentials to query against it outside of kodi?
2) Where is the code for smart playlists found?

Is there anything else that I should know before I start poking around? Thanks.
Reply
#2
The local database is in the userdata under "userdata/Databases" and it's an SQLite database (unless you have setup MySQL). You'll need some third party tool to inspect it and send queries to it.

The smartplaylist code is located in "xbmc/playlists/SmartPlaylist.h/cpp" and the listing/retrieval logic is in "xbmc/filesystem/SmartPlaylistDirectory.h/cpp".

What do you intend to do exactly? Maybe I can give you some more pointers if I know what you are trying to achieve.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#3
Thanks for those locations.

My goals are two fold

1) Allow and/or queries without the need to create a playlist of playlists. I suspect this is mostly a UI issue as SQL can easily do this today.
2) Allow querying from a temp table or view. This is probably substantially more difficult and possibly not within my skillset, but you never know.

#2 really bothers me because what I would like to do is create a playlist of watched comedy shows that has an equal chance of showing every show REGARDLESS of how many epsiodes there are of a given show. So shows with 10 episodes have the same chance as shows with 200. The only way that would be possible is by creating a temp table first and then querying from it.
Reply
#4
1) What kind of queries? You can already do temporary library filtering without creating a smartplaylist (it creates a smartplaylist in the background but it is not saved/persisted or anything).
2) This would either require some way to specify the SQL GROUP BY operator or to be able to create a smartplaylist based on another smartplaylist (which is not the same as combining the conditions of two smartplaylists). The tricky part with the first approach is that it's very technical and 99% of the people would probably be confused with it. The tricky part about the second approach is that all conditions are written to match the view names (movie_view, tvshow_view, ...) so they won't easily work with a temporary table with a different name.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#5
I'm Also always been interested in smart playlists but usually with video playlists of playlists I managed to solve almost everything (except grouping episodes by TV shows or select only the first unwatched episode). Instead seems to me that with music you can do a lot less than with video. With video playlist you can actually replicate almost every part of the video library filtered but with music you can't. Is this because of video nodes and the flexibility that work brought? Is there anyone working on something similar for music?
Reply
#6
The main reason is that most developers (including myself) only use the video library and nobody really cares about the music library. I have done a lot of improvements on the smartplaylists and the video library in general which could also be applied to the music library but I never really find the motivation to do it because I don't really use it myself and I also don't know the code that well.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#7
1) I actually dont have an example off the top of my head in which I would use it, I was just under the impression its not possible for smart playlists (which seems to be true, but there is a temporary way to do them). I really like linking playlists to submenus on the home screen though so I can see a use where I would want some permanence.

2) My initial thought on this was to create a temp table and then insert to it. So for my example above: (I want 20 episodes at random of 10 different comedies that have not been viewed in 90 days with an equal chance of any of the 10 appearing).

Create Temp Table Comedy
Insert into Comedy (Select top 10 Show A where lastviewed not in 90 days order random)
Continue

Then for the final playlists you would just select 20 from the temp table comedy.

Once again, I have no idea how complicated this would be to implement and let alone for people to figure out how to use it within the UI, but that was what I was thinking. As for the names needing to match the views, would it not be possible to use an alias on the temp table to make this happen? You just have to point to the temp table initially and then all the field names could be the same.
Reply

Logout Mark Read Team Forum Stats Members Help
SQL Database and Smart Playlists0