Kodi Community Forum

Full Version: [RELEASE] Random and last items smartplaylist script for Skins
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Sorry a noob question

I want the script to get one movie from the IMDB Top 250.xsp but have no idea how to code it but below is what I have so far!

I think I put the "XBMC.RunScript(script.randomandlastitems,limit=1,method=Last,playlist=special://masterprofile/playlists/IMDB Top 250.xsp,menu=1)" in the wrong place! but no clue were to put it.

PHP Code:
            <!-- Featured -->
            <
control type="group">
                <
visible>Container(300).HasFocus(3)</visible>                                                        
                <
control type="list" id="370">
                    <include>
IMDB Movie</include>                    
                    <
content>
                        <
item id="1">
                            <
onload>XBMC.RunScript(script.randomandlastitems,limit=1,method=Last,playlist=special://masterprofile/playlists/IMDB Top 250.xsp,menu=1)</onload>                
                            
<thumb>$INFO[Window.Property(PlaylistRandomMovie1.1.Thumb)]</thumb>
                            <
icon>$INFO[Window.Property(PlaylistRandomMovie1.1.Fanart)]</icon>            
                            <
onclick>$INFO[Window.Property(PlaylistRandomMovie1.1.Path),PlayMedia(,)]</onclick>
                        </
item>
                    </
content>
                </
control>
            </
control>
            <!-- 
Featured (End) --> 

Huh
in home.xml if you want, or include.xml

<onload>XBMC.RunScript(script.randomandlastitems,limit=1, method=Last,playlist=special://masterprofile/playlists/IMDB Top 250.xsp,menu=1)</onload>

and modify

<!-- Featured -->
<control type="group">
<visible>Container(300).HasFocus(3)</visible>
<control type="list" id="370">
<include>IMDB Movie</include>
<content>
<item id="1">

<thumb>$INFO[Window.Property(PlaylistRandomMovie1.1.Thumb)]</thumb>
<icon>$INFO[Window.Property(PlaylistRandomMovie1.1.Fanart)]</icon>
<onclick>$INFO[Window.Property(PlaylistRandomMovie1.1.Path),PlayMedia(,)]</onclick>
</item>
</content>
</control>
</control>
<!-- Featured (End) -->
You cannot use the script this way.

You have to use a compatible skin :
Glass : http://forum.xbmc.org/showthread.php?tid=114839
Convergence : http://forum.xbmc.org/showthread.php?tid=99839
Fusion Migma V2 : http://forum.xbmc.org/showthread.php?tid=120867

I can give your details for Glass.
fmronan Wrote:in home.xml if you want, or include.xml

<onload>XBMC.RunScript(script.randomandlastitems,limit=1, method=Last,playlist=special://masterprofile/playlists/IMDB Top 250.xsp,menu=1)</onload>

and modify

<!-- Featured -->
<control type="group">
<visible>Container(300).HasFocus(3)</visible>
<control type="list" id="370">
<include>IMDB Movie</include>
<content>
<item id="1">

<thumb>$INFO[Window.Property(PlaylistRandomMovie1.1.Thumb)]</thumb>
<icon>$INFO[Window.Property(PlaylistRandomMovie1.1.Fanart)]</icon>
<onclick>$INFO[Window.Property(PlaylistRandomMovie1.1.Path),PlayMedia(,)]</onclick>
</item>
</content>
</control>
</control>
<!-- Featured (End) -->

this is how I have it in home.xml

mikebzh44 Wrote:You cannot use the script this way.

You have to use a compatible skin :
Glass : http://forum.xbmc.org/showthread.php?tid=114839
Convergence : http://forum.xbmc.org/showthread.php?tid=99839
Fusion Migma V2 : http://forum.xbmc.org/showthread.php?tid=120867

I can give your details for Glass.

Im trying to use the script in a skin im developing. I just want it to display 1 random movie from the IMDB Top 250.xsp on the home view.

Im just having trouble getting the script to work. But are you saying it will only work on those skins?
no you run the script in your container
No, if you are a skinner, you can add this script to your skin.

Maybe you should rename your xsp file to : ImdbTop250.xsp

If you display your playlist in XBMC, you have a movie ?

When you run the script in home.xml or include.xml (look how other skinners call it) :

XBMC.RunScript(script.randomandlastitems,limit=1,type=Movie,method=Last,playlist=special://masterprofile/playlists/ImdbTop250.xsp,menu=1)

You should have windows properties :

PlaylistLastMovie1.Count
PlaylistLastMovie1.Unwatched
PlaylistLastMovie1.Watched
PlaylistLastMovie1.1.Rating
PlaylistLastMovie1.LastMovie1.Plot
PlaylistLastMovie1.LastMovie1.RunningTime
PlaylistLastMovie1.LastMovie1.Path
PlaylistLastMovie1.LastMovie1.Rootpath
PlaylistLastMovie1.LastMovie1.Fanart
PlaylistLastMovie1.LastMovie1.Thumb
PlaylistLastMovie1.LastMovie1.Title
PlaylistLastMovie1.LastMovie1.Year
PlaylistLastMovie1.LastMovie1.Trailer

Has explained in first message of this thread :

http://forum.xbmc.org/showthread.php?tid=122448
mikebzh44 Wrote:I will have a closer look to commoncache but if you have set up parameters for display only unwatched movies for example, each time the script is called, I have to scan all the playlist/library to seach for unwatched movies. And what's happen when you add a new source to your library ?
You decide how long the cached version is valid. You can vary between 1 second or xx hours.
When the set time expires it will retrieve new data when script is run. Within that time it will use the 'old' data.

Quote:Maybe there is a JSON method to known if database has been updated, I will ask to the specific thread.

There isn't
Martijn Wrote:You decide how long the cached version is valid. You can vary between 1 second or xx hours.
When the set time expires it will retrieve new data when script is run. Within that time it will use the 'old' data.



There isn't

I think I can use commoncache when unwatched=false and resume=false. But script won't be up to date if you add a new movie to your database :

Example :

- execute script + commoncache (refresh every hour) JSON results
- widgets are OK
- add a new movie to database
- widget "Recently added movies" is outdated

Or I can add a new option : useCommonCache=True/False
Don't add to much options IMHO.
It was just a suggestion like if you run user run the script several times it could be somewhat faster in processing.
You will always have down and upside to a certain way of working.
I known that caching data could be a way to speed up the script but only in some case.

I must have a look to commoncache !!
Version 1.1.5 released

Just a little cosmetic change.

Properties are cleared only when needed to avoid blinking effect when widget is refresh
If no issues/bugs are found feel free to do a PR to add this to offcial XBMC repo
This way even less experienced users can benefit from this great script Smile

How-to:
Official_add-on_repository (wiki)
Instead of having to determine the type in the script parameters, couldn't the type (movies or episodes) be fetched from the playlist itself? That way we don't have to have 4 different options for 1 custom menu item.
It's an idea, and a good one Wink

But, when calling the script without playlist (to work on library), you will have to set type= option.

I will work on it next week.
Okay, but that's up to the skinner right? So there could be type=playlist or type=library instead?