Author Topic: Multi-phase XML can it be done?  (Read 4637 times)

0 Members and 1 Guest are viewing this topic.

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Multi-phase XML can it be done?
« on: March 03, 2015, 09:00:36 AM »
Haven't looked too much into this yet, just putting the idea out there.

Can I make a multi-phase payload?

Example for TV shows:
To show - season - episode = episode Id

So have a 4 table payload where 3 tables need to match to send the value.
Or maybe 4 separate payloads, all in one seems much neater.
I haven't looked much into RegEx yet, maybe it's possible.

Feel free to offer suggestions.....

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Multi-phase XML can it be done?
« Reply #1 on: March 03, 2015, 10:11:16 AM »
I'm trying to wrap my head around this but I can't understand what you are saying.  Could you offer a real world example.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Multi-phase XML can it be done?
« Reply #2 on: March 03, 2015, 12:20:51 PM »
@Mace -- wasn't it you who originally came up with the command to ask for an individual episode by name? (http://voxcommando.com/forum/index.php?topic=1075.msg9040#msg9040)

If you have a problem with duplicate episode names, then maybe you'd want TV series + episode name (though for me that would be a mouthful already, without trying to make it a 3- or 4-phrase payload). Is season also needed?

VC does have a "2-phrase" payload option, which James mentioned in that other thread. Usually people use it for play song X by artist Y. So you could probably create a similar query for TV series + episode name.

It's not clear when you'd need a four-table match to return one value, which I guess is James's question above. Me too.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Multi-phase XML can it be done?
« Reply #3 on: March 03, 2015, 02:32:55 PM »
e.g., we can create the SQL query from the Video db:

Code: [Select]
select distinct idEpisode, c00, strTitle from episodeview where strTitle!=""
And use it with your play episode command, but now using a 2-phrase payloadXML file that I've called xbmcEpisodeByTVSeries.xml:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.8-->
<command id="688" name="Play Episode" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>XJson.Raw</cmdType>
    <params>
      <param>Player.Open</param>
      <param>"item" : {"episodeid" : {1} }</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Play Episode</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="True" phraseConnector="of, of the series" Phrase2wildcard="any show" optional="False">XbmcPayloads\xbmcEpisodeByTVSeries.xml</payloadFromXML>
</command>

Choose the "connector" phrase or phrases that feel natural to you. In the attached screenshot, I have a choice of using "of" or "of the series".

If I say "of any show" after the episode name, it won't care what the series is called. Otherwise I have to say something like, "Play episode Job Offer of Archer" style of thing.


TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Multi-phase XML can it be done?
« Reply #4 on: March 03, 2015, 02:57:12 PM »
That's what happens when you write stuff late at night, sounds good in my head, but not so much for everyone else.

My original play episode command was built off episode name. And works well for the most part.
As my collection has grown I'm experiencing some similarities between names and occasionally getting the wrong episode. In reality, I can live with that.

However, as I like a challenge, I'd like to try build a different way. It would be nice to play an episode by its number, rather than name. Eg:
Game of Thrones, Season 2, Episode 8.

Kodi (Xbmc) uses unique episodeid from the database to play the episodes. This id is in no way related to 'Episode 8'

As none of the above are unique in them self they can't retrieve the ' episodeid'
But if you use tv show title as a filter it narrows it down. Each show only has one 'season 2' and each season only has one 'Episode 8', combined the statement is unique. Resulting in one 'episodeid' being send to the player.

So a 4 table payload would be cool. Three phases and one value.

Retrieving a tv show title and season from Kodi is pretty easy, but to get a episodeid from an Episode numbers specific to a season which is specific to a tv show title is where the fun part is.

As I said, it's just an idea that would be cool. And I enjoy a challenge.

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Multi-phase XML can it be done?
« Reply #5 on: March 03, 2015, 03:05:04 PM »
@nime5ter
That's pretty cool, but as you can see, it's the episode name that I would like to drop.

Which makes things tricky, cause to get the right episode number we need to combine results from the episode and tvshow tables from the database.
« Last Edit: March 03, 2015, 03:08:21 PM by Mace »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Multi-phase XML can it be done?
« Reply #6 on: March 03, 2015, 03:20:59 PM »
Actually I'm using "episodeview", which combines data from Show, season, episode.

In that view table, you can get series name, season number, and episode number and associate these with the episode ID. That's not the issue.

However, it's true that VC only allows a 2-phrase payload. I don't know if there's a workaround that could allow you to automate generating series name as one phrase + season number&episode number as your second phrase using the xSQL query. Maybe James can clarify that. But probably you could generate it on your own using Python or whatever, and it would work in the same way as my example. Episode number vs. episode name. Doesn't matter. As long as the combo of phrases is uniquely associated with a single episode ID.
« Last Edit: March 04, 2015, 08:43:06 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Multi-phase XML can it be done?
« Reply #7 on: March 03, 2015, 03:38:45 PM »
OK, got it!

My familiarity with sql is not that advanced. Duh. :)

The query

Code: [Select]
select distinct idEpisode, strTitle, (c12 ||  ' episode '|| c13)  from episodeview
Gives you a payload xml file where episodeID is associated with the phrase"series Name&&seasonnum episode episodenum".

Then you just need to use the word "season" as your connector phrase, et voilĂ !

... or maybe you'd want season+episode first, and show title as your second phrase, I guess. Anyhow. This seems doable/customizable to me.

