Kodi Community Forum
[RELEASE] Random and last items smartplaylist script for Skins - Printable Version

Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Skinning (https://forum.kodi.tv/forumdisplay.php?fid=12)
+---- Forum: Skin helper addons (https://forum.kodi.tv/forumdisplay.php?fid=300)
---- Thread: [RELEASE] Random and last items smartplaylist script for Skins (/showthread.php?tid=122448)

[RELEASE] Random and last items smartplaylist script for Skins - mikebzh44 - 2012-02-10


I have written a script that scan Video library and return movies (Random or recently added) that match video smartplaylist.

Frodo ONLY

Release version is located in offcial repo (can't be installed through normal addon browser or is auto pulled when installed skins)
For new skin labels see readme

Github page:



Parameters are :

type = Movie/Episode/Music       | Script will request Movie database or Episode database
                                 | (/!\ Caution : upper and lower case are important)
limit = #                        | # to limit returned results (default=10)
method = Last/Random             | Last to get last added items and Random to get random items
playlist = PathAndNameOfPlaylist | Name of the smartplaylist like special://masterprofile/playlists/video/children.xsp
                                 | or empty to request global database
                                 | If you set this parameter, you don't need to set type= because type will be read from playlist file
menu = NameOfMenu                | Name of custom or standard menu which display the widget
unwatched = True/False           | unwatched=True to filter only unwatched items
resume = True/False              | resume=True to filter only partially watched items
propertie = NameOfTheProperty    | You can overwrite the default properties names Playlist<method><type><menu> by using this parameter
                                 | example : propertie=CustomMenu1Widget1

/!\ CAUTION /!\
resume=True can slow down script when working on playlist

Script call :

As you set playlist= parameter, type=Movie is no longer needed.

Properties returned to Home window (id : 10000) are :

* type=Movie

Playlist<method>Movie<menu>.Type = Movie
Playlist<method>Movie<menu>.Count = Number of movies in library or playlist
Playlist<method>Movie<menu>.Unwatched = Number of unwatched movies in library or playlist
Playlist<method>Movie<menu>.Watched = Number of watched movies in library or playlist
Playlist<method>Movie<menu>.<# of movie>.Rating = Movie N°# rate
Playlist<method>Movie<menu>.<# of movie>.Plot = Movie N°# plot
Playlist<method>Movie<menu>.<# of movie>.RunningTime = Movie N°# running time
Playlist<method>Movie<menu>.<# of movie>.Path = Movie N°# path (eg : C:\Movies\Movie1\Movie1.mkv)
Playlist<method>Movie<menu>.<# of movie>.Rootpath = Movie N°# root path (eg : C:\Movies\Movie1\)
Playlist<method>Movie<menu>.<# of movie>.Fanart = Movie N°# fanart
Playlist<method>Movie<menu>.<# of movie>.Thumb = Movie N°# thumbnail
Playlist<method>Movie<menu>.<# of movie>.Title = Movie N°# title
Playlist<method>Movie<menu>.<# of movie>.Year = Movie N°# year
Playlist<method>Movie<menu>.<# of movie>.Trailer = Movie N°# trailer
Playlist<method>Movie<menu>.<# of movie>.Resolution = Movie N°# (values are blank, 480, 540, 576, 720, 1080)

* type=Episode

Playlist<method>Episode<menu>.Type = Episode
Playlist<method>Episode<menu>.Count = Number of episodes in library or playlist
Playlist<method>Episode<menu>.Unwatched = Number of unwatched episodes in library or playlist
Playlist<method>Episode<menu>.Watched = Number of watched episodes in library or playlist
Playlist<method>Episode<menu>.TvShows = Number of TV shows in library or playlist
Playlist<method>Episode<menu>.<# of episode>.Rating = Episode N°# rate
Playlist<method>Episode<menu>.<# of episode>.Plot = Episode N°# plot
Playlist<method>Episode<menu>.<# of episode>.RunningTime = Episode N°# running time
Playlist<method>Episode<menu>.<# of episode>.Path = Episode N°# path (ex : C:\TVShows\TVShow1\Season1\Episode1.avi)
Playlist<method>Episode<menu>.<# of episode>.Rootpath = Episode N°# root path (ex : C:\TVShows\TVShow1\)
Playlist<method>Episode<menu>.<# of episode>.Fanart = Episode N°# fanart
Playlist<method>Episode<menu>.<# of episode>.Thumb = Episode N°# thumbnail
Playlist<method>Episode<menu>.<# of episode>.ShowTitle = Episode N°# TV Show title
Playlist<method>Episode<menu>.<# of episode>.EpisodeTitle = Episode N°# title
Playlist<method>Episode<menu>.<# of episode>.EpisodeNo = Episode N°# (format sXXeXX)
Playlist<method>Episode<menu>.<# of episode>.EpisodeSeason = Episode N°# season number
Playlist<method>Episode<menu>.<# of episode>.EpisodeNumber = Episode N°# number
Playlist<method>Episode<menu>.<# of episode>.TVShowFanart = TV Show fanart for episode N°#
Playlist<method>Episode<menu>.<# of episode>.TVShowThumb = TV Show thumbnail for episode N°#

* type=Music

Playlist<method>Music<menu>.Type = Music
Playlist<method>Music<menu>.Artists = Number of artists in library or playlist
Playlist<method>Music<menu>.Albums = Number of albums in library or playlist
Playlist<method>Music<menu>.Songs = Nombre of songs in library or playlist
Playlist<method>Music<menu>.<# of album>.Album = Album N°# title
Playlist<method>Music<menu>.<# of album>.Artist = Album N°# artist name
Playlist<method>Music<menu>.<# of album>.Year = Album N°# year
Playlist<method>Music<menu>.<# of album>.Fanart = Album N°# fanart
Playlist<method>Music<menu>.<# of album>.Thumb = Album N°# thumbnail
Playlist<method>Music<menu>.<# of album>.ArtistPath = Album N°# artist path (eg : C:\Music\Artist1)
Playlist<method>Music<menu>.<# of album>.AlbumPath = Album N°# path (ex : C:\Music\Artist1\Album1)
Playlist<method>Music<menu>.<# of album>.AlbumDesc = Album N°# description
Playlist<method>Music<menu>.<# of album>.PlayPath = Album N°# for playing (musicdb://3/1/)

So with the precedent calling, properties will be :


Script is still in development.

- [Add] New properties TVShowThumb and TVShowFanart to get TV Show thumbnail and fanart of the episode

- [Fix] Albums properties were not cleared properly
- [Add] New property AlbumDesc

- [Fix] Episode title is now based on title and not on label because of some JSON changes :

- [Fix] Statistic for songs was wrong on library or albums playlist

- [Add] The script now manage Music (playlists or library).
        See README.txt or LISEZMOI.txt for details.

- [Add] Property .Type is returned. Value is Movie or Episode.
        Helpfull if you use script with playlist and did not specifie type= parameter so script will get type from playlist.

- [Fix] If video has no stream details, resolution is set to blank

- [Add] New property Resolution for Movies. Values are blank, 480, 540, 576, 720, 1080

- [Fix] When type= was not set with playlist, properties name was unwellformed

- [Add] If playlist= is set and type= is not seet then playlist type is read from playlist file

- [Add] Properties are cleared only if needed to avoid blinking effect in widgets

- [Fix] Properties were not cleaned between two call

- [Fix] resume= and watched= were inefficient with playlists
- [Add] Propertie TvShows set to number of TV Shows in library or playlist

- [Fix] Season number printed in 2 digit only if needed
- [Fix] Properties Count, Watched and Unwatched = 0 if playlist or library is empty

- [Add] Script can manage tv shows and episodes playlist
- [Add] Propertie Rootpath to get the directory of the movie or the tvshow (to display extrafanarts and so on)

- [Fix] resume= is unable but can slow down the script (see README.txt or LISEZMOI.txt)
- [Add] You can now get last added or random episodes from series (work only on Library not on Playlist)

- [Fix] Handle exception when playlist is empty or fetching information failed
- resume= parameter is disable because of a bug in method GetDirectory of JSONRPC API

- [Add] Playlist<method>Movie<menu>.Unwatched return the number of unwatched movies in the library/playlist
- [Add] Playlist<method>Movie<menu>.Watched return the number of watched movies in the library/playlist

- [Fix] Scanning movies of movie set always scan same set (constant instead af variable in the code).
- [Add] Playlist<method>Movie<menu>.Count now return the number of movies in the library/playlist

- [Fix] Trailer is now provide properly

- [Fix] Last added movies really return last added movies. Movies in set are handle properly.
- [Added] New options
              True : Display only unwatched movies
              False : Display watched and unwatched movies

              True : Display only movie partially watched movie
              False : Display all movies

- Use Files.GetDirectory instead of parsing XML playlist to retrieve movies

- from v3.0.7 of RandomItems script, add playlist filters

Download : http://passion-xbmc.org/addons/Download.php/script.randomandlastitems/script.randomandlastitems-1.2.5.zip

- fmronan - 2012-02-10

I like that with my custom menu for childrenNod

- mikebzh44 - 2012-02-10


I'm rewritting the all script to avoid scanning rules in the playlist file.

Now I'm using Files.GetDirectory to get directly the list of movies in the playlist.

So if a skinner want to use it, he can test with the actual version and upgrade to the new one when I will release it, calling parameters will not change.

- mikebzh44 - 2012-02-10

Version 1.0.1 released.

Code rewritten in ordre to use function JSONRPC Files.GetDirectory (return movie list for playlist) instead of parsing XML playlist to analyse rules and test if each movie match or not the rules.

With this version, combined playlists (playlist of playlists) should work (not tested) :


- butchabay - 2012-02-10

Great work man !!!

So the user will be forced to name his playlist in order on how the skinner will call the script?

I just think every skinner should use a defined naming rule else there will be trouble while switching skin or ?

Thanx again for this really nice feature !

- LAW-Mastermind - 2012-02-10

Hope this will be integrated in many Skins, so we have seperate Categories now Smile

- mikebzh44 - 2012-02-10

No, skinner have to open a window displaying the differents playlists defined and let the user choose one.

I will make some screenshot from Glass.

- Martijn - 2012-02-10

Seems to be same language naming problem in your addon.xml
You declare "en" twice instead of "en"and "fr"

To be truly useful this should also be in the offcial XBMC-repo and not only in passion-repo (after you are certain things work like they should)

(this also counts for other script as well like the movie set add-on)

- mikebzh44 - 2012-02-10

Oups ! addon.xml corrected Wink

I don't know how to publish this script to official XBMC repo.

- mikebzh44 - 2012-02-10


How to set up playlist in Glass :




If you don't understand the settings, fmronan (skinner of Glass) will give you some tips.

- Martijn - 2012-02-10

mikebzh44 Wrote:Oups ! addon.xml corrected Wink

I don't know how to publish this script to official XBMC repo.
Well let's say a minor glitch Wink

Explained here on how to send to xbmc repo:

It's not that difficult. Even I did manage to do it Wink
Just make sure all is functioning like it should and let people test it before sending.

- mikebzh44 - 2012-02-10

Yes, I will wait few days before posting on official repository Wink

- Hitcher - 2012-02-10

So if the user has a custom playlist (ie Kids) we can use this script to display the latest added items to that playlist in the same way we currently do for the standard library?

- mikebzh44 - 2012-02-10

Yes, script can provide latest added movies or random movies from any playlist or both (with a double call) as in Glass :


"Fims aléatoires" = "Random movies"
"Derniers films" = "Lastest movies"

- Hitcher - 2012-02-10

Very useful, hopefully it'll get on the official repo as Martijn suggested.

PS. A readme is always handy in the addon.

This forum uses Lukasz Tkacz MyBB addons.