Random Movie script for skins

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
el_Paraguayo Offline
Fan
Posts: 448
Joined: Feb 2011
Reputation: 7
Location: London, UK
Post: #1
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!

MythSuspendAlarm: Suspend xbmc and set ACPI wake alarm based on next scheduled MythTV recording.
BBC Football Scores: Get live football score notifications.
Random Movie Script: Play random movies from user's library (for skinners).
(This post was last modified: 2011-09-06 19:52 by el_Paraguayo.)
find quote
Big_Noid Offline
Skilled Skinner
Posts: 2,627
Joined: Jul 2010
Reputation: 68
Location: Below sea level
Post: #2
It's working nice. I have a suggestion though, couldn't you add the genre bit too as a pop up instead of leaving the choice to the skinner. I can imagine I sometimes want the choice for genre and sometimes I don't. The way it's implemented I have to edit the skin to toggle between these two settings.
find quote
el_Paraguayo Offline
Fan
Posts: 448
Joined: Feb 2011
Reputation: 7
Location: London, UK
Post: #3
Big_Noid Wrote:It's working nice. I have a suggestion though, couldn't you add the genre bit too as a pop up instead of leaving the choice to the skinner. I can imagine I sometimes want the choice for genre and sometimes I don't. The way it's implemented I have to edit the skin to toggle between these two settings.

Yeah, I did think about that too.

I might add another option e.g.
-no parameter - play random movie (so as not to break existing skin implementations)
-filtergenre - direct link to genre selection
-userchoice - user asked whether he wants to pick genre or not.

I'll add to my To Do list...

Thanks!

MythSuspendAlarm: Suspend xbmc and set ACPI wake alarm based on next scheduled MythTV recording.
BBC Football Scores: Get live football score notifications.
Random Movie Script: Play random movies from user's library (for skinners).
find quote
el_Paraguayo Offline
Fan
Posts: 448
Joined: Feb 2011
Reputation: 7
Location: London, UK
Post: #4
Update:

I've added a pre-Eden compatible version of the script (download link in first post).

I've also added (just to pre-Eden at the moment) the option to prompt the user whether they want to filter by genre, so skinners only need to include the one call to the script if they want. See the readme file for more info.

NB: The readme is currently incorrect (can't update until I'm home tonight!) - the args that can be passed are "filtergenre=True" and "prompt=True".

MythSuspendAlarm: Suspend xbmc and set ACPI wake alarm based on next scheduled MythTV recording.
BBC Football Scores: Get live football score notifications.
Random Movie Script: Play random movies from user's library (for skinners).
(This post was last modified: 2011-09-01 09:50 by el_Paraguayo.)
find quote
Big_Noid Offline
Skilled Skinner
Posts: 2,627
Joined: Jul 2010
Reputation: 68
Location: Below sea level
Post: #5
With the prompt=true addition it is now perfect. Works really great, it's like having a sneak preview at home Big Grin
find quote
el_Paraguayo Offline
Fan
Posts: 448
Joined: Feb 2011
Reputation: 7
Location: London, UK
Post: #6
UPDATE: Minor tweak to fix an error where the returned data contained an accented letter.

Download link unchanged - see 1st post.

MythSuspendAlarm: Suspend xbmc and set ACPI wake alarm based on next scheduled MythTV recording.
BBC Football Scores: Get live football score notifications.
Random Movie Script: Play random movies from user's library (for skinners).
find quote
moosenoz Offline
Senior Member
Posts: 142
Joined: Jan 2010
Reputation: 0
Post: #7
el_Paraguayo, could your script be edited to work in a playlist submenu context?

for example, i have a shortcut to a video playlist with various tv shows attached to my home menu. could you edit your script so that the random button would appear under the playlist and i'd be able to play a random tv show?

i think this would be a fantastic feature in any skin.

regards,
mark
find quote
el_Paraguayo Offline
Fan
Posts: 448
Joined: Feb 2011
Reputation: 7
Location: London, UK
Post: #8
Mark,

Sorry for the slow reply - hadn't realised there'd been a new post here.

I think that it should be possible.

There are two things you're asking:
1) Make script work for TV shows (currently it's movies only - seemed a bit counter-intuitive to do for TV shows as you'd usually watch episodes in order)
2) Make script work for Playlists (as above).

I think that the JSON RPC spec provides enough info for the script to work on TV shows and playlists without too much additional work.

In terms of adding it to the skin - have you modded your skin so there's a direct link to your playlist, or were you hoping to get this added as a context menu item for each playlist automatically? If it's the former I can help, if it's the latter then this is probably outside of my skills!

I'll take a look.

el_P

MythSuspendAlarm: Suspend xbmc and set ACPI wake alarm based on next scheduled MythTV recording.
BBC Football Scores: Get live football score notifications.
Random Movie Script: Play random movies from user's library (for skinners).
find quote
el_Paraguayo Offline
Fan
Posts: 448
Joined: Feb 2011
Reputation: 7
Location: London, UK
Post: #9
For anyone trying to use the pre-Eden version on the the latest nightlies, you'll need to change one word in the script to make it work:

In line 33 of default.py in the script.randommovies folder. Change "fields" to "properties".

I'll push the update to github when I get the chance - DONE

MythSuspendAlarm: Suspend xbmc and set ACPI wake alarm based on next scheduled MythTV recording.
BBC Football Scores: Get live football score notifications.
Random Movie Script: Play random movies from user's library (for skinners).
(This post was last modified: 2011-10-09 00:39 by el_Paraguayo.)
find quote
arnuschky Offline
Junior Member
Posts: 3
Joined: Aug 2011
Reputation: 0
Post: #10
Hey,

I don't know much about skinning (know Python, though). Can someone give me an easy solution how to integrate this into confluence?

Cheers
find quote
Post Reply