[RELEASE] Random and last items smartplaylist script for Skins

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
mikebzh44 Offline
Posting Freak
Posts: 1,790
Joined: Nov 2011
Reputation: 48
Location: Nantes - France
Post: #1
Hello.

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)
http://mirrors.xbmc.org/addons/frodo/
For new skin labels see readme

Github page:
https://github.com/XBMC-Addons/script.ra...dlastitems

------------------------------------------------------------

Eden ONLY


Parameters are :

Code:
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 :
Code:
XBMC.RunScript(script.RandomAndLastItems,type=Movie,limit=10,method=Random,playl​ist=special://masterprofile/playlists/video/children.xsp,menu=Menu1)

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

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

Code:
* 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 :

Code:
PlaylistRandomMovieMenu1.Count
PlaylistRandomMovieMenu1.1.Title
...
...
PlaylistRandomMovieMenu1.10.Title

Script is still in development.

Changelog
Code:
v1.2.5
- [Add] New properties TVShowThumb and TVShowFanart to get TV Show thumbnail and fanart of the episode

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

v1.2.3
- [Fix] Episode title is now based on title and not on label because of some JSON changes :
http://forum.xbmc.org/showthread.php?tid=113702&pid=1047340&highlight=episodetitle#pid1049580

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

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

v1.2.0
- [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.

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

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

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

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

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

v1.1.4
- [Fix] Properties were not cleaned between two call

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

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

v1.1.1
- [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)

v1.1.0
- [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)

v1.0.6
- [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

v1.0.5
- [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

v1.0.4
- [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

v1.0.3
- [Fix] Trailer is now provide properly

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

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

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

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

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

Sorry for my english, but, you know, I'm French so ...

(This post was last modified: 2013-03-29 16:02 by Martijn.)
find quote
fmronan Offline
Fan
Posts: 600
Joined: Dec 2010
Reputation: 4
Post: #2
I like that with my custom menu for childrenNod
[Image: 1328873809-screenshot135.png]
find quote
mikebzh44 Offline
Posting Freak
Posts: 1,790
Joined: Nov 2011
Reputation: 48
Location: Nantes - France
Post: #3
Well.

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.

Sorry for my english, but, you know, I'm French so ...

find quote
mikebzh44 Offline
Posting Freak
Posts: 1,790
Joined: Nov 2011
Reputation: 48
Location: Nantes - France
Post: #4
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) :

http://wiki.xbmc.org/index.php?title=Sma..._Playlists

Sorry for my english, but, you know, I'm French so ...

find quote
butchabay Offline
Skilled Skinner
Posts: 3,827
Joined: Mar 2010
Reputation: 75
Location: Planet Crematoria
Post: #5
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 !
find quote
LAW-Mastermind Offline
Member
Posts: 98
Joined: Sep 2008
Reputation: 0
Location: Germany
Post: #6
Hope this will be integrated in many Skins, so we have seperate Categories now Smile
find quote
mikebzh44 Offline
Posting Freak
Posts: 1,790
Joined: Nov 2011
Reputation: 48
Location: Nantes - France
Post: #7
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.

Sorry for my english, but, you know, I'm French so ...

find quote
Martijn Offline
Team Kodi
Posts: 11,606
Joined: Jul 2011
Reputation: 167
Location: Dawn of time
Post: #8
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)

Always read the XBMC online-manual, FAQ and search the forums before posting.
Do NOT e-mail Team-XBMC members asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting, make sure you read this first

For your mediacenter artwork go to
[Image: fanarttv.png]
find quote
mikebzh44 Offline
Posting Freak
Posts: 1,790
Joined: Nov 2011
Reputation: 48
Location: Nantes - France
Post: #9
Oups ! addon.xml corrected Wink

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

Sorry for my english, but, you know, I'm French so ...

find quote
mikebzh44 Offline
Posting Freak
Posts: 1,790
Joined: Nov 2011
Reputation: 48
Location: Nantes - France
Post: #10
@butchabay

How to set up playlist in Glass :

[Image: 1328892836-screenshot007.png]

[Image: 1328892907-screenshot008.png]

[Image: 1328892925-screenshot009.png]

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

Sorry for my english, but, you know, I'm French so ...

find quote
Martijn Offline
Team Kodi
Posts: 11,606
Joined: Jul 2011
Reputation: 167
Location: Dawn of time
Post: #11
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:
http://wiki.xbmc.org/index.php?title=Off...repository

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.

Always read the XBMC online-manual, FAQ and search the forums before posting.
Do NOT e-mail Team-XBMC members asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting, make sure you read this first

For your mediacenter artwork go to
[Image: fanarttv.png]
find quote
mikebzh44 Offline
Posting Freak
Posts: 1,790
Joined: Nov 2011
Reputation: 48
Location: Nantes - France
Post: #12
Yes, I will wait few days before posting on official repository Wink

Sorry for my english, but, you know, I'm French so ...

find quote
Hitcher Offline
Skilled Skinner
Posts: 10,875
Joined: Aug 2007
Reputation: 101
Location: Eastleigh, UK
Post: #13
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?
find quote
mikebzh44 Offline
Posting Freak
Posts: 1,790
Joined: Nov 2011
Reputation: 48
Location: Nantes - France
Post: #14
Yes, script can provide latest added movies or random movies from any playlist or both (with a double call) as in Glass :

[Image: 1328873809-screenshot135.png]

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

Sorry for my english, but, you know, I'm French so ...

find quote
Hitcher Offline
Skilled Skinner
Posts: 10,875
Joined: Aug 2007
Reputation: 101
Location: Eastleigh, UK
Post: #15
Very useful, hopefully it'll get on the official repo as Martijn suggested.

PS. A readme is always handy in the addon.
find quote
Post Reply