Author Topic: Play random episode of a show in XBMC  (Read 14344 times)

0 Members and 1 Guest are viewing this topic.

fattybunter

  • $upporter
  • Contributor
  • *****
  • Posts: 57
  • Karma: 0
    • View Profile
Play random episode of a show in XBMC
« on: June 22, 2011, 06:54:13 PM »
Searched and couldn't find anything in the forum about this.

I'm trying to figure out how to do a voice command for just what the title says.  I'd like to be able to do it without creating a smartlist beforehand in XBMC as I have a whole bunch of shows.

right now I have the macro from the forum (I think) for finding a tv show by name:

Code: [Select]
<commandGroup name="XBMC TV+Movies" enabled="True" prefix="" priority="0" requiredProcess="" description="">
- <command id="136" name="tv show" enabled="true" alwaysOn="False" confirm="False" loop="False" loopDelay="0" loopMax="0" description="">
- <action>
  <cmdType>XBMC.Send</cmdType>
  <cmdString>execbuiltin(ActivateWindow(videolibrary,tvshowtitles))</cmdString>
  <cmdRepeat>1</cmdRepeat>
  </action>
- <action>
  <cmdType>XBMC.Filter</cmdType>
  <cmdString>{1}</cmdString>
  <cmdRepeat>1</cmdRepeat>
  </action>
- <action>
  <cmdType>XBMC.ExecBuiltin</cmdType>
  <cmdString>Action(Down)</cmdString>
  <cmdRepeat>1</cmdRepeat>
  </action>
- <action>
  <cmdType>XBMC.ExecBuiltin</cmdType>
  <cmdString>Action(Select)</cmdString>
  <cmdRepeat>1</cmdRepeat>
  </action>
- <action>
  <cmdType>XBMC.ExecBuiltin</cmdType>
  <cmdString>Action(Down)</cmdString>
  <cmdRepeat>1</cmdRepeat>
  </action>
- <action>
  <cmdType>XBMC.ExecBuiltin</cmdType>
  <cmdString>Action(Select)</cmdString>
  <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase optional="true">find</phrase>
  <phrase>tv, television</phrase>
  <phrase optional="true">show, series</phrase>
  <payloadFromXML phraseOnly="True" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone">XbmcPayloads\xbmcTvShowTitles.xml</payloadFromXML>
  </command>

I modified it a little so that it finds the show then enters the "All Seasons" node.  Once I'm there though, I want to play a random episode by saying "random episode"


Anyone have a starting point for me?  I'm new to this (hence my 3rd post)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Play random episode of a show in XBMC
« Reply #1 on: June 22, 2011, 08:02:26 PM »
Searched and couldn't find anything in the forum about this.

I'm trying to figure out how to do a voice command for just what the title says.  I'd like to be able to do it without creating a smartlist beforehand in XBMC as I have a whole bunch of shows.
...
...
I modified it a little so that it finds the show then enters the "All Seasons" node.  Once I'm there though, I want to play a random episode by saying "random episode"


Anyone have a starting point for me?  I'm new to this (hence my 3rd post)

you can still use a smart playlist.  You can use the payload {1} which contains the show name and then specify that the episode is selected at random.  At least, I think that should be possible.  It is probably also possible to do it using the QueryVideoDatabase command, retrieving the id and then queueing it...  I would have to play with it a bit to figure it out, but I think it's doable.

If you want to try the smart playlist route, check out this video.  I think you'll find it enlightening. Even though it was based on an older version of VC the principles are sound and not that much has changed.


It's nice to have a fresh face on the forum asking challenging questions!

fattybunter

  • $upporter
  • Contributor
  • *****
  • Posts: 57
  • Karma: 0
    • View Profile
Re: Play random episode of a show in XBMC
« Reply #2 on: June 22, 2011, 10:07:07 PM »
Looks like that will do the trick, but as I'm going through it I see that "XBMC.LoadSmart" is no longer a valid action.  I'm guessing this is absorbed in some other command.  How do I handle it without this action?  Thanks in advance!

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Play random episode of a show in XBMC
« Reply #3 on: June 22, 2011, 11:28:14 PM »
It actually is a valid command, but it looks like it got erased from availablecommands.xml file somehow.  That is the file that is used to auto-complete actions, build the tree and provide help.

You can still use it this action though.  It is of the form:  XBMC.LoadSmart

I use it all the time in my "Unwatched episodes of..." command so I know it works.  If you look in the group "XBMC Smart playlists" you should find the command being used.  Thanks for the heads up, I'll correct the availablecommands.xml file for the next release!

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Play random episode of a show in XBMC
« Reply #4 on: June 22, 2011, 11:57:21 PM »
Hopefully you can get it to work on your own, but in case not, or if others want to use this command, see the attached.

- put the .xsp file into your smarts subfolder (subfolder of your VC folder)
- drag the .xml file onto your command tree to import it

save

note that XBMC smart playlists will select files randomly but will still want to sort them in either ascending or descending order.  That is why I chose to only return 1 item.  You could get it to return 5 random episodes, but they will be listed in order w.r.t. each other.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Play random episode of a show in XBMC
« Reply #5 on: June 23, 2011, 12:00:02 AM »
for convenience, this is what the smart playlist looks like in code

Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="episodes">
    <name>random episodes</name>
    <match>all</match>
    <rule field="tvshow" operator="contains">{1}</rule>
    <limit>1</limit>
    <order direction="ascending">random</order>
</smartplaylist>

fattybunter

  • $upporter
  • Contributor
  • *****
  • Posts: 57
  • Karma: 0
    • View Profile
