VoxCommando

Help and Support (Using VoxCommando) => Kodi (XBMC) Frodo / Gotham / Isengard / Jarvis => Topic started by: jitterjames on October 21, 2012, 12:52:30 PM

Title: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on October 21, 2012, 12:52:30 PM
Here I will post the latest updates, scripts, and plugins in an effort to make the switch from the http api to the new JSON api.

In order to test you will need to update to the latest version of XBMC found here: http://mirrors.xbmc.org/nightlies/

Because the JSON interface is missing a lot of the functionality that we normally use we will need to do the following, which means that setup will be a bit more complicated, but hopefully the end functionality will be at least as good as it was.

1) Install an addon in XBMC called voxtools.  This is easily done, I will provide a .zip file and you will only need to do an "install from .zip".  using this addon we can do things like "xbmc.execbuiltin" which is not possible with JSON
2) Rely more on Smart Playlists - because the JSON library does not allow us to do very sophisticated playlist building, at least, not that I have been able to figure out.
3) GenXML will now require a new VC plugin that can access the XBMC database files directly in order to do SQL queries which are not available in the JSON api
4) use a new VC plugin for JSON commands.  This way people using EDEN can use the original XBMC actions in VC and people using pre-Frodo can use the plugin actions.


I will be looking for people to help me figure out specific problems.  I can manage by myself but if I get help it will go faster.

I will also need people to help me test these crazy new ideas / workarounds.  Testing means installing the lastest version of XBMC which will no longer support the old methods, so you will need to have a spare system set up if you want to continue to use the old configurations of VC with XBMC :(
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on October 21, 2012, 12:52:46 PM
reserved
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on October 21, 2012, 12:52:51 PM
reserved
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on October 21, 2012, 12:52:56 PM
reserved
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: fishware on January 05, 2013, 04:02:21 PM
Hi outhere,

I will short introduce myself (sorry for my english, I'm a german native)

I'm from Berlin in Germany, 37 years old and "play around" with computer, multimedia, and voicecontrol!!! since around 1995.
At this time the computer can't play videos  ;) and also he don't hear me (IBM ViaVoice, what a ****).

Now serevals years later I use XBMC to consume HighDefinition Videos over GBLan, controlled from a remotedevice in my pocket (greetings from Android).
One step closer to  the "Star Trek Bridge"

And a few days ago, I discovred VoxCommando!!!

I try outit  with an wireless Headset from Asus and a Windows7 OS....it works perfect!!!

Very nice job James


I will be looking for people to help me figure out specific problems.  I can manage by myself but if I get help it will go faster.

I will also need people to help me test these crazy new ideas / workarounds.  Testing means installing the lastest version of XBMC which will no longer support the old methods, so you will need to have a spare system set up if you want to continue to use the old configurations of VC with XBMC :(

I play around with the XJson plugin.
So, I will help to improve this features, because I think it is a really nice one.

I stay tuned.........

Chris


Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 05, 2013, 04:35:19 PM
Welcome aboard fishware.  You are most welcome.

I am actually working on a new release of the xJson plugin and some commands that work with it.

I hope to have some good stuff ready for people to play with by the end of January and I will be very happy to have people to help test.  I'm sure Kalle will be happy to have someone help with the German version of the commands.

I was doing some testing with RC2 (just updated to RC3 today) and found it was still quite unstable.  Is it just me?  RC2 was crashing every time I closed it, and would often crash when listening to music and then pressing "stop".  Also, some commands I was testing would work fine for a while, and then just stop working.

I think we may still have a long way to go before we have a fully functional VoxCommando / Frodo solution, but I have most stuff working now, most of the time. :)
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: Kalle on January 05, 2013, 05:15:57 PM
Hi Chris und willkommen im VoxCommando forum  ::wave

und da Du es gerade erwähnst
Quote
Now serevals years later I use XBMC to consume HighDefinition Videos over GBLan, controlled from a remotedevice in my pocket (greetings from Android).
One step closer to  the "Star Trek Bridge"

hier ein kleiner Einblick was mit VC so alles machbar ist  ;)

http://www.youtube.com/watch?v=7JyM7bLgADU (http://www.youtube.com/watch?v=7JyM7bLgADU)

@James - At the moment I doesn't use frodo, I'll be waiting to march to take a look on it  ::yikes  (NANO is in my baggage)

Kalle
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: fishware on January 05, 2013, 07:02:44 PM
Quote
I will also need people to help me test these crazy new ideas / workarounds.

Long time i'v been looking for a solution to view my tvshows sometimes in german sometimes in english for while.
All tvshows has as first audiotrack the german language and english as the second. All players incl. XBMC plays after mediachange the first track, so I have to set it to second track manually every time.  >:(
Now i found a solution with  :clap VOXCOMMANDO !!!

<?xml version="1.0" encoding="utf-16"?>
<command id="465" name="AudioStreamChange" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>XJson.Raw</cmdType>
    <cmdString>Player.SetAudioStream&amp;&amp;"playerid":1,"stream":"next"</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>Player.OnPlay</event>
</command>

This runs in the backround. Next step is to set up XBMC to play german or english via voicecommando until it is change via voicecommando

kind regards

chris
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 05, 2013, 08:52:21 PM
Fast learner! :o  I can see you are going to be trouble ;)

The good kind of trouble though.

Quote
This runs in the backround. Next step is to set up XBMC to play german or english via voicecommando until it is change via voicecommando

I'm not sure I understand what you are saying here.  Can you explain more?
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: fishware on January 05, 2013, 09:42:13 PM
Quote
Fast learner! Shocked  I can see you are going to be trouble Wink

Thanks for that.

Often if I at home it runs a TVshow in the background, Episode for Episode (so it is a little trouble at home  ;) )
Most of tvshows i've had, are with two audiotracks in an avicontainer. First track is mostly german, second track is the origin mostly english.
To advanced my english skills, I run the tvshows sometimes only in english episode for episode.

Now the Problem:

After every episode change all mediaplayers that I tried, incl. XBMC switch to the first audiotrack of an avi, in my case mostly german.
Now I must change the audiotrack manually each time.
With voxcommando it is possible to trigger the episode is changed. Than voxcommando send a JSon statement to change the audiotrack.
So I can choose to hear/watch the episodes all in english (if the trigger is on) or in german without the trigger, e.g. shutdown voxcommander.

Next step should be, that voxcommander 'knows' which language i want to hear, and switch the audiotrack after each change automaticly or not.
This to option should be switch via voice commando, and so I looking at the moment to set variables in voxcommand.


I hope I can clear your mind. Sorry for my english, but I trained every day.... ;)

kind regards

chris
 
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 05, 2013, 10:21:11 PM
OK. No problem.  VoxCommando can store a variable which you can set with a voice command.

When a new video begins to play VC can check the variable with a logic block (if then else).

I am away from my computer until tomorrow night , but if you still need help then, I can assist you.

You can either store the variable in memory (VC will forget when you shut it down) or you can write the variable to a text file.  Kalle has an example on the forum where he does this to remember which lights are on or off.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: fishware on January 05, 2013, 10:57:28 PM
Really cool your program.
Easy to learn I think.

One question:

Is there a way to set two IF conditions?

One condition is the playstate of XBMC (paused or not) -> this state I set to a variable 'pause' [on|off]
Second condition is wich language is set, and is it nessesary to switch the audiostream.