EDIT: Actually, as James wisely ( 8)) just pointed out to me, in this scenario we wouldn't necessarily want a 2-phrase payload anyhow. The point of the 2-phrase payload is to allow the second phrase to be semi-optional--hence the wildcard feature. So, if you really want to ask for every episode by show name + season num + ep num, it probably makes more sense to concatenate all those together into a single phrase within the SQL query, seems like.

Code: [Select]
select distinct idEpisode, (strTitle||' season '||c12 ||  ' episode '|| c13)  from episodeview
« Last Edit: March 03, 2015, 05:29:32 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Multi-phase XML can it be done?
« Reply #8 on: March 04, 2015, 06:50:43 AM »
Now that's some artistic genius!

I humbly bow to the master and padawan.  ;)

Next question: which is more efficient, XML or Python script?

Python script can query the database each time.....can i run a sql query directly from VC, nope. Nothing in MySql Plugin

XML, well i haven't actually worked the XML out yet. Oh wait do I generate a payload xml with each command?

Much appreciate the problem solving support. It's good fun.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Multi-phase XML can it be done?
« Reply #9 on: March 04, 2015, 08:12:25 AM »
Don't let my earlier confusion/babbling confuse you. ;) I initially thought that there may be limits to the kinds of sql queries we could do in the XBMC sql plugins, but that was my mistake. The only limitation is the structure of the output that we want (i.e. 2/3-column payload xml tables).

....can i run a sql query directly from VC, nope. Nothing in MySql Plugin

Yes, all the Output XML Payload file queries listed in your MySql plugin table are just sql queries. You can change them or add additional ones, and it will then generate the appropriate payloadXML file.

You'll want to issue a command to regenerate the xml whenever you add new shows, or set VC to do so automatically every day if that makes more sense. And then use it with the command I posted above.

So, you can add this query in your xMySql plugin table as per the screen capture.
Code: [Select]
select distinct idEpisode, (strTitle||' season '||c12 ||  ' episode '|| c13)  from episodeview
Then your phrases will take the form that you mentioned earlier "Game of Thrones Season 2 Episode 8" and each be associated with the appropriate episode ID.
« Last Edit: March 04, 2015, 08:42:46 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Multi-phase XML can it be done?
« Reply #10 on: March 04, 2015, 08:25:55 AM »
I get the impression you mostly wanted to know what is possible, but I'm wondering -- Do you already have the other TV-related commands that are now standard in the configs?

The problem with the "Play episode X" command is that you'll be generating a pretty large payloadXML, depending on the size of your library.

We mostly use the "unwatched episodes of X" command, which takes us right to the next episodes of the show we want to watch. Or the "Browse season # of X", if we want to see all episodes in a particular season and choose one. So far that hasn't felt inefficient to me.

TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Multi-phase XML can it be done?
« Reply #11 on: March 04, 2015, 08:51:24 AM »
Quote
So, you can add this query in your xMySql plugin table as per the screen capture
I tried this but all I got was id episode and the number 1.  Must of had a setting wrong somewhere, I'll have another look later.

Quote
The problem with the "Play episode X" command is that you'll be generating a pretty large payloadXML, depending on the size of your library.
Why I was wondering if python would be more efficient.

Quote
We mostly use the "unwatched episodes of X" command, which takes us right to the next episodes of the show we want to watch. Or the "Browse season # of X", if we want to see all episodes in a particular season and choose one. So far that hasn't felt inefficient to me.
My problem with this is some times I have a habit of watching something before I put it in Kodi, so the unwatched bit doesn't always work for me, but that's just personal style.
I use browse season command a lot, but my hiccup here is i find the VC navigation commands annoying and I wouldn't even know where to start looking for my tv remote to push a button.

To me a single sentence to play what I want, is my go to option.

Should 'strTitle' be 'idShow' I'm after the tv show not the episode title?

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Multi-phase XML can it be done?
« Reply #12 on: March 04, 2015, 09:09:17 AM »
I tried this but all I got was id episode and the number 1. 

Hm. Strange. Any chance you're querying the wrong table? This query works fine for me with the episodeview table.

Quote
Should 'strTitle' be 'idShow' I'm after the tv show not the episode title?

In the episodeview table, strTitle refers to the name of the TV show. You don't need the id of the Show for this purpose, do you? You want to play individual episodes, so you should only need the id for the episode.

The best thing would be for you to take a look at the episodeview table yourself, if you haven't yet. Maybe there's something off with the metadata for your TV show library.
« Last Edit: March 04, 2015, 09:17:30 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Multi-phase XML can it be done?
« Reply #13 on: March 04, 2015, 02:53:29 PM »
strTitle - I found my mistake there. Was reading from the kodi wiki, looks like it is still on myvideos75 information.

The XML issue, I think is just a setting I have out somewhere.

I'll have another look when I get a spare minute. Working the next few days, time is limited.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Multi-phase XML can it be done?
« Reply #14 on: March 04, 2015, 05:17:47 PM »
Here's an alternative method that I think is pretty cool.  It only uses the regular payloadXML for TV Show Titles so it is easier on resources. 

The only possible drawback is that the payload ranges are "dumb" in that they don't know which seasons and episodes you have for a given show, but assuming your recognition accuracy is decent I don't think this will be a problem. 

The bonus is that if you don't have that episode or season, it will at least try to browse to the closest match.

http://voxcommando.com/forum/index.php?topic=2059.0