Re: Play random episode of a show in XBMC
« Reply #6 on: June 23, 2011, 12:09:15 AM »
Attached an image of what I'm doing, which results in exactly the same thing as your included "Find TV show" macro. Still can't get anything useful...

2 issues that I can identify:

1.  I'm not sure if it's an XBMC glitch, but it seems like whenever I make a smart playlist and choose "random" as the sorting, it doesn't actually change the sorting to random and instead keeps it on whatever my sorting defaults to (by rating in my case).

2.  Making an "Episodes" smart playlist instead of the "TV Shows" one I have pictured in my attachment results in only episodes that match both the tv show name AND episode name. For example, "Play random episodes of South Park" results in a one episode list of South Park with the episode "South Park is Gay"

EDIT: I'll go ahead and try what you just posted...Thanks so much!

fattybunter

  • $upporter
  • Contributor
  • *****
  • Posts: 57
  • Karma: 0
    • View Profile
Re: Play random episode of a show in XBMC
« Reply #7 on: June 23, 2011, 12:31:41 AM »
That worked beautifully.  Thank you.  This is easily the best customer support of all time  :)

I'm trying to make the <limit> field a variable now, but I think the missing documentation on XBMC.LoadSmart is making it difficult.  So maybe you can help me understand how it works (if you have some more time).

In the .xml file you attached, where/when does my voice-commanded choice from xbmcTvShowTitles.xml get assigned to the variable {1}? 

I Imagine I can just replace the "<limit>1</limit>" with "<limit>{2}</limit>" and then feed a limit value in that way, but I'm not sure how to do this.

fattybunter

  • $upporter
  • Contributor
  • *****
  • Posts: 57
  • Karma: 0
    • View Profile
Re: Play random episode of a show in XBMC
« Reply #8 on: June 23, 2011, 12:33:38 AM »
I see that VoxSmart.xsp is overwritten each time.  Now maybe I can figure this out :)

EDIT: yes! beautiful!  I love this program
« Last Edit: June 23, 2011, 12:37:38 AM by fattybunter »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Play random episode of a show in XBMC
« Reply #9 on: June 23, 2011, 09:08:50 AM »
someone's on a roll  ;D

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Play random episode of a show in XBMC
« Reply #10 on: June 23, 2011, 09:25:45 AM »
Actually, I discovered that you can have more than one item, sorted randomly.  You need to change the sort order on the side panel to "playlist" (when viewing the smart playlist, not when editing it).  I'm not 100% sure if the setting will persist and be remembered for each individual view, but I tested it on AeonMQ2 and it remembers to sort TV shows by episode in normal view and leave my smart playlist in playlist order (i.e. random).

fattybunter

  • $upporter
  • Contributor
  • *****
  • Posts: 57
  • Karma: 0
    • View Profile
Re: Play random episode of a show in XBMC
« Reply #11 on: June 23, 2011, 09:38:02 AM »
I noticed the same thing, and it also seems to be persisting for me.


a couple more questions:


1.  What I am finding strange is after I add more than one episode (via limit>1) to the smartplaylist and start playing from the top, XBMC isn't automatically adding all of the episodes in the smartplayst to the "Now Playing" list, so playback just stops after one episode and returns to the smartplaylist.  This isn't a big deal at all, but I know my roommates and I prefer if it would just continue.

2.  In addition to saying "play one random episode of <show>", I also want to be able to say "play a random episode of <show>" where 'a' invokes '1'.  Can this be done using a payload list with an if-else statement before the XBMC.LoadSmart action?



jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Play random episode of a show in XBMC
« Reply #12 on: June 23, 2011, 10:31:37 AM »
1: this is the nature of XBMC.  I am sure we can find a solution. Let me play with it.

2:  Did you try just saying 'A'?  I thought maybe the engine would be smart enough to map a to 1, but I guess it would be more likely to do 8.  If you only had the range of 1-5 it might work.

Anyway, you *could* use logic for this, but a more elegant solution would be to use a payloadXML file.  In the values column you would enter the digits, and for the phrases you could enter various ways of specifying (saying) the digit separated by commas.

eg:

1 |  1,A,An,A single
2 |  2,A couple, A couple of, double
3 |  3,A few, Some, A trio of
4 |  4, A bunch
.
.
.

This is a very handy technique, and also allows you to use other languages by mapping a phonetic phrase to a value.  If you want to use xbmc direction keys it is expecting the exact values of (up,down,left,right) but to use french you would need to map (gauche -> left) etc.

Documentation is not really available for this yet but I think you can figure it out.  If not let me know.  I have some "real" work I need to do right now.

fattybunter

  • $upporter
  • Contributor
  • *****
  • Posts: 57
  • Karma: 0
    • View Profile
Re: Play random episode of a show in XBMC
« Reply #13 on: June 23, 2011, 11:02:34 AM »
Fantastic...payloadXML will be perfect.  Thank you once again.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Play random episode of a show in XBMC
« Reply #14 on: June 27, 2011, 10:28:22 AM »
a couple more questions:

1.  What I am finding strange is after I add more than one episode (via limit>1) to the smartplaylist and start playing from the top, XBMC isn't automatically adding all of the episodes in the smartplayst to the "Now Playing" list, so playback just stops after one episode and returns to the smartplaylist.  This isn't a big deal at all, but I know my roommates and I prefer if it would just continue.

OK I finally took a moment to play with this:

If you want to play the whole list you can use this simple command consisting of only two actions, that will start playing the smart playlist right away.  I only tested with music, but I imagine it will work with episodes as well.

XBMC.LoadSmart       smarts\***.xsp
XBMC.ExecBuiltin       Playmedia({path.vc}\VoxSmart.xsp)