Code: [Select]
IF "pause" == off AND IF "lang" == eng
THEN {
           XJson.Raw Player.SetAudioStream "playerid":1,"stream":"next"
         {
ELSE {
          Do nothing
         }


Here is an example, how could it works....

Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: Kalle on January 06, 2013, 04:58:57 AM
Really cool your program.
Easy to learn I think.

One question:

Is there a way to set two IF conditions?

One condition is the playstate of XBMC (paused or not) -> this state I set to a variable 'pause' [on|off]
Second condition is wich language is set, and is it nessesary to switch the audiostream.

Code: [Select]
IF "pause" == off AND IF "lang" == eng
THEN {
           XJson.Raw Player.SetAudioStream "playerid":1,"stream":"next"
         {
ELSE {
          Do nothing
         }


Here is an example, how could it works....


Ich denke es ist möglich, indem Du den "play status" und "lang status" von XBMC in eine Datei speicherst und in deinem Befehl an erster Stelle abfragst.
Schau Dir im Editor unter "file" die actions "writeline" und "readline" an.
Bin Heute unterwegs, aber wenn ich es schaffe gebe ich Dir ein Beispiel.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 06, 2013, 08:38:51 AM
It is not possible to do a compound if statement.  The logic blocks are admittedly, very simple, but they work for the majority of cases.

To get around this we can we can use two if blocks next to eat h other, and if the first condition is not met we call an action to abort execution of the command.

http://voxcommando.com/mediawiki/index.php?title=Actions#StopMacro
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: fishware on January 09, 2013, 06:56:26 AM
Quote
http://voxcommando.com/mediawiki/index.php?title=Actions#StopMacro

Thx. I still need more time to discover the "whole universe" that can my voice control......  ;)

I have found another possible solution. With the

Code: [Select]
{"jsonrpc":"2.0","method":"Player.GetProperties","params":{"playerid":1,"properties":["currentaudiostream"]},"id":1}
I get

Code: [Select]
{"id":1,"jsonrpc":"2.0","result":{"currentaudiostream":{"bitrate":115575,"channels":2,"codec":"mp3","index":1,"language":"","name":"Stereo"}}}
I try this with a telnetsession

Now, I want to use this in VC with the XJson.Raw and the XJson.ParseTokens.

I use it this way

Quote
<action>
                <cmdType>XJson.Raw</cmdType>
                <cmdString>Player.GetProperties&amp;&amp;"playerid":1,"properties":["currentaudiostream"]</cmdString>
                <cmdRepeat>1</cmdRepeat>
            </action>
            <action>
                <cmdType>XJson.ParseTokens</cmdType>
                <cmdString>{item.currentaudiostream[]}</cmdString>
                <cmdRepeat>1</cmdRepeat>
            </action>
            <action>
                <cmdType>OSD.ShowText</cmdType>
                <cmdString>{item.currentaudiostream}&amp;&amp;5000</cmdString>
                <cmdRepeat>1</cmdRepeat>
            </action>

And this is from the vox.Log.txt

Quote
Action:  XJson.Raw - Player.GetProperties&&"playerid":1,"properties":["currentaudiostream"]
09.01.2013 10:48:17   343   action repeat set to: 1

this is from jsonlog.txt

Quote
456   Error while calling JSON RPC:{"jsonrpc": "2.0", "method": "Player.GetProperties", "params":{"playerid":1,"properties":["currentaudiostream"]},"id": "0"}
System.Net.WebException: Der Server hat eine Protokollverletzung ausgeführt.. Section=ResponseStatusLine
   bei System.Net.HttpWebRequest.GetResponse()
   bei vcPlugin.xjComm.PostRequest(String strRequest)

Attached is a screenshot from voxcommando with errormessage

I hope it is not bug in the proggi but rather to me  ;)

chris

Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 09, 2013, 10:05:38 AM
I need to wait until I get home to find a file that has multiple languages in it.  What exactly are you trying to read?  The number of languages?  The current index?

This is return the current index:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="885" name="get stream index" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>XJson.Raw</cmdType>
    <cmdString>Player.GetProperties&amp;&amp;"playerid":1,"properties":["currentaudiostream"]</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>XJson.ParseTokens</cmdType>
    <cmdString>{currentaudiostream.index}</cmdString>
    <cmdRepeat>0</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <cmdString>{LastResult}&amp;&amp;5000</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: fishware on January 09, 2013, 10:19:18 AM
I want to read the current Index.

For future projects it would be nice to read all result items.
So I can specify commands like "switch to english" or "switch to france", if the specified language available.

Thanks Chris
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 09, 2013, 07:47:50 PM
You can read the language too
Code: [Select]
<cmdString>{currentaudiostream.language}</cmdString>This will give to you something like
en - for english
por - for portuguese
If you call this:
Code: [Select]
<cmdString>Player.GetProperties&amp;&amp;"playerid":1,"properties":["audiostreams"]</cmdString>You will recive a array with the audios of the file, samething for "subtitle".
I dont test the Json in VoxCommando yet, so i dont know how to get the values of the array, James will tell you if its possible, maybe with something like this (in the json parse)
Code: [Select]
<cmdString>{audiostreams[0].language}</cmdString>Congratulations James ;D
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 10, 2013, 01:20:08 PM
Thanks Clayton.  You are on the right track for sure.

Here are a couple of sample commands that will give you an idea of what you can do.  If you need explanation just let me know.

By the way, the parse command is one that we will experiment with and possibly, we will decide that there is a better way to do it.  Once you have played with it enough to understand how it works, if you have suggestions, please share them.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 10, 2013, 02:06:03 PM
James, i have to install the Vox in my htpc again.
Do you think its possible insert filters in the request ?
See in this video:

Any request in my app its made with a filter field, if you put this in vox will be a very good thing to play around.
Lets say we wanna play only the unwatched episodes  for a tvshow, we just need to say the name of the tvshow and then your script will make the json request and insert the episodes in a video playlist, this will work for movies (like genre), tvshows and musics (album, artist, genre,...). Everything now can be found with the filters, its cool and we will not have to create any playlist. We can use operators too, like "and" "or".
I can send all the code for you, but its in .js. If you want to make the script to work with this let me know, maybe i can learn a little more working with you  ;D
Clayton
p.s little preview of the tvshow wall in my app 8)
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 10, 2013, 02:22:07 PM
Ok
I just see the code. Its really cool man. Very nice work again. I will play with this a little more.
What is the {LastResult} ? this is the data that you get from the json parse in this case? So, every time that a make a request or a parse i can access the data with the {LastResult}?
If possible can you describe each step ? I am a little lost with some values like
{Var.numstreams} its the length of the variable numstreams, but i dont know how to set the variable for get not only the length, will be nice if you explain each step for us (me :biglaugh);
Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 10, 2013, 03:45:44 PM
Ok, tested a little more. Since we can manipulate the params, we can insert filters too, or not ?
Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 10, 2013, 04:59:16 PM
Ok, tested a little more. Since we can manipulate the params, we can insert filters too, or not ?
Clayton

Yes.  You can send any json command that XBMC will understand.  We can send a sequence of commands such as playlist.clear, playlist.add (type, filter, etc), playlist play, etc.

If you have sample commands with filters please send them to me.  I am sure it will be helpful.  It does not matter if it is in javascript, I just need to look at the json command strings.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 10, 2013, 05:15:04 PM
James, i will post the function here, its big but you will understand, but i will make the request in one line and post later.
I made this function to request tvshows. Its big because i am manipulating 3 filters and 2 operators. this function first  analyze the 2º filter, the analyze the 2º, use the operator to determine if its true or not, and then compare the result with the first filter. I will try to explain this better later.
I will mount the request in a simple line with some examples, i just cant make this right now, sorry.
See the function:
Code: [Select]
self.getTvshowFilter2 = function(type,linkOperator1,linkOperator2,baseJoin,sortorder,sortmethod,field1,operator1,value1,field2,operator2,value2,field3,operator3,
  value3,limits){
      var linkoperator1  = linkOperator1;
      var linkoperator2  = linkOperator2;
      if (limits) {
         var limits = parseInt(limits);
         var params = {
            sort: {"order": sortorder, "method": sortmethod},
            properties: ["title","art","episode","watchedepisodes","year","imdbnumber","playcount","plot"],
            filter: {},
            limits: {"end": limits}
         };
      } else {
        var params = {
           sort: {"order": sortorder, "method": sortmethod},
           properties: ["title","art","episode","watchedepisodes","year","imdbnumber","playcount","plot"],
           filter: {}   
        };
      }
      if (type=="1"){
         params.filter = {field: field1, operator: operator1, value: value1};
      }
      if (type == "2"){
         params.filter[linkoperator1] = [
            {field: field1, operator: operator1, value: value1},
            {field: field2, operator: operator2, value: value2}
         ];
      } else if(type == "3"){
        var filteroperator2 = {};
        filteroperator2[linkoperator2] = [
            {field: field2, operator: operator2, value: value2},
            {field: field3, operator: operator3, value: value3},
         ];
         params.filter[linkoperator1] =[
           filteroperator2,
           {field: field1, operator: operator1, value: value1}
         ]
      } 
      self.rpc("VideoLibrary.GetTVShows", params, function(data) {
      // CF.logObject(data);
          CF.listRemove("l"+baseJoin);
          var arrayTvShowFilter = [];
          for (i=0;i<data.result.limits.end;i++){
             var tvshowid = data.result.tvshows[i].tvshowid;
             var showtitle = decode_utf8(data.result.tvshows[i].title);
             var plot = decode_utf8(data.result.tvshows[i].plot);
             var banner = self.URL + "vfs/" + data.result.tvshows[i].art.banner;
             var episode = data.result.tvshows[i].episode;
             var watchedepisodes = data.result.tvshows[i].watchedepisodes;
             var unwatched = episode - watchedepisodes;
             var unwatched = "Não Assistidos: "+ unwatched;
             var playcount = data.result.tvshows[i].playcount;
             var playcount = (playcount > 0) ? 1:0;
             var year = "("+data.result.tvshows[i].year+")";
             var imdbnumber = data.result.tvshows[i].imdbnumber;
             arrayTvShowFilter.push({
                s21 : tvshowid,
                s22 : showtitle,
                s23 : banner,
                s24 : year,
                s25 : unwatched,
                d21: {
       tokens: {
       "[tvshowid]": tvshowid,
                     "[imdbnumber]": imdbnumber,
                     "[plot]": plot,
                   }
                },
                d22: playcount
            });
          }
          CF.listAdd("l"+baseJoin,arrayTvShowFilter)
          if (baseJoin  == XBMCMacMini.joinTvShowWallTopList){
             self.arrayTvShowWall = [];
             self.arrayTvShowWall = arrayTvShowFilter;
             self.buildTvShowWall(XBMCMacMini.joinTvShowWall,2);
          }
      })
  }
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 10, 2013, 05:17:48 PM
Ok
I just see the code. Its really cool man. Very nice work again. I will play with this a little more.
What is the {LastResult} ? this is the data that you get from the json parse in this case? So, every time that a make a request or a parse i can access the data with the {LastResult}?
If possible can you describe each step ? I am a little lost with some values like
{Var.numstreams} its the length of the variable numstreams, but i dont know how to set the variable for get not only the length, will be nice if you explain each step for us (me :biglaugh);
Clayton

{LastResult} is like a variable that gets updated any time an action produces a result.  Some actions (for example OSD.Show) do not change the value of {lastresult}

When we send the first action:
Code: [Select]
<action actiontype="XJson.Raw" repeat="1" logic="False"><paramstring>Player.GetProperties&amp;&amp;"playerid":1,"properties":["audiostreams"]</paramstring></action>
Then {LastResult} will be equal to whatever XBMC returns.  For example is I have two audio streams it might be somethign like this:
Code: [Select]
{
  "audiostreams": [
    {
      "index": 0,
      "language": "fre",
      "name": "DTS 5.1 - DTS 5.1"
    },
    {
      "index": 1,
      "language": "eng",
      "name": "DTS 5.1 - DTS 5.1"
    }
  ]
}

When we call XJson.ParseTokens, LastResult result will be replaced with a new value.  Parse tokens modifies the input string and replaces  tokens such as {audiostreams[0].language} based on the the last json response that was received from XBMC.  Whatever string we get is now stored in {LastResult}.  In this case the token is {audiostreams[

Next I am creating a new variable to store a value in.  When I call
Code: [Select]
<action actiontype="Results.SetVar" repeat="1" logic="False"><paramstring>numstreams&amp;&amp;{LastResult}</paramstring></action>
I am creating a variable called "numstreams" and putting the value of {LastResult} into it.  Later I can read this variable using {var.numstreams}

In the case of the command named: "XJson audio stream languages parse and logic" I am then using this variable with Logic Blocks, to decide how to parse the JSON data that was returned by calling Player.GetProperties   "playerid":1,"properties":["audiostreams"]

if there is only one stream, I show it by parsing tokens again, this time I use the format:
Code: [Select]
Stream 0:{audiostreams[0].language}
and if there are 2 streams I show the data for both of them by using this format:
Code: [Select]
Stream 0:{audiostreams[0].language}{CR}Stream 1:{audiostreams[1].language}
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 10, 2013, 05:25:37 PM
How, great. Very thanks for take time to explain this. I will have some fun making codes for Xbmc with Vox now ;D
Thanks again.
Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 10, 2013, 05:35:55 PM
I think we have a bit of work to do still.

We can use a filter with GetTVShows, but this does not really allow us to play all the TVShows...

It is for this reason that I mostly am planning to use Smart Playlists.

But maybe we can do something with it still.  It will require some thought, and a lot of work I think, but we will figure it out!
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 10, 2013, 05:39:56 PM
Jame, my intention its use your addon to insert the files in the playlist, its very easy to make. Maybe will be better pass the params directly for the addon, and then make the json request with this we can easily insert the files in a playlist ;D
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 10, 2013, 05:59:17 PM
Yes, it should be possible to request a list of songs using a filter and then create a playlist.  My only concern is that this is very inneffecient because we need to loop though all the results and add each song to the playlist, one by one, and each time we do this we need to create a new JSON command that we send accross the network.  The old http api was so much better because we could just send an sql statement.  It was fantastic.  Why they had to change this I will never understand.  :(

I am wondering if it makes more sense for us to use the voxtools plugin to do this.  At least that way we are not creating a huge amount of network traffic for nothing.  the python script could do it all internally.

If you just want to request music by id (album, artist, song) here are some commands that are working for me:
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 10, 2013, 06:30:26 PM
Yes, the script its a lot of better to manipulate and create playllists on the fly.
But we can use filters to get cool requests.
Code: [Select]
{"jsonrpc": "2.0", "method": "videoLibrary.Gettvshows", "params":
    { "sort": {"order": "descending", "method": "lastplayed"},
    "filter": {"field": "inprogress", "operator": "true", "value": ""},
    "proerties":["title"]  }, "id": 1}
The filter above give us the lastplayed tvshow if this tvshow have at least one episode unwatched. Its cool.
Lets  insert another filter:
Code: [Select]
{"jsonrpc": "2.0", "method": "videoLibrary.Gettvshows", "params":
    { "sort": {"order": "descending", "method": "lastplayed"},
   "filter": {"and":[{"field": "inprogress", "operator": "true", "value": ""},{"field": "title", "operator": "startwith", "value": "a"}}],
   "proerties"["title"]  }, "id": 1}

Now we get the last tvshow played with at least one episode unwatched and the title start with the char "a", its just a exemple.
We can create many filters we want, what we will do with the result its another history ;D
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 10, 2013, 06:45:32 PM
Make a filter can be little complicate.
See:
Code: [Select]
{"jsonrpc": "2.0", "method": "videoLibrary.Gettvshows", "params": { "sort": {"order": "descending", "method": "lastplayed"},
   "filter": {and:["or":[{"field": "inprogress", "operator": "true", "value": ""},{"field": "genre", "operator": "startwith", "value": "a"}],{"field": "title", "operator": "startwith", "value": "a"}}],
   "proerties"["title"]  }, "id": 1}
First the xbmc will see if the tvshow has a inprogress field or the genre start with "a", if one of this its true the xbmc will see if the title start with the char "a" .
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: fishware on January 10, 2013, 08:23:27 PM
Hey claymic, hey jitterjames,

very nice code of both from you. Really Thanks.
I understand much more how voxcommand rocks (works), and what is possible with XBMC JSON <--> VoxCommando.
I also play a little bit around with this stuff.

Last night I create a few timer with Voxcommando, so I can "set" my eggtimer on Sunday via Voicecommando like "Set timer 5 minutes an 30 seconds" or "Set timer to 4 minutes" Its really cool to do this that way.

If your are interrested on these scripts, let me know it.

voxcommando-infected

chris
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 10, 2013, 08:35:47 PM
Yes Chris, VoxCommado its  great and the support its the best. I am now trainning my htpc, i lost my hd few weeks ago, its time to get the vox working again ;D
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: fishware on January 10, 2013, 09:33:52 PM
Here it comes:


After I get the time to count, I call a vbscript that returns the time to count in seconds, so I can use [attachment=1][attachment=1]the VC.SetEventTimer (is there any way to calculate simple arithmatics with VC itself?).

Is the timer up, i fired a eventghost event, because currently I'm using windows 7 and it don't have a german TTS. To play a little with the new Windows 8 Metro GUI I run it in a VM with a 22" Touchscreen (really cool Metro app for XBMC look here: http://apps.microsoft.com/windows/en-us/app/fb9b17a9-0613-4fa6-b7a0-ee233c1a0e71 )

Windows 8 includes a german TTS named Hedda. So I can route TTS output via EventGhost with payload to my Windows 8 german TTS.

Feel free to fire your own events, may be you try to shut the whole internet, after your egg is cooked  well.

chris

Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 11, 2013, 08:37:45 AM
Ok, started to make my new commands. is there any default configuration for the XBMC JSON ?
Anyway i will make the changes and post here.
Lets start with the simple commands first  ;D
XBMC Go To Windows
[attachment=1]
Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 11, 2013, 10:35:54 AM
Since i am not feeling my fingers anymore(copy,paste,copy,paste, ::club), i will stop for a while, but let me share another group first.
This group have almost all actions that you need to control the xbmc, its just a copy and paste control for a Input.ExecuteAction . Many of this commands we can put in a playload later, i just make separately for a quick test to see what this commands does. I think there is more then 100 commands inside this group.
If you guys found any error let me know to fix it. Maybe i will insert more payloads later. Some of the commands like audio delay plus i put a loop, but dont test yet because i cant play the video in this pc, i will test later if you guys dont do this first ;D.
Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: Kalle on January 11, 2013, 10:38:52 AM
Ok, started to make my new commands. is there any default configuration for the XBMC JSON ?
Anyway i will make the changes and post here.
Lets start with the simple commands first  ;D
XBMC Go To Windows
[attachment=1]
Clayton

Hi Clayton, big thanks to start with this commands, that is exactly what I need to find a start with JSON   :clap
I'll translated the commands in german too.
If you have more, post it  ;)

Kalle
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 11, 2013, 10:40:31 AM
kalle, i am thinking of making all the commands.
I am waiting my fingers wake up :biglaugh.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: Kalle on January 11, 2013, 10:43:16 AM
kalle, i am thinking of making all the commands.
I am waiting my fingers wake up :biglaugh.
Haha, no hurry - you are the best  :hugs

Is there anything to do in XBMC to work with this commands?
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 11, 2013, 10:55:26 AM
Kylle you just need to use the Frodo RC1 or later.
Forgot to put the payloads, my bad


Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 11, 2013, 10:57:02 AM
Since i am not feeling my fingers anymore(copy,paste,copy,paste, ::club), i will stop for a while, but let me share another group first.
This group have almost all actions that you need to control the xbmc, its just a copy and paste control for a Input.ExecuteAction . Many of this commands we can put in a playload later, i just make separately for a quick test to see what this commands does. I think there is more then 100 commands inside this group.
If you guys found any error let me know to fix it. Maybe i will insert more payloads later. Some of the commands like audio delay plus i put a loop, but dont test yet because i cant play the video in this pc, i will test later if you guys dont do this first ;D.
Clayton
Thanks Clayton

This is very helpful.  I would like to point out though, that for most of the simple actions, I think it is better to use the old Btn.KB commands.  However, there may be some situations where using the JSon method is preferable so this is still a very valuable resource.  The Btn.KB method is faster and lighter, and we have the advantage of commands that vary with context, because we are simulating a keypress.

the advantage of the Json commands is that VC will wait for confirmation of the command (sometimes you want this and sometimes you don't) and in some cases we may want to execute a specific action and not rely on context.

So for example, if we are using the scroll (up down left right) or Cancel, or select, then using the Btn.Kb method is better.

But if we are doing a complex macro where we need to wait to make sure that XBMC is ready before we go to the next action, then it is better to use the JSon actions.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 11, 2013, 10:58:56 AM
Haha, no hurry - you are the best  :hugs

Is there anything to do in XBMC to work with this commands?
You should only need to enable the network service and set the port, however, some commands will only work with the later version of Frodo.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: Kalle on January 11, 2013, 11:00:12 AM
You should only need to enable the network service and set the port, however, some commands will only work with the later version of Frodo.
Ok, thanks  :D
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 11, 2013, 11:03:07 AM
Kylle you just need to use the Frodo RC1 or later.
Forgot to put the payloads, my bad


Clayton

This seems like the same file twice.  Is there supposed to be a difference between:  "xbmcLevelJson.xml"  and "xbmcZoomLevelJson.xml" ?
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 11, 2013, 11:29:10 AM
the advantage of the Json commands is that VC will wait for confirmation of the command (sometimes you want this and sometimes you don't) and in some cases we may want to execute a specific action and not rely on context.

So for example, if we are using the scroll (up down left right) or Cancel, or select, then using the Btn.Kb method is better.

But if we are doing a complex macro where we need to wait to make sure that XBMC is ready before we go to the next action, then it is better to use the JSon actions.
You read my mind James. You are all right. I made some tests in vox early to see if the actions will works like a callback function.
Thanks for the tips. Later i will start some more complex actions and maybe create a little plugin to manage our tvshows. Let´s see.
Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 11, 2013, 11:47:22 AM
You read my mind James. You are all right. I made some tests in vox early to see if the actions will works like a callback function.
Thanks for the tips. Later i will start some more complex actions and maybe create a little plugin to manage our tvshows. Let´s see.
Clayton
my bad again, its the same, just use the xbmcZoomLevelJson
James
I am trying to generate my xml for xbmc, but i get a error. Where i can see the log of this error to post here ?
Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 11, 2013, 12:13:45 PM
Where i can get the voxtools.zip ?
Thanks
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 11, 2013, 12:25:51 PM
please use the repository to install it.

use "install from zip" to install the repository with the attached file.  then you can install VoxTools after that.

The current version of VoxTools should be 0.1.3
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 11, 2013, 12:27:47 PM
Thanks James, you send this to my email but i cant found it ;D
More tests coming ::)
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 11, 2013, 02:28:23 PM
Here are some more groups to play with.  One is just to play a movie (with resume if in progress)

the other is to request some info about currently playing music
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 11, 2013, 02:30:25 PM
Here are some commands to play music (artist, album, song)
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 11, 2013, 02:35:34 PM
Here is XML for a group to test all actions I know of, it is probably the same as the ones that clayton uploaded, but this one is using payloads because it was easier for me to copy paste from an excel sheet!  I am including it only in case Clayton missed some...

Here is the group xml to copy and paste, and the attached file is the payloadXML


Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<commandGroup open="True" name="XJSON Execute Actions Payload" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="182" name="Test Action {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>XJson.Raw</cmdType>
      <cmdString>Input.ExecuteAction&amp;&amp;"action":"{1}"</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Test Action</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone">payloads\execute actions.xml</payloadFromXML>
  </command>
</commandGroup>
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 11, 2013, 03:06:25 PM
And here are some of the new commands that use smart playlists.

You must have the latest version of voxTools for these to work.  The contents of smarts.zip should be in your VC\smarts folder
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 11, 2013, 03:10:56 PM
Great James, thanks for all the codes.
The fist time that a made the execute action commands i made in this way too, everything in one payload, but for us from Brasil this can be complicate, we have to put separate commands to training the Vox or we will not be able to control in Portuguese. I have to isolate the commands to get a good result with the training.
I will test all the codes tonight.
Thanks again
Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 11, 2013, 03:12:24 PM
Ok, i will suggeste to you put all the commands in the first post too, i believe that this topic will be big very soon ;D
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 11, 2013, 03:38:45 PM
James
I tried again generate my xml for xbmc, but every time i get a error. I have to configure something ?
Thanks
Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: Wanilton on January 11, 2013, 05:23:36 PM
Clayton,I generate XML for xbmc, follow the step go to setting addon xsql, point for your database, and press save and generate.

(https://voxcommando.com/forum/proxy.php?request=http%3A%2F%2Fi.imgur.com%2F28fAr.jpg&hash=c12a90fb38da126dcb0342d9208aadefb7be3b73)

Done.

Clayton, ative os addons necessários, configure o addon xsql, aponte para os bancos de dados de músicas e filmes, e pressione na aba de configuração o botão save and generate.

"Quem é mestre, não perde o trono" Wanilton

 :biglaugh :biglaugh
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 11, 2013, 06:46:18 PM
Clayton,I generate XML for xbmc, follow the step go to setting addon xsql, point for your database, and press save and generate.
...

Also make sure that the plugin is using the latest database files.  Each version of Frodo that comes out seems to change the number of the database.

You can also ask for this using an action:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="437" name="gen xml Frodo" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>XSQL.GenerateAll</cmdType>
    <cmdString />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>gen xml Frodo</phrase>
</command>

I did not yet add it to the documentation but I will update this in the next version.  It works fine in the current version.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: Wanilton on January 11, 2013, 08:06:44 PM
Yes, in my case database files are MyMusic32 and MyVideos75, only need search for files in database folder, when fine file, change red for green color in addon setting.

Wanilton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 11, 2013, 08:58:16 PM
Thanks guys.
Ok James, dont get upset with me ;D but i made some changes in your script. A little resume with the three most important add
- i made a function to let the VoxTools be running forever. A instance of the script will be running until we call again the script. This will let us manipulate some data that we get in the last call of the script, if we want of course.
- I insert a function to monitoring the player of the xbmc, this means that we can always know if a file (movie, tvshow or music) start,stop or finnesh to play.
- The third function its a little udp send. This will send a envent to vox.
We can now get automatic responses from VoxCommando.
Exemple:
When a movie start to play in the xbmc, a event its send to vox, we can then create a action for this event.
If you are not angry with me :biglaugh Please help me with the send event to vox. For now if you play a movie its send the string "movie", if play a music its send "music", if its playing a episode its send "tvshow"
I just dont remember how its the event, its something like "event&&movie" ?
Test and let me know what you think about this. There is many situations where we can use this.
Wanilton will like, i am pretty sure. If we are playing a music the vox can now read the name of song automatic, without have to send any command to the vox.

Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: Wanilton on January 11, 2013, 09:37:21 PM
Events exist in voxcommando, and I use events for auto read info via tts with multiples languages in music, equal your idea. 

 :o :o :o
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 11, 2013, 09:41:08 PM
I tested now Wanilton, i only get the same event when i am playing something: "Player.OnPlay", for music, tvshow and movies.
Clayton
p.s oh, we can use the getNowPlaying later to see what is playing, by type. But with the script we can determine this very fast and without have to make many conditionals. We can see if we are playing a tvshow, movie or trailer for example.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 12, 2013, 09:09:39 AM
I still have some work to do with the events.  Maybe they can be improved.

Clayton, I very much appreciate your help with the script.  I think it might come in handy, but only as an option because some users may not want a script that is always running in the background and executing a loop of code every 0.5 seconds.

It would be nice if there were a way for a script to stay resident in memory and wait to be called though, currently it seems that every time we call the script it needs to be loaded by xbmc so it is slightly slow sometimes.

If I am not able to improve the events generated by the json plugin then we can either try to make a configuration screen where the user can choose to use the event loop or not.  If that is too hard then we could make this a separate script available in the VC repository.  In any case, even if we don't use this feature it is interesting and helpful to see it and to be aware of new possibilities.  ;D ;D
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 12, 2013, 09:11:46 AM
Ok guys, now i made some more modifications in the and its done for you test, if you want of course.
Now the script run when you start the xbmc, because that you have to replace two files in the script.voxtolls, normally will be in this folder
C:\Users\your user name\AppData\Roaming\XBMC\addons\script.voxtools
Close the xbmc and then copy and paste this two files inside the folder
[attachment=1]
[attachment=2]
Now you can open the xbmc and play around with this.
Every time you start, stop or a file ended to play the vox will get a event like:
EpisodeStart
EpisodeStop
EpisodeEnd
Same thing for Movies, Album and Trailer
I made a poor group example for test.
[attachment=3]
Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 12, 2013, 09:21:37 AM
James
Code: [Select]
Clayton, I very much appreciate your help with the script.  I think it might come in handy, but only as an option because some users may not want a script that is always running in the background and executing a loop of code every 0.5 seconds.

It would be nice if there were a way for a script to stay resident in memory and wait to be called though, currently it seems that every time we call the script it needs to be loaded by xbmc so it is slightly slow sometimes.
Every script in the xbmc run in this way, with 0.500ms or whatever , the users dont see but they are running, there is no way to prevent a script to close without this. Of course we can manage the time and put any value we want. Every call inside the Vox will have the same time, no slow, since this execute first and outside. The script still running only for monitoring the player. I think that all the scripts in xbmc who need to monitor the player use this, its default for the xbmc.
I test here without any delay.
But if you can improve the events from Json, better. This will be awesome.
Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 12, 2013, 09:24:16 AM
I am sure I can improve it.  but this is giving me another idea as well...  >:D  :biglaugh

I would suggest that you try a 1500 ms delay which should be fine for our purposes, instead of 500 ms.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 12, 2013, 09:30:06 AM
The problem with the use of the values like 1500 its that we get the risk to not close the others instances opened. I put 500 there, but in the init of the main i put 2000, just to be sure that any old instance will be close after the script run again. But i will test.
I really like when you are enthusiastic with some ideas, this means that we will have some very good news soon ;D
Thanks for all James
Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 12, 2013, 09:42:07 AM
There is a strange behavior in the xbmc when its playing a audio file James. You can see in the script that i only send the event for Vox one time, but i can see in the .log that two events its sent. Strange, i dont figure out why. Xbmc bug ?
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 12, 2013, 09:59:26 AM
James,
How can i send a event for Vox with some params (args)?
Lets say i want to send this event: "MovieId"
in the script i can send with this: "event&&MovieId"
But if i want to send the event with the number of the movie for example, how can i do ?
lets say this:
"event&&MovieId,35"
I want to get the value 35 and use inside a action, so the MovieId will be my event, and 35 will be my arg.
its possible ?
Thanks
Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 12, 2013, 11:25:41 AM
There is a strange behavior in the xbmc when its playing a audio file James. You can see in the script that i only send the event for Vox one time, but i can see in the .log that two events its sent. Strange, i dont figure out why. Xbmc bug ?
It seems to be a bug in XBMC, I get it too with the JSON notifications that are sent.  I wonder if they are aware.  If someone wants to check/open a ticket that would help me a lot.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 12, 2013, 11:49:37 AM
James,
How can i send a event for Vox with some params (args)?
Lets say i want to send this event: "MovieId"
in the script i can send with this: "event&&MovieId"
But if i want to send the event with the number of the movie for example, how can i do ?
lets say this:
"event&&MovieId,35"
I want to get the value 35 and use inside a action, so the MovieId will be my event, and 35 will be my arg.
its possible ?
event&&Movie&&35

but you won't need to do this I am making good progress with events in the XJson plugin.  You just need to wait a few hours, or maybe a day. :)
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 12, 2013, 12:13:27 PM
James
Thanks, its just to learn.
I made this already event&&movie&&35
But, how i can use this in a action ? I tried with the payload and {1}, dont work.
Thanks for all your effort.
Clayton
p.s its more easy to me make a script to show you what i am trying to do, then try to explain what i want in my bad english :biglaugh
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 12, 2013, 12:51:52 PM
Ok, forgot that, its working. ;D
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 12, 2013, 01:29:52 PM
yeah, I was going to say... "it SHOULD work!".

OK I have made enough progress that I can upload the next plugin for testing.

This one has improved events, but I am sure there is still a lot of work to do!
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 12, 2013, 01:34:45 PM
here is a sample command to announce songs:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="476" name="OnPlay Song" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>TTS.Stop</cmdType>
    <cmdString>{LastResult}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>XJson.Raw</cmdType>
    <cmdString>Player.GetItem&amp;&amp;"playerid":0, "properties": ["title", "album", "artist", "rating","playcount","genre"]</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>XJson.ParseTokens</cmdType>
    <cmdString>Now Playing : {item.title}, by Artist {item.artist[[ &amp; ]]}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.Speak</cmdType>
    <cmdString>{LastResult}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>XBMC.Player.OnPlay.song</event>
</command>

It always announces songs twice which is why I put the action:  TTS.Stop  at the beginning.

If you try to use TTS.speakSync this won't work and you will hear the announcement twice.

I need to figure out if this is a problem with XBMC or what...
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 12, 2013, 02:17:49 PM
Great job James,
I will play with this a little ;D
Very thanks
Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 12, 2013, 03:09:01 PM
James
That its exactly what we need. Well done again, i play a little with the Events and get the result that i get with the script. Its nice and fun. We can now start to make our commands to get some nice tts return.
Thanks Again, but let me suggest another implement in your plugin.
Do you remember the VcGetInfo plugin ?
In your script we can insert this very easy like you make for ExecBuiltin, but we have to  this for the:
Code: [Select]
xbmc.getInfoLabel and xbmc.getCondVisibilityWhy ?
Lets say we are navigating over our movies and we want to get some information about it. Now we are only able to do this if we play the file or use the VcGetInfo plugin.
But you can make in your script something like this:
Code: [Select]
elif cmdtype == "getInfo":
          if xbmc.getCondVisibility( 'Container.Content(Movies)' ):  
             title=xbmc.getInfoLabel( "ListItem.Title" )
             sendToVox("event&&Movie&&%s"%title)
Same thing for music, tvshow, file, playlist, or whatever, the getCondVisibility will always let us to know what window its open in xbmc ;D
We get the title (we cant get the ID), so we can use a json with a filter to get the data of this movie in vox. I believe that Json will not be able to manage this alone, i dont know anyway to json get a information inside a container, i think its not possible, only using a script like i post above. I use the same function from the script that i sent early for send the event for Vox, but to test i need the vox send the "getinfo" for the script.
I am terrible to describe this things in english, let me know if you get the idea, if not i can make the script and send to you.
Let ´s put you to work a little more :biglaugh I am your friend :biglaugh
Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 12, 2013, 04:36:00 PM
in JSON we have access to most of this stuff.

Here is a sample command.  It is not complete but it shows some possibilities.

I guess the question is, how exactly do we want to use this, and what will be the most powerful but flexible combo for all users.  I don't know yet...  I have to think about it more.

the main problem with the script is that it requires us to use events, and it is not possible to edit the script for the normal user.  Anyway, we don't want all users to have different versions of the script or it will cause a lot of confusion.

Trying to do it all using the LCB and actions right now is possible, but maybe a bit painful to do.  So I will try to think of ways to make it easier.

How do you use this?  do you ask "what item am I currently on?" or do you want to detect any time you are on a new item and have it speak?

Is that possible to do? (detect when a new item is selected, or new window opens in XBMC)
I might not use this myself, but for a blind person maybe it could be very helpful...

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="453" name="getinfolabels test 1" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>XJson.Raw</cmdType>
    <cmdString>XBMC.GetInfoBooleans&amp;&amp;"booleans": ["Container.Content(movies)"]</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>{LastResult}&amp;&amp;true</ifParams>
    <then>
      <action>
        <cmdType>XJson.Raw</cmdType>
        <cmdString>XBMC.GetInfoLabels&amp;&amp;"labels": ["System.CurrentWindow","System.CurrentControl","Listitem.Label"]</cmdString>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <cmdString>MOVIES: {LastResult}</cmdString>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
</command>
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 12, 2013, 04:52:49 PM
I am terrible to describe this things in english, let me know if you get the idea, if not i can make the script and send to you.
Let ´s put you to work a little more :biglaugh I am your friend :biglaugh
Clayton

You explained it very well.  I understand completely.  I am very interested in these scripts.  It is cool that you can grab a handle to "MyPlayer()" and then listen for events by defining "def onPlayBackEnded(self):" for that class.  I love it. This is very good to know about!  I wonder if we could do the same thing with the GUI to listen for when the user has changed to a new window...

My main concern is that I want VC to be as independent as possible so that if someone has not installed the script, most things will still work.  For some things, like execbuiltin, we do not have a choice at all, so it must be in the script.  For other things, like the softmute command, we could probably do it with VC completely, but I think it makes more sense to put it in the script instead of doing many calls back and forth between VC and XBMC...  It is not always obvious which is the best way.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 12, 2013, 05:16:45 PM
Ok James, i am not blind too, but i have to say that get the plot of the movie without have to play it its my best command in Vox. I use the wall view, to read the plot i have to open the info page, the plot its very dificcult to read if i am using the tv, if am using the projector its fine. I use vox to read the plot to me. If i dont use getinfolabels, vox will only be able to read the plot if i play the file, its not a good process i think.
Maybe you cant see the advantage of this, but i use a lot. I just say Read to Me and its Done, Vox read the plot and the ratio. Another thing, if we get the movie path we can get the trailer too, so i use this to read the plot and i can play the trailer if i want. For me its very useful.
There is another reason to use this, the plot can be big and the space for the plot in the skin its always small, the priority its for the fanart or thumb. Put the skin to scroll the plot its annoying! Automatic or not.
I never see the GetInfoBooleans, its a very nice command and i will read a little more about it right now, the wiki page of the Json its some thing at least weird.
Very thanks for your help.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 12, 2013, 05:23:39 PM
Oh, the Json have now the getinfolabels, that is a very good thing to have. I missed that, i will have to make some changes in my app too and make some commands for vox. Now i am happy!
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 12, 2013, 05:54:36 PM
yes there is a lot of information to access here:

http://wiki.xbmc.org/index.php?title=InfoLabels

and

http://wiki.xbmc.org/index.php?title=List_of_Boolean_Conditions

I agree, this information can be very useful to make our commands more intelligent and open up the possibilities.  What I meant, was that I would not want my computer to speak every time I selected a new item!  That would be too noisy... but if I were blind I might need it.

Anyway, it doesn't only matter how I would use it, I always try to think of all the ways any user might want to use it, and then try to find a balance that is not too much trouble.  but OK, how I would use it always takes priority ;)
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 12, 2013, 07:15:16 PM
Oh, my bad James, i understand wrong :bonk
To make my day the only thing left its create a playlist for unwatched episodes. I dont understand why the guys from xbmc dont add this to Json like we can do with albums, songs, flies,etc, using the ID. We can play or insert a album with the id, but we cant make this for tvshow or seasons. The only way its use a loop to insert each episode by time., at least i think so.
But at least now we can use the filters and get the fisrt episode unwatched and play it. When the episode ended the xbmc will set the episode for watched, so we can use the event EpisodeEnded(i dont remember exactly the name) to run the  command again or just call the command again, will always play the first episode unwatched.
Thanks
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 12, 2013, 08:28:11 PM
My smart playlist command for unwatched episodes works well.  I like being able to view the list before playing.  I uploaded it recently.
http://voxcommando.com/forum/index.php?topic=940.msg8119#msg8119

Tomorrow I will look at a solution for using filters.  Probably, this would be something we could put in the script.

I also intend to add actions to the xsql plugin at some point, that will allow us to make custom queries.  From there we would still need to find a nice way to create a playlist.  For the people who are using MySQL, I guess it will be a problem...
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: eQUIV on January 15, 2013, 01:48:45 AM
Hi, I'm new to VoxCommando.. just wanted to say I wish I had heard of it earlier. This is great program. Thanks for all your hard work on it.

Now my question, I am running XBMC Frodo RC3.. and I have installed some of the updated entries you posted in this thread. However some commands don't work.. I think specifically the JSON commands.

I'm unable to login to the XBMC HTTP webserver... it seems to reject my login. Are you aware of any known problems with the RC3 release in this respect?

Do I need the latest nightly for these new JSON commands to work?

Any help would be greatly appreciated.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: claymic on January 15, 2013, 07:43:06 AM
Do you enabled the plugins ?
I made a little video showing how to do
http://youtu.be/wzlWOspxyKc
Clayton
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: eQUIV on January 15, 2013, 08:07:36 AM
Clay... Thanks or the video, however I already had those enabled.. Settings input, imported my XBMC library to XML. Although I don't have TCPMic enabled (at least I don't think I do), I'm not at home at the moment so I can't confirm. Is that plugin important/related?

I seem to get authentification errors for the JSON required commands. I am also unable to login to the HTTP web interface for XBMC. I've triple checked my port, username/pass settings. Curious if anyone else running RC3 has had this problem. Unable to login. I'm running Windows 8 x64. Port is open on router, Windows Firewall is off.. Running XBMC and VoxCommando as admin.. Can't seem to figure out the problem.

I'm stumped, any ideas?
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 15, 2013, 08:18:24 AM
Clay... Thanks or the video, however I already had those enabled.. Settings input, imported my XBMC library to XML. Although I don't have TCPMic enabled (at least I don't think I do), I'm not at home at the moment so I can't confirm. Is that plugin important/related?

I seem to get authentification errors for the JSON required commands. I am also unable to login to the HTTP web interface for XBMC. I've triple checked my port, username/pass settings. Curious if anyone else running RC3 has had this problem. Unable to login. I'm running Windows 8 x64. Port is open on router, Windows Firewall is off.. Running XBMC and VoxCommando as admin.. Can't seem to figure out the problem.

I'm stumped, any ideas?
Hi, I'm new to VoxCommando.. just wanted to say I wish I had heard of it earlier. This is great program. Thanks for all your hard work on it.

Now my question, I am running XBMC Frodo RC3.. and I have installed some of the updated entries you posted in this thread. However some commands don't work.. I think specifically the JSON commands.

I'm unable to login to the XBMC HTTP webserver... it seems to reject my login. Are you aware of any known problems with the RC3 release in this respect?

Do I need the latest nightly for these new JSON commands to work?

Any help would be greatly appreciated.

Hi eQUIV and welcome to the forum and to VoxCommando.

RC3 is fine. Just the regular version from here: http://xbmc.org/download/

You need the latest version of VoxCommando which is currently here: http://voxcommando.com/forum/index.php?topic=969.0

and then update the XJson plugin for VC with the latest version from this thread.

You don't need the TcpMic plugin unless you are using VoxWav for Android as a microphone.

Send us pictures of your XBMC settings pages and your XJson plugin settings.  If you want to be more thourough enable logging in VC and in XBMC and send us the logs after you try to send a command.

Warning: This topic is for experienced users who are experimenting with new and incomplete features so it will probably be a bit hard to a new user to follow everything.  Some of the commands that I post here will be incomplete because the intended audience is people who already know what they are doing.

I hope to release a more complete version of VC with all the latest plugins and settings for Frodo soon.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 15, 2013, 08:22:05 AM
I seem to get authentification errors for the JSON required commands. I am also unable to login to the HTTP web interface for XBMC. I've triple checked my port, username/pass settings. Curious if anyone else running RC3 has had this problem. Unable to login. I'm running Windows 8 x64. Port is open on router, Windows Firewall is off.. Running XBMC and VoxCommando as admin.. Can't seem to figure out the problem.

Are you talking about actually logging into XBMC using a web browser?  If so, what url are you using?  Which port are you using?  (send those images  :D)

You should not need to open an ports on your router unless you are accessing your computer from outside your lan.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: eQUIV on January 16, 2013, 12:49:17 AM
James.. Thanks for your help. Upgrading to the latest version of VoxCommando seems to have fixed my authentication issues. Everything seems to be working now. Can't wait to play around and get some other features working.

Is it possible to setup commands to launch specific XBMC add-ons and smart playlists?
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on January 16, 2013, 10:51:15 AM
Is it possible to setup commands to launch specific XBMC add-ons and smart playlists?

Yes.  The commands for addons will vary but here's an example that opens the subtitle downloader addon while viewing video:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="388" name="download subtitles" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>XJson.Raw</cmdType>
    <cmdString>Addons.ExecuteAddon&amp;&amp;"addonid":"script.xbmc.subtitles"</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>download subtitles</phrase>
</command>

Here is one way to open a smart playlist:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="131" name="open smart playlist" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>XJson.Raw</cmdType>
    <cmdString>GUI.ActivateWindow&amp;&amp;"window": "video", "parameters": [ "special://profile/playlists/mixed/voxsmart.xsp" ]</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: Kickers56 on February 01, 2013, 11:26:45 AM
Hi guys,

Making the switch to Frodo (final release) and VC (0.9.8.0) and see all your hard work remapping everything through Json has really paid off. I'm going to have a play around myself to understand how it all works with some of my own commands, but for sake of speed I wonder if its possible to control pvr channels? If so, if I wanted to switch to channel 5 (whatever station is mapped to channel 5) is there a command to do that through VC.

I searched these forums and couldn't find any mention of this and if no one has done it I will play around with Json myself but if someone has already got a command xml for doing this, great.

oh love all the enhancements to VC, particularly the command editor...well done.

tom
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on February 01, 2013, 11:40:18 AM
Hi Kickers,

Unfortunately I don't have any PVR hardware so it is kind of difficult for me to work on this.  However, if you have time we could work on it together on your system using TeamViewer, and then I could add the commands to the default config.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on February 02, 2013, 02:06:17 PM
you can try this command.  I have no way of testing it, so I don't know if it works

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="800" name="Change to channel {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>XJson.Raw</cmdType>
    <cmdString>Player.Open&amp;&amp;"item":{"channelid":{1}}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Change to channel</phrase>
  <payloadRange>1,200</payloadRange>
</command>
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: Kickers56 on February 04, 2013, 12:15:14 PM
Sorry about late reply, had a 'working' weekend.

Tried the xml you provided above and it does (I don't know how you do it) work. It goes instantly to the channel I specify. It does however, when I say 'channel 1' start up the 1st radio station I have tuned rather than the tv channels. So I have to start at channel numbers from 30 after all my radio stations to get the tv channels, but that obviously is how the backend has set up my channel listings. I will either have a play around with the backend to see if I can swap them, or just set up commands once I know all the channel ID's for the TV channels with phrases to the station names. Time consuming - but what I wanted anyway.

So in conclusion, what you did works with the PVR setup in Frodo(final release).

Thanks James

kickers56
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on February 04, 2013, 04:37:58 PM
Glad to hear it.  :D ;D

Once you get everything set up correctly, could you please send me the epg.db file that is in your XBMC database folder?

C:\Users\YOURUSERNAMEHERE\AppData\Roaming\XBMC\userdata\Database

and the filename is something like "Epg7.db"

I'll see if there is a way to generate the channel names payloadXML from that.
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on February 04, 2013, 04:39:55 PM
oh and I guess all the file: "TV22.db"
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: Kickers56 on February 08, 2013, 04:10:02 PM
Ok, here is the tv22 db file you requested

It works great after I manually put in the channel names. Just for reference I am using tvheadend backend tv server and XBMC frodo seems to read the radio channels first then tv channels after. There doesnt seem to be a way I can change this in tvheadend. But you can change channel order within xbmc rather than getting the order from tvheadend server.

Hope it helps

[attachment=1]
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: Kickers56 on February 08, 2013, 04:14:46 PM
I seem to be getting timeouts when trying to upload the epg7 db file...trying again, this time in rar file
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: Kickers56 on February 08, 2013, 04:15:35 PM
that did it!
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on February 08, 2013, 05:01:50 PM
Great.  Thanks.  I don't really understand the whole TV/Radio situation.  It sounds like you can't have both a channel 5 radio and channel 5 TV.  Is that right?  Weird, but there must be some way around it?

Anyway please try the attached update to the XSql plugin which should help to auto-generate the payloadxml for radio and tv channels.

I suggest you delete your options.xml from the XSql plugins folder, but if you don't want to do that, then edit your options.xml in the plugin folder it and add the following entries to the <genXML> sectino so it looks like this:

Code: [Select]
    <genXml>
        <genXmlParam dataType="Music" queryString="select idArtist,strArtist from artist" xmlFilename="xbmcArtists" useSubStrings="True" />
        <genXmlParam dataType="Music" queryString="select idAlbum,strAlbum from album" xmlFilename="xbmcAlbums" useSubStrings="True" />
        <genXmlParam dataType="Music" queryString="select idSong,strTitle from song" xmlFilename="xbmcSongs" useSubStrings="True" />
        <genXmlParam dataType="Music" queryString="select idGenre,strGenre from genre" xmlFilename="xbmcGenres" useSubStrings="False" />
        <genXmlParam dataType="Music" queryString="select distinct idSong,strTitle,strArtists from songview where strArtists!=&quot;&quot;" xmlFilename="XbmcSongsByArtist" useSubStrings="False" />
        <genXmlParam dataType="Video" queryString="select idShow,c00 from tvshow" xmlFilename="xbmcTvShowTitles" useSubStrings="True" />
        <genXmlParam dataType="Video" queryString="select idMovie,c00 from movie" xmlFilename="xbmcMovieIDs" useSubStrings="True" />
        <genXmlParam dataType="Video" queryString="select strpath||strfilename,c00 from movieview" xmlFilename="xbmcMovies" useSubStrings="True" />
        <genXmlParam dataType="TV" queryString="select idChannel, sChannelName from channels where bIsRadio=1" xmlFilename="xbmcRadioChannels" useSubStrings="true" />
        <genXmlParam dataType="TV" queryString="select idChannel, sChannelName from channels where bIsRadio=0" xmlFilename="xbmcTvChannels" useSubStrings="true" />
    </genXml>

the new lines are:

Code: [Select]
        <genXmlParam dataType="TV" queryString="select idChannel, sChannelName from channels where bIsRadio=1" xmlFilename="xbmcRadioChannels" useSubStrings="true" />
        <genXmlParam dataType="TV" queryString="select idChannel, sChannelName from channels where bIsRadio=0" xmlFilename="xbmcTvChannels" useSubStrings="true" />

I hope it's clear but if you need help let me know.  Note that you can customize this depending on your needs.  For example if you just want one command for TV and Radio you could create a single query, instead of the two separate ones

example:
Code: [Select]
<genXmlParam dataType="TV" queryString="select idChannel, sChannelName from channels" xmlFilename="xbmcAllChannels" useSubStrings="true" />
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on February 08, 2013, 05:06:14 PM
Also you need to check your plugin settings to confirm that the path for the TV database is pointing to the correct file: "TV22.db"

OH, and if you don't want to mess around with the xml files you can go into the plugin settings and add two new entries in the table.

Set the type for both of them to "TV", assign whatever filenames you want for the xmlpayload files and for the Query enter these:

for Radio Channels:
Code: [Select]
select idChannel, sChannelName from channels where bIsRadio=1
for TV Channels:
Code: [Select]
select idChannel, sChannelName from channels where bIsRadio=0
Title: Re: XBMC JSON: for pre-Frodo nightlies after Oct. 9th 2012
Post by: jitterjames on February 21, 2013, 03:19:55 PM
After I get the time to count, I call a vbscript that returns the time to count in seconds, so I can use [attachment=1][attachment=1]the VC.SetEventTimer (is there any way to calculate simple arithmatics with VC itself?).
Yes.  There is now, with the python plugin  :D

http://voxcommando.com/forum/index.php?topic=1005.msg8409#msg8409