Kodi Community Forum
Next Up Playlist - Automatically generated + lightweight for widgets - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: OS independent / Other (https://forum.kodi.tv/forumdisplay.php?fid=228)
+---- Thread: Next Up Playlist - Automatically generated + lightweight for widgets (/showthread.php?tid=344120)

Pages: 1 2


Next Up Playlist - Automatically generated + lightweight for widgets - henryjfry - 2019-05-22

Hello

I posted my preliminary versions of a script which can be used to generate a next up episodes smart playlist.  This was very much a work in progress but i've now refined it to a fairly final, reliable version which runs very quickly.  So the original thread was here:
https://forum.kodi.tv/showthread.php?tid=344009

The new version only writes one playlist file, it gets all the episode id's for next up episodes dated before today using a single sql query (it may look fairly complex but i can break it down for anyone who is interested and wanted to make their own playlists), there is no issue with the "Special://" path which i had in my original script, all configuration is done at the top of the script. And it triggers widget refreshing by marking the oldest unwatched episode watched/unwatched.

So all you should really need to do is determine the path to the playlists folder and the database folder for your system and setup your kodi connection options.

python:
#!/usr/bin/env python
import requests
import json
import sys
import base64
import os, re, os.path

import sqlite3
con = sqlite3.connect('/home/path/.kodi/userdata/Database/MyVideos116.db')
cur = con.cursor()

kodi_credentials = b'user:password' 
kodi_encoded_credentials = base64.b64encode(kodi_credentials) 
kodi_authorization = b'Basic ' + kodi_encoded_credentials 
kodi_header = { 'Content-Type': 'application/json', 'Authorization': kodi_authorization } 
kodi_ip = '127.0.0.1'
kodi_port = '8080'
kodi_url = 'http://' + kodi_ip + ':' + kodi_port + '/jsonrpc'

playlist_path = '/home/path/.kodi/userdata/playlists/video/'

#in progress + next up episodes - episodeid + path
sql_result = (cur.execute(" select idepisode,c18,c13,show from (SELECT files.idfile, episode.c00, episode.c18, episode.c12, episode.c13, episode.c05, idepisode, tvshow.c00 as show, episode.idShow, playcount, lastplayed from episode, files, tvshow where episode.idfile=files.idfile and episode.idshow = tvshow.idshow and files.idfile in (select idfile from(SELECT min(files.idfile) as idfile, min(episode.c05) as firstaired, tvshow.c00 FROM  episode, files, tvshow where episode.idfile=files.idfile and episode.idshow = tvshow.idshow and playcount is null   GROUP BY tvshow.c00) )  ) where idshow in (select idshow from(SELECT files.idfile, episode.c00, episode.c05, idepisode, tvshow.c00, episode.idShow, playcount, lastplayed from episode, files, tvshow where episode.idfile=files.idfile and episode.idshow = tvshow.idshow and files.idfile in (select idfile from(SELECT max(files.idfile) as idfile, max(episode.c05) as firstaired, tvshow.c00 FROM  episode, files, tvshow where episode.idfile=files.idfile and episode.idshow = tvshow.idshow and playcount>0   GROUP BY tvshow.c00) ) )) and c05 < date('now') order by c05 desc").fetchall())

big_xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>' + "\n" + '<smartplaylist type="episodes">'  + "\n" 
big_xml = big_xml + '    <name>001_NEXT_EPISODES</name>' + "\n" + '    <match>one</match>'

for k in sql_result:
    episode_id = k[0]
    file_name = os.path.basename(k[1])
    big_xml = big_xml + "\n" + '    <rule field=\"filename\" operator=\"is\"><value>'+ file_name.replace('&','&amp;')  +'</value></rule>' 

big_xml = big_xml + "\n"+'    <order direction=\"descending\">year</order>' + "\n" +'</smartplaylist>'
f = open(playlist_path + "NEXT_EPISODES_PLAYLIST.xsp", "w")
f.write(big_xml)
f.close()

kodi_params = ('{"jsonrpc":"2.0","method":"VideoLibrary.SetEpisodeDetails","params":{"episodeid":' + str(episode_id)+',"playcount": 1},"id":"1"}')
kodi_response = requests.post(kodi_url, headers=kodi_header, data=kodi_params)
json_data = json.dumps(kodi_response.json(), indent=4, sort_keys=True)

kodi_params = ('{"jsonrpc":"2.0","method":"VideoLibrary.SetEpisodeDetails","params":{"episodeid":' + str(episode_id)+',"playcount": 0},"id":"1"}')
kodi_response = requests.post(kodi_url, headers=kodi_header, data=kodi_params)
json_data = json.dumps(kodi_response.json(), indent=4, sort_keys=True)
print(json_data)

cur.close()
exit()



RE: Next Up Playlist - Automatically generated + lightweight for widgets - Lunatixz - 2019-05-22

Curious, Why did you choose to access Kodi's DB directly instead of using json RPC?

Also if this is for a widget, why write a physical xml playlist? node didn't work?


RE: Next Up Playlist - Automatically generated + lightweight for widgets - henryjfry - 2019-05-22

(2019-05-22, 20:18)Lunatixz Wrote: Curious, Why did you choose to access Kodi's DB directly instead of using json RPC?

Also if this is for a widget, why write a physical xml playlist? node didn't work?

I was thinking about doing it as a node but im not entirely sure how that works so i would need to figure it out first.  I originally had it done in jsonrpc but i figured that doing it in sql would be more efficient as i don't want to have to wait any longer than i have to for the widget to refresh.
Also it was far easier for me to figure out how to filter to the next unwatched episode using sql, with json i started having to do loops through every single episode to find the first unwatched. And i do sql in my job so i know how to do stuff, so i figured why not.

Its for using with the skin helper service widgets, so not my own widgets or anything. Therefore, not knowing enough about addons and how to use the python xbmc module and internal functions i have no idea how i would populate these directly.

How would i use a node to populate the next up episodes into it? I installed library node editor and i had thought maybe the nodes are specific tables in sql so i could maybe create a new node and populate the sql table, but i dont think it works that way, correct me if im wrong.

So if i created a node can i add episodes directly to it? Could you point me to some help documents as all ive found about nodes is for the library node editor and these are barely more complex than playlists.

So yeah basically ive done it this way because i couldnt figure out any better way to do it without first learning how to build addons. And ive been hesitant to start building addons because ive got no idea how testing/addon development for kodi actually works.
Any time i try and import xbmc it just fails in python.


RE: Next Up Playlist - Automatically generated + lightweight for widgets - henryjfry - 2019-05-22

Doesnt the LazyTV addon generate a smart playlist too? I figured it was just a limitation in kodi that outside of the db kodi playlisting support is very poor.
Ive seen nothing in the hours of reading it took me to get this all working which suggests otherwise.


RE: Next Up Playlist - Automatically generated + lightweight for widgets - Lunatixz - 2019-05-22

(2019-05-22, 21:15)henryjfry Wrote: Doesnt the LazyTV addon generate a smart playlist too? I figured it was just a limitation in kodi that outside of the db kodi playlisting support is very poor.
Ive seen nothing in the hours of reading it took me to get this all working which suggests otherwise.

LazyTV was written a long time ago... what's available today, wasn't then. Kodi playlist support is not "very poor"; it's one of the most robust features.


RE: Next Up Playlist - Automatically generated + lightweight for widgets - Lunatixz - 2019-05-23

(2019-05-22, 21:09)henryjfry Wrote:
(2019-05-22, 20:18)Lunatixz Wrote: Curious, Why did you choose to access Kodi's DB directly instead of using json RPC?

Also if this is for a widget, why write a physical xml playlist? node didn't work?

I was thinking about doing it as a node but im not entirely sure how that works so i would need to figure it out first.     
https://kodi.wiki/view/Video_nodes
(2019-05-22, 21:09)henryjfry Wrote: I originally had it done in jsonrpc but i figured that doing it in sql would be more efficient as i don't want to have to wait any longer than i have to for the widget to refresh.
Also it was far easier for me to figure out how to filter to the next unwatched episode using sql, with json i started having to do loops through every single episode to find the first unwatched. And i do sql in my job so i know how to do stuff, so i figured why not.
Accessing Kodi's DB directly is unorthodox; jsonrpc is the gold standard.  "refresh" time is negligible... as for loops this all depends on your code and query; json allows filters along with parameters. This can help boil down the results.
(2019-05-22, 21:09)henryjfry Wrote: Its for using with the skin helper service widgets, so not my own widgets or anything. Therefore, not knowing enough about addons and how to use the python xbmc module and internal functions i have no idea how i would populate these directly.

How would i use a node to populate the next up episodes into it? I installed library node editor and i had thought maybe the nodes are specific tables in sql so i could maybe create a new node and populate the sql table, but i dont think it works that way, correct me if im wrong.
Depends on your exact needs; if its a widget for specific shows you can create a node or smartplaylist that lists a show by title and only displays episodes with a "0" playcount. then make sure it's sorted by episode number and or airdate. In some cases, python maybe needed (rarely) and in those cases writing a physical xml is resource heavy and not needed for a widget. You can use plugin listitems to fill skin widgets directly, no need for nodes or smartplaylists.
(2019-05-22, 21:09)henryjfry Wrote: So if i created a node can i add episodes directly to it? Could you point me to some help documents as all ive found about nodes is for the library node editor and these are barely more complex than playlists.
Yes and no... smartplaylists and nodes are better suited for matching criteria, not specific items. Smartplaylists and nodes are not the same as m3u, pls playlists where the latter is a queue playlist. If you are using python you can drop the need for smartplaylists and nodes. It's an unneeded step.
(2019-05-22, 21:09)henryjfry Wrote: So yeah basically ive done it this way because i couldnt figure out any better way to do it without first learning how to build addons. And ive been hesitant to start building addons because ive got no idea how testing/addon development for kodi actually works.
Any time i try and import xbmc it just fails in python.  

Addon development would ultimately be what you want... sure you can get away with the above code, however; I wouldn't recommend this method for the masses.

You can find support for addon development below:
https://forum.kodi.tv/forumdisplay.php?fid=26
https://kodi.wiki/view/Add-on_development


RE: Next Up Playlist - Automatically generated + lightweight for widgets - henryjfry - 2019-05-23

(2019-05-22, 23:42)Lunatixz Wrote:
(2019-05-22, 21:15)henryjfry Wrote: Doesnt the LazyTV addon generate a smart playlist too? I figured it was just a limitation in kodi that outside of the db kodi playlisting support is very poor.
Ive seen nothing in the hours of reading it took me to get this all working which suggests otherwise.
LazyTV was written a long time ago... what's available today, wasn't then. Kodi playlist support is not "very poor"; it's one of the most robust features.



I think we are taking about different things when we are talking about playlists in Kodi.

The Kodi internal playlist is great and I can add all the stuff I want with playlist.add but it's not persistent and you can't save it. At least not via JSON.

This posts talks about the same limitations I'm experiencing with Kodi playlists (ie smart playlists).

https://forum.kodi.tv/showthread.php?tid=330349&highlight=Node+tv

And by extension most of these limitations would extend to nodes. There are some more filtering options but you couldn't filter for example only the next 1 unwatched episode for TV shows in progress on one playlist (or node, from what I am reading).

So can add-ons create nodes with more internal filtering options?
How do add-ons create nodes on the fly?
Because I'm thinking this would need to be done by writing XML files, which is basically what I'm doing.

The documentation you linked to (which I had already seen) is not very helpful in clearing that up and expanding on what nodes are other than special smart playlists.


RE: Next Up Playlist - Automatically generated + lightweight for widgets - henryjfry - 2019-05-23

I have seen some JSON examples with filtering now, which I wasn't aware you could do.
So yes I could get tvshowid for all shows in progress and then request the unwatched episodes for each show and limit to 1 sorted by airdate and return the episodes I want in 2 steps? But this is still one more step than a single SQL call.

With regard to nodes/smart playlists it is my understanding that episodes lists cannot be sorted by airdate?
It just won't let you, you can sort by year but I'm pretty sure that's show year and not airdate.
And you have said sort by episode number and/or airdate.
You can't put multiple sort items it's one or the other, and for episodes it's a very limited selection of mostly not terribly useful sorting options.

If writing physical XML files is resource intensive how else would I create a smart playlist or a node?

What are plugin list items, are these add-on specific and internal to Kodi, ie cannot be accessed by JSON.

I have read so many forum posts and the same wiki pages over and over again and there is nothing I have found that suggests that what I want can be achieved much better than what I'm already doing. (Without learning a whole lot more python and a lot more about add-ons)

I don't want my widgets to be live updated by some add-on every time, that's basically what skin helper service does and it can be a bit slow.
I want a playlist stored across reboots which contains only the next up episodes so widget refreshes are as fast as possible.

If episodes smart playlists allowed more sorting and filtering options this would be totally achievable using just one XML smart playlist.

Oh and I would use an m3u or a pls playlist as these would allow absolute ordering, if they could also link to episodes in the library and have full metadata, fanart, info and all that stuff.

But you can't, so it's back to writing XML files.

If there is some other method that can be done without having to learn how to make add-ons and how the skin helper service widget actually works, I'd love to hear it.

But until I figure out how to start doing that and run and debug whatever add-on I start building it has the be methods which can run without "import xbmc".

(2019-05-23, 00:04)Lunatixz Wrote:
(2019-05-22, 21:09)henryjfry Wrote:
(2019-05-22, 20:18)Lunatixz Wrote: Curious, Why did you choose to access Kodi's DB directly instead of using json RPC?

Also if this is for a widget, why write a physical xml playlist? node didn't work?

I was thinking about doing it as a node but im not entirely sure how that works so i would need to figure it out first.     
https://kodi.wiki/view/Video_nodes
(2019-05-22, 21:09)henryjfry Wrote: I originally had it done in jsonrpc but i figured that doing it in sql would be more efficient as i don't want to have to wait any longer than i have to for the widget to refresh.
Also it was far easier for me to figure out how to filter to the next unwatched episode using sql, with json i started having to do loops through every single episode to find the first unwatched. And i do sql in my job so i know how to do stuff, so i figured why not.
Accessing Kodi's DB directly is unorthodox; jsonrpc is the gold standard.  "refresh" time is negligible... as for loops this all depends on your code and query; json allows filters along with parameters. This can help boil down the results.
(2019-05-22, 21:09)henryjfry Wrote: Its for using with the skin helper service widgets, so not my own widgets or anything. Therefore, not knowing enough about addons and how to use the python xbmc module and internal functions i have no idea how i would populate these directly.

How would i use a node to populate the next up episodes into it? I installed library node editor and i had thought maybe the nodes are specific tables in sql so i could maybe create a new node and populate the sql table, but i dont think it works that way, correct me if im wrong.
Depends on your exact needs; if its a widget for specific shows you can create a node or smartplaylist that lists a show by title and only displays episodes with a "0" playcount. then make sure it's sorted by episode number and or airdate. In some cases, python maybe needed (rarely) and in those cases writing a physical xml is resource heavy and not needed for a widget. You can use plugin listitems to fill skin widgets directly, no need for nodes or smartplaylists.
(2019-05-22, 21:09)henryjfry Wrote: So if i created a node can i add episodes directly to it? Could you point me to some help documents as all ive found about nodes is for the library node editor and these are barely more complex than playlists.
Yes and no... smartplaylists and nodes are better suited for matching criteria, not specific items. Smartplaylists and nodes are not the same as m3u, pls playlists where the latter is a queue playlist. If you are using python you can drop the need for smartplaylists and nodes. It's an unneeded step.
(2019-05-22, 21:09)henryjfry Wrote: So yeah basically ive done it this way because i couldnt figure out any better way to do it without first learning how to build addons. And ive been hesitant to start building addons because ive got no idea how testing/addon development for kodi actually works.
Any time i try and import xbmc it just fails in python.  

Addon development would ultimately be what you want... sure you can get away with the above code, however; I wouldn't recommend this method for the masses.

You can find support for addon development below:
https://forum.kodi.tv/forumdisplay.php?fid=26
https://kodi.wiki/view/Add-on_development



RE: Next Up Playlist - Automatically generated + lightweight for widgets - Lunatixz - 2019-05-23

(2019-05-23, 09:45)henryjfry Wrote:
(2019-05-22, 23:42)Lunatixz Wrote:
(2019-05-22, 21:15)henryjfry Wrote: Doesnt the LazyTV addon generate a smart playlist too? I figured it was just a limitation in kodi that outside of the db kodi playlisting support is very poor.
Ive seen nothing in the hours of reading it took me to get this all working which suggests otherwise.
LazyTV was written a long time ago... what's available today, wasn't then. Kodi playlist support is not "very poor"; it's one of the most robust features.        



I think we are taking about different things when we are talking about playlists in Kodi.

The Kodi internal playlist is great and I can add all the stuff I want with playlist.add but it's not persistent and you can't save it. At least not via JSON.

This posts talks about the same limitations I'm experiencing with Kodi playlists (ie smart playlists).

https://forum.kodi.tv/showthread.php?tid=330349&highlight=Node+tv

And by extension most of these limitations would extend to nodes. There are some more filtering options but you couldn't filter for example only the next 1 unwatched episode for TV shows in progress on one playlist (or node, from what I am reading).

So can add-ons create nodes with more internal filtering options?
How do add-ons create nodes on the fly?
Because I'm thinking this would need to be done by writing XML files, which is basically what I'm doing.

The documentation you linked to (which I had already seen) is not very helpful in clearing that up and expanding on what nodes are other than special smart playlists.        
We are talking about the same thing... I'm trying to point out the confusion. Smart Playlists are not to be confused with m3u playlists... ie smart playlists filter based on matched criteria. They're rarely used to queue items.

Playlist.add has nothing to do with smart playlists... if you wanted to create a permanent "playlist" on par with playlist.add you'd use a m3u which can be directly imported to the player. https://codedocs.xyz/xbmc/xbmc/group__python___play_list.html#gadb9c48b725cb3d3de3d4a17bbc5d7fcb

The confusion is in the term "playlist" which has a broad terminology. I suggest since you want a "widget" look into plugin creation and abandon writing a playlist file or at the least try replacing your direct access DB code with json queries; which is safer for long term use.

Some of your observations on what's achievable and how; are limited... When you say things like "But you can't"; I'd rather not argue on the contrary.

Good Luck


RE: Next Up Playlist - Automatically generated + lightweight for widgets - henryjfry - 2019-05-23

Well is it possible to have a saved playlist file (m3u, m3u8, pls or any other playlist type) which can pickup Kodi metadata as well as having specific ordering?

Even if I have to write the metadata into the playlist at creation?

Because Ive tried looking for this sort of information and it seems geared towards mp3s and maybe including album art but that's about it.

If there is any documentation anywhere that shows how to do this id love to read it. I have looked.

I already have a widget but it's slow to update when using the built in "next up" widget. Updating the widget from a playlist is very fast, hence me taking that approach.

(2019-05-23, 14:49)Lunatixz Wrote:
(2019-05-23, 09:45)henryjfry Wrote:
(2019-05-22, 23:42)Lunatixz Wrote: LazyTV was written a long time ago... what's available today, wasn't then. Kodi playlist support is not "very poor"; it's one of the most robust features.        



I think we are taking about different things when we are talking about playlists in Kodi.

The Kodi internal playlist is great and I can add all the stuff I want with playlist.add but it's not persistent and you can't save it. At least not via JSON.

This posts talks about the same limitations I'm experiencing with Kodi playlists (ie smart playlists).

https://forum.kodi.tv/showthread.php?tid=330349&highlight=Node+tv

And by extension most of these limitations would extend to nodes. There are some more filtering options but you couldn't filter for example only the next 1 unwatched episode for TV shows in progress on one playlist (or node, from what I am reading).

So can add-ons create nodes with more internal filtering options?
How do add-ons create nodes on the fly?
Because I'm thinking this would need to be done by writing XML files, which is basically what I'm doing.

The documentation you linked to (which I had already seen) is not very helpful in clearing that up and expanding on what nodes are other than special smart playlists.        
We are talking about the same thing... I'm trying to point out the confusion. Smart Playlists are not to be confused with m3u playlists... ie smart playlists filter based on matched criteria. They're rarely used to queue items.

Playlist.add has nothing to do with smart playlists... if you wanted to create a permanent "playlist" on par with playlist.add you'd use a m3u which can be directly imported to the player. https://codedocs.xyz/xbmc/xbmc/group__python___play_list.html#gadb9c48b725cb3d3de3d4a17bbc5d7fcb

The confusion is in the term "playlist" which has a broad terminology. I suggest since you want a "widget" look into plugin creation and abandon writing a playlist file or at the least try replacing your direct access DB code with json queries; which is safer for long term use.

Some of your observations on what's achievable and how; are limited... When you say things like "But you can't"; I'd rather not argue on the contrary.

Good Luck



RE: Next Up Playlist - Automatically generated + lightweight for widgets - Lunatixz - 2019-05-23

(2019-05-23, 15:46)henryjfry Wrote: Well is it possible to have a saved playlist file (m3u, m3u8, pls or any other playlist type) which can pickup Kodi metadata as well as having specific ordering?

Even if I have to write the metadata into the playlist at creation?

Because Ive tried looking for this sort of information and it seems geared towards mp3s and maybe including album art but that's about it.

If there is any documentation anywhere that shows how to do this id love to read it. I have looked.

I already have a widget but it's slow to update when using the built in "next up" widget. Updating the widget from a playlist is very fast, hence me taking that approach.
(2019-05-23, 14:49)Lunatixz Wrote:
(2019-05-23, 09:45)henryjfry Wrote: I think we are taking about different things when we are talking about playlists in Kodi.

The Kodi internal playlist is great and I can add all the stuff I want with playlist.add but it's not persistent and you can't save it. At least not via JSON.

This posts talks about the same limitations I'm experiencing with Kodi playlists (ie smart playlists).

https://forum.kodi.tv/showthread.php?tid=330349&highlight=Node+tv

And by extension most of these limitations would extend to nodes. There are some more filtering options but you couldn't filter for example only the next 1 unwatched episode for TV shows in progress on one playlist (or node, from what I am reading).

So can add-ons create nodes with more internal filtering options?
How do add-ons create nodes on the fly?
Because I'm thinking this would need to be done by writing XML files, which is basically what I'm doing.

The documentation you linked to (which I had already seen) is not very helpful in clearing that up and expanding on what nodes are other than special smart playlists.        
We are talking about the same thing... I'm trying to point out the confusion. Smart Playlists are not to be confused with m3u playlists... ie smart playlists filter based on matched criteria. They're rarely used to queue items.

Playlist.add has nothing to do with smart playlists... if you wanted to create a permanent "playlist" on par with playlist.add you'd use a m3u which can be directly imported to the player. https://codedocs.xyz/xbmc/xbmc/group__python___play_list.html#gadb9c48b725cb3d3de3d4a17bbc5d7fcb

The confusion is in the term "playlist" which has a broad terminology. I suggest since you want a "widget" look into plugin creation and abandon writing a playlist file or at the least try replacing your direct access DB code with json queries; which is safer for long term use.

Some of your observations on what's achievable and how; are limited... When you say things like "But you can't"; I'd rather not argue on the contrary.

Good Luck
Yes, meta in a m3u is possible using the #KODIPROP flag; sort is dictated by the list order.

As for a physical playlist; IMO the logic is faulty, you want a static list for dynamic content, ie episode watch status will change after view (your list grows stale quickly). If your widget is "slow" think about Memoization.... balance stale data with practical refresh rates.


RE: Next Up Playlist - Automatically generated + lightweight for widgets - henryjfry - 2019-05-23

If and when I actually start trying to figure out how to build an add-on then I'll definitely look into the various pointers you have posted.

But for now what I'm doing is triggering my playlist generator script on playback ended and then causing the widgets to reload, which keeps everything up to date.

So a non dynamic list works well enough for what I want. Obviously other methods might be better. But as I'm the one who is doing this it has to be methods I understand.
And any add-on/built in methods, I currently don't understand.

I find any "help" posts and a lot of stuff on the wiki to be pretty unhelpful.
As it's usually the syntax I'm having trouble with not the actual command. Add to this that I don't have a debugger and am debugging everything with print statements it makes this a pretty frustrating experience.

But that is literally the first mention of this KODIPROP flag I have seen anywhere.

Perhaps those more familiar with python can read this stuff easier but not me.
That's why I've been posting my full scripts every time because if someone is trying to figure out how to do something I don't wa t them pulling their hair our like I have been.


(2019-05-23, 15:57)Lunatixz Wrote:
(2019-05-23, 15:46)henryjfry Wrote: Well is it possible to have a saved playlist file (m3u, m3u8, pls or any other playlist type) which can pickup Kodi metadata as well as having specific ordering?

Even if I have to write the metadata into the playlist at creation?

Because Ive tried looking for this sort of information and it seems geared towards mp3s and maybe including album art but that's about it.

If there is any documentation anywhere that shows how to do this id love to read it. I have looked.

I already have a widget but it's slow to update when using the built in "next up" widget. Updating the widget from a playlist is very fast, hence me taking that approach.
(2019-05-23, 14:49)Lunatixz Wrote: We are talking about the same thing... I'm trying to point out the confusion. Smart Playlists are not to be confused with m3u playlists... ie smart playlists filter based on matched criteria. They're rarely used to queue items.

Playlist.add has nothing to do with smart playlists... if you wanted to create a permanent "playlist" on par with playlist.add you'd use a m3u which can be directly imported to the player. https://codedocs.xyz/xbmc/xbmc/group__python___play_list.html#gadb9c48b725cb3d3de3d4a17bbc5d7fcb

The confusion is in the term "playlist" which has a broad terminology. I suggest since you want a "widget" look into plugin creation and abandon writing a playlist file or at the least try replacing your direct access DB code with json queries; which is safer for long term use.

Some of your observations on what's achievable and how; are limited... When you say things like "But you can't"; I'd rather not argue on the contrary.

Good Luck
Yes, meta in a m3u is possible using the #KODIPROP flag; sort is dictated by the list order.

As for a physical playlist; IMO the logic is faulty, you want a static list for dynamic content, ie episode watch status will change after view (your list grows stale quickly). If your widget is "slow" think about Memoization.... balance stale data with practical refresh rates.



RE: Next Up Playlist - Automatically generated + lightweight for widgets - Lunatixz - 2019-05-23

(2019-05-23, 18:29)henryjfry Wrote: If and when I actually start trying to figure out how to build an add-on then I'll definitely look into the various pointers you have posted.

But for now what I'm doing is triggering my playlist generator script on playback ended and then causing the widgets to reload, which keeps everything up to date.

So a non dynamic list works well enough for what I want. Obviously other methods might be better. But as I'm the one who is doing this it has to be methods I understand.
And any add-on/built in methods, I currently don't understand.

I find any "help" posts and a lot of stuff on the wiki to be pretty unhelpful.
As it's usually the syntax I'm having trouble with not the actual command. Add to this that I don't have a debugger and am debugging everything with print statements it makes this a pretty frustrating experience.

But that is literally the first mention of this KODIPROP flag I have seen anywhere.

Perhaps those more familiar with python can read this stuff easier but not me.
That's why I've been posting my full scripts every time because if someone is trying to figure out how to do something I don't wa t them pulling their hair our like I have been.
 
(2019-05-23, 15:57)Lunatixz Wrote:
(2019-05-23, 15:46)henryjfry Wrote: Well is it possible to have a saved playlist file (m3u, m3u8, pls or any other playlist type) which can pickup Kodi metadata as well as having specific ordering?

Even if I have to write the metadata into the playlist at creation?

Because Ive tried looking for this sort of information and it seems geared towards mp3s and maybe including album art but that's about it.

If there is any documentation anywhere that shows how to do this id love to read it. I have looked.

I already have a widget but it's slow to update when using the built in "next up" widget. Updating the widget from a playlist is very fast, hence me taking that approach.
Yes, meta in a m3u is possible using the #KODIPROP flag; sort is dictated by the list order.

As for a physical playlist; IMO the logic is faulty, you want a static list for dynamic content, ie episode watch status will change after view (your list grows stale quickly). If your widget is "slow" think about Memoization.... balance stale data with practical refresh rates.
Which is why I brought up the issues with your script... once it goes beyond your personal use... it's worth doing correctly? or at least informing others less knowledgeable about its shortcomings. IMO running this type of script on player stop is a little nutty; It will thrash your storage device... or worse yet your NAND.

Documentation is a little hard to come by; However, you'll find a lot of devs here willing to help your coding projects... good luck with yours.


RE: Next Up Playlist - Automatically generated + lightweight for widgets - henryjfry - 2019-05-23

Hey can you provide some guidance on how to use the KODIPROP option in a M3U playlist?

Because im trying to provide kodi metadata and its not picking up episodeid, showid, showtitle, season, episode, basically anything I have tried.

#EXTM3U
#EXTINF:-1
#KODIPROP:xbmc.showtitle=Show Title
#KODIPROP:xbmc.season=3
#KODIPROP:xbmc.episode=2
#KODIPROP:xbmc.thumb=http://www.thetvdb.com/banners/episodes/72521/89378.jpg
/path/to/file.file

If i could get this method to work it might be useful for my purposes.

Also i tried creating some sets of filtered tv show playlists, so only showing unwatched episodes and then filtering so only the oldest, ie next, unwatched episode is shown on each playlist.  Then i linked these in one main playlist.
However the main playlist then shows all the unwatched episodes for a given tv show, completely ignoring the limit on the individual playlists.
Why would it do that?


RE: Next Up Playlist - Automatically generated + lightweight for widgets - CorentinB - 2020-04-24

Hey @henryjfry , I am trying to get your script running, do you still use this one or did you apply any change since?