2011-08-29, 21:03
EDIT: Please note - I've updated this script for Gotham (and because I'm a bit better at python now too...). New location for download here: https://github.com/elParaguayo/script.ra...master.zip
The intention is for this to be added to the official repository but I need to test for more bugs first.
I've been helping out on the Cirrus Extended skin for a few months now. For the latest release I wrote a short script that plays a random movie from the user's library. The script allows the user to restrict the selection by genre/unwatched movies.
I wanted to make the experience seamless with the skin as a whole, so the code to launch the script is coded directly into the skin (rather than launching through the addons menu).
I therefore thought I'd share the code with other skin developers so that they could include with their skins if they wanted to.
Script id: script.randommovie
Compatibility: Dharma (see below)
Source: https://github.com/elParaguayo/xbmc-random-movies
Download (Dharma): https://github.com/elParaguayo/xbmc-rand...all/master
Download (pre-Eden): https://github.com/elParaguayo/xbmc-rand...ll/preEden
Skin code:
Up to the skinner as to where to include the code. The key lines are:
For filter by genre:
For no genre filter:
The user is first asked (via a yes/no dialog) whether they want to restrict the choice to unwatched movies. If the genre filter has been delected then the list of genres populates a DialogSelect list.
As I understand it, this isn't compatible in post-Dharma versions - I assume this is down to the deprecation of the http api requests and their replacement with JSON RPC calls.
Once I get pre-Eden working on my laptop I'll convert the script. EDIT: DONE.
I hope someone else finds this useful.
el_P
EDIT: Please note, there is a more comprehensive Random Items script (available here) which you may want to consider looking at. Depends what your needs are!
The intention is for this to be added to the official repository but I need to test for more bugs first.
I've been helping out on the Cirrus Extended skin for a few months now. For the latest release I wrote a short script that plays a random movie from the user's library. The script allows the user to restrict the selection by genre/unwatched movies.
I wanted to make the experience seamless with the skin as a whole, so the code to launch the script is coded directly into the skin (rather than launching through the addons menu).
I therefore thought I'd share the code with other skin developers so that they could include with their skins if they wanted to.
Script id: script.randommovie
Compatibility: Dharma (see below)
Source: https://github.com/elParaguayo/xbmc-random-movies
Download (Dharma): https://github.com/elParaguayo/xbmc-rand...all/master
Download (pre-Eden): https://github.com/elParaguayo/xbmc-rand...ll/preEden
Skin code:
Up to the skinner as to where to include the code. The key lines are:
For filter by genre:
Code:
<onclick>RunScript(script.randommovie, filtergenre=True)</onclick>
<visible>System.HasAddon(script.randommovie)</visible>
For no genre filter:
Code:
<onclick>RunScript(script.randommovie)</onclick>
<visible>System.HasAddon(script.randommovie)</visible>
The user is first asked (via a yes/no dialog) whether they want to restrict the choice to unwatched movies. If the genre filter has been delected then the list of genres populates a DialogSelect list.
As I understand it, this isn't compatible in post-Dharma versions - I assume this is down to the deprecation of the http api requests and their replacement with JSON RPC calls.
Once I get pre-Eden working on my laptop I'll convert the script. EDIT: DONE.
I hope someone else finds this useful.
el_P
EDIT: Please note, there is a more comprehensive Random Items script (available here) which you may want to consider looking at. Depends what your needs are!