•   
  • 1
  • 6
  • 7
  • 8(current)
  • 9
  • 10
  • 21
  •   
Release Execute user tasks for Kodi events (callbacks ver2)
Hi KenV99,

following the last posts I was wondering if there is a way your addon can track the execution of another Android app or Android service as an event.

I am having difficulties in using the implemented Airplay function of Kodi (sometimes it is not recognized by iPhones/iPads and iTunes). Therefore I would rather like to use the Android App "Airpin Pro" which runs as a service and works just fine, even allowing Airplay mirroring. However, I have not been able to find an event included in your Callbacks Addon that would be triggered when I connect to Airpin via Airplay.

I would like to use such event to send an http-request to my homeautomation that activates the remote socket of my TV and AVR, so they both "wake up" when I start playing something via Airplay (otherwise you would see or hear anything).
Reply
(2016-03-30, 15:26)fantasticn Wrote: Hi KenV99,

following the last posts I was wondering if there is a way your addon can track the execution of another Android app or Android service as an event.

I am having difficulties in using the implemented Airplay function of Kodi (sometimes it is not recognized by iPhones/iPads and iTunes). Therefore I would rather like to use the Android App "Airpin Pro" which runs as a service and works just fine, even allowing Airplay mirroring. However, I have not been able to find an event included in your Callbacks Addon that would be triggered when I connect to Airpin via Airplay.

I would like to use such event to send an http-request to my homeautomation that activates the remote socket of my TV and AVR, so they both "wake up" when I start playing something via Airplay (otherwise you would see or hear anything).

I can't think of any simple way of implementing this. Since it is a Kodi addon, monitoring other processes outside of Kodi is beyond the scope of it's purpose.
If you have access to the java source and are experienced at compiling for Android I would say to write a file to a given directory on connect and then delete it on disconnect. Then you could use the addon's watchdog event to trigger of the appearance and disappearance of that file.
Reply
(2016-03-30, 13:17)KenV99 Wrote:
(2016-03-30, 03:56)subzero79 Wrote: I just tested from Rpi OSMC, and it works ok it sends the name as argument.

BTW I just noticed that you added POST, GET, etc. Gonna give them a try.

Yes, I pushed another update, including the other HTTP verbs available within the requests module and creates a session object for use during the send cycle.
This update also provides additional information in the log to see what the url that has been assembled.
It also includes everything possible to obtain a title for a file (I was concerned that the reason you weren't getting a title is that the addon couldn't resolve one).

I tested it using an Android emulator and it sends the title to my echo server, so hopefully this works for you.

The title is working now in firetv, however for a series it just sends the episode name. This is the log for Line of Duty season 3 episode 1. Mediatype still shows as unknown, playback percentage works also.

Code:
01:16:45 web.1  | 10.10.10.23 - - [31/Mar/2016 01:16:45] "GET /kodi/test HTTP/1.1" 200 113 1.3897
01:16:45 web.1  | 10.10.10.23 - - [31/Mar/2016 01:16:45] "GET /favicon.ico HTTP/1.1" 404 36 0.0020
01:17:12 web.1  | 10.10.10.23 - - [31/Mar/2016 01:17:12] "GET /kodi/test HTTP/1.1" 200 534 1.0090
01:17:55 web.1  | 10.10.10.23 - - [31/Mar/2016 01:17:55] "GET /kodi/test HTTP/1.1" 200 534 1.0089
01:18:32 web.1  | 10.10.10.13 - - [31/Mar/2016 01:18:32] "POST /kodi/Episode%201 HTTP/1.1" 200 541 1.0115
[01:29:27 web.1  | 10.10.10.13 - - [31/Mar/2016 01:29:27] "GET /kodi/17/Episode%201/unknown/nfs://10.10.10.12/export/videos/series/ricardo/Line%20of%20Duty/Season%203/Line%20of%20Duty%20-%20S03E01%20-%20SDTV%20-%20ORGANiC.mp4 HTTP/1.1" 200 718 1.0095
01:35:22 web.1  | 10.10.10.23 - - [31/Mar/2016 01:35:22] "POST /kodi/ HTTP/1.1" 200 654 1.0097
01:35:37 web.1  | 10.10.10.23 - - [31/Mar/2016 01:35:37] "POST /kodi/ HTTP/1.1" 200 548 1.0081
01:36:04 web.1  | 10.10.10.23 - - [31/Mar/2016 01:36:04] "POST /kodi/ HTTP/1.1" 200 674 1.0095
01:38:38 web.1  | 10.10.10.23 - - [31/Mar/2016 01:38:38] "POST /kodi HTTP/1.1" 200 548 1.0080
01:42:05 web.1  | 10.10.10.13 - - [31/Mar/2016 01:42:05] "GET /kodi/0/Super%208/unknown/nfs://10.10.10.12/export/videos/peliculas/Super%208%20(2011)/Super%208%202011%20BluRay%201080p%20LTT.mkv HTTP/1.1" 200 680 1.0083

As for me ATM i can work out with just the filename, get all the info from there, since the videos are named properly.

Also if you're gonna introduce POST shouldn't be available a field to put the payload, either in json or x-form-urlencode? This is good since atm with fn the webhook server assumes all slashes are field separators and I get like 10 or 12 arguments. Using curl would be

Code:
--data "arg1=nfs://10.10.10.12/export/videos/series/ricardo/Line of Duty/Season 3/Line of Duty - S03E01 - SDTV - ORGANiC.mp4&arg2=22&arg3=unknown"

Code:
--data "arg1=%fn&arg2=%pp&arg3=%mt"


or
Code:
--data '{ "arg1" : "nfs://10.10.10.12/export/videos/series/ricardo/Line of Duty/Season 3/Line of Duty - S03E01 - SDTV - ORGANiC.mp4", "arg2" : 22, "arg3" : "unknown"}'

Code:
--data '{ "arg1" : "%fn", "arg2" : %pp, "arg3" : "%mt"}'


I would have three well defined variables
Reply
I added more variables for you to send via onPlaybackStarted. Download the latest and give it a try.
I switched to using jsonrpc to obtain the data with backups. If you are getting any unknowns, then I'm at a loss how to fix it.
I have coded every trick in my book to get the data.

You can payload post with the userarg line:
Code:
/kodi?var1=x&var2=y

Creating multiple different ways of doing things within Kodi's settings.xml syntax is very painful.
That file is already 1088 lines long and unintelligible to most humans.
I have no intention of also letting you type in dict's as well at the moment.
Reply
(2016-03-31, 23:36)KenV99 Wrote: You can payload post with the userarg line:
Code:
/kodi?var1=x&var2=y

Creating multiple different ways of doing things within Kodi's settings.xml syntax is very painful.
That file is already 1088 lines long and unintelligible to most humans.
I have no intention of also letting you type in dict's as well at the moment.

Tested and tvshow variables are working good on Playbackstarted, but playbackpause and stop don't pass variables. Looking at github seems like you only enabled started.

[code]01:44:52 web.1 | I, [2016-04-01T01:44:52.371526 #19] INFO -- : worker=2 ready
01:44:52 web.1 | I, [2016-04-01T01:44:52.375267 #16] INFO -- : worker=1 ready
01:45:01 web.1 | 10.10.10.13 - - [01/Apr/2016 01:45:01] "GET /kodi/%25pp/Episode%201/episode/ HTTP/1.1" 200 561 1.0191 <---playstart
01:48:12 web.1 | 10.10.10.13 - - [01/Apr/2016 01:48:12] "GET /kodi/episode/Aquarius%20(2015)/01/01 HTTP/1.1" 200 570 1.0099 <--playstart
01:56:19 web.1 | 10.10.10.13 - - [01/Apr/2016 01:56:19] "GET /kodi//%25st/%25se/%25ep/-122084 HTTP/1.1" 200 564 1.0081 <-- playend
01:57:09 web.1 | 10.10.10.13 - - [01/Apr/2016 01:57:09] "GET /kodi/episode/%25st/%25se/%25ep/86 HTTP/1.1" 200 570 1.0082
01:58:56 web.1 | 10.10.10.13 - - [01/Apr/2016 01:58:56] "GET /kodi//%25st/%25se/%25ep/-264613 HTTP/1.1" 200 564 1.0082
02:01:32 web.1 | 10.10.10.13 - - [01/Apr/2016 02:01:32] "GET /kodi/unknown/%25st/%25se/%25ep/%25pp HTTP/1.1" 200 573 1.0083 <--playpaused[ /code]


I understand is hard to keep everyone happy, i can mostly work with just one variable %fn and fetching data from kodi api (like playcount or playback status)

Correct if I am wrong, there is no way of passing payload in URL using POST because payload goes in form, is only in GET that you can pass parameters (query). I think you should remove POST option then.

Anyway thanks again for your time and code
Reply
(2016-03-30, 22:33)KenV99 Wrote:
(2016-03-30, 15:26)fantasticn Wrote: Hi KenV99,

following the last posts I was wondering if there is a way your addon can track the execution of another Android app or Android service as an event.

I am having difficulties in using the implemented Airplay function of Kodi (sometimes it is not recognized by iPhones/iPads and iTunes). Therefore I would rather like to use the Android App "Airpin Pro" which runs as a service and works just fine, even allowing Airplay mirroring. However, I have not been able to find an event included in your Callbacks Addon that would be triggered when I connect to Airpin via Airplay.

I would like to use such event to send an http-request to my homeautomation that activates the remote socket of my TV and AVR, so they both "wake up" when I start playing something via Airplay (otherwise you would see or hear anything).

I can't think of any simple way of implementing this. Since it is a Kodi addon, monitoring other processes outside of Kodi is beyond the scope of it's purpose.
If you have access to the java source and are experienced at compiling for Android I would say to write a file to a given directory on connect and then delete it on disconnect. Then you could use the addon's watchdog event to trigger of the appearance and disappearance of that file.

Ok, but unfortunately I have no skills in programming anything for Android. Anyway, thanks for your answer!
Reply
Pushed another update to GitHub.
I added all variables to all onPlayback events, let me know if its not working.

I made it so that for post events, anything after a '??' is treated as payload with content-type 'application/json'.
For example:
Code:
/test?x=arg??{"jsonrpc": "2.0", "method": "JSONRPC.Introspect", "id":1, "params": { "getmetadata": true }}
That way you can still include query data and also then include a json payload.

If someone REALLY needs other content types, let me know, but I haven't come up with an easy way to integrate choosing a type into the settings without a lot of major rewrites.

Edit: I added content-types on task settings screen. Obviously I am not enabling multipart/form-data file uploading.
Reply
Just testing the new one since i saw activity at your github, I didn't see this post until now, so before that i gave my other webhook server documentation another read (i was using hookhand before, now i am using this one https://github.com/adnanh/webhook), and this one was possible to configure it to pass payload as query in GET so it goes in URL as you described with ?arg1 and so on, the script will receive one argument as json format with all the variables, from there i strip down with jq

I put
Code:
10.10.10.12:7501/hooks/kodi?title=%ti&season=%se&episode=%ep&mediatype=%mt&playback=%pp
and i get

Code:
{"episode":"12","mediatype":"episode","play":"33","season":"01","title":"Orange Is the New Black"}
on the script

Beautiful....working very good just using GET, however I think you missed putting the variable options for playBackended, i added the tvshow ones to events.py and is working ok i think. Android and linux kodi.

Thanks very much
Reply
Wink 
Nice work Ken. It has taken me awhile to get this up and working with my "Resume, Delete, Play another show" function. Not because of any issue with your addon, but the fact that I was in the hospital for awhile and sick. Back home doing well and busy working on my "projects" now.

This version is clearly more advanced then your previous one and is working flawlessly with my python script. Just took me a bit to work out the parameters that I was passing to it. Much more flexibility there then the previous version, but I had to do a bit of experimentation to get it right. Right now I only have it installed on my Jarvis test machine, which is Windows 10. I plan to put it on my "production" HTPC (Windows 7 pro) tomorrow. That system is still running Gotham. I won't get into why as it is too long a story. So I assume it will work just fine under Gotham?

The way I rewrote my python script, it should work just the same under your old version or the new, but I will find out for sure tomorrow. When I initially write a piece of code, I just do what is necessary to get it to work. But when I "re-write" the code, I try to make it more efficient as well as more maintainable. So my current version should be easier to fix when need be.

Again, thanks for your hard work and beautiful piece of code. I worked in the IT business for many years before I retired. You have to be an artist to be a real good coder. You are an artist!
Reply
(2016-04-08, 19:58)ReplayHarry Wrote: Nice work Ken. It has taken me awhile to get this up and working with my "Resume, Delete, Play another show" function. Not because of any issue with your addon, but the fact that I was in the hospital for awhile and sick. Back home doing well and busy working on my "projects" now.

This version is clearly more advanced then your previous one and is working flawlessly with my python script. Just took me a bit to work out the parameters that I was passing to it. Much more flexibility there then the previous version, but I had to do a bit of experimentation to get it right. Right now I only have it installed on my Jarvis test machine, which is Windows 10. I plan to put it on my "production" HTPC (Windows 7 pro) tomorrow. That system is still running Gotham. I won't get into why as it is too long a story. So I assume it will work just fine under Gotham?

The way I rewrote my python script, it should work just the same under your old version or the new, but I will find out for sure tomorrow. When I initially write a piece of code, I just do what is necessary to get it to work. But when I "re-write" the code, I try to make it more efficient as well as more maintainable. So my current version should be easier to fix when need be.

Again, thanks for your hard work and beautiful piece of code. I worked in the IT business for many years before I retired. You have to be an artist to be a real good coder. You are an artist!

Thank you for all the kind compliments!

Unfortunately, the addon is for helix and above. If you really need to run it on Gotham, I can make a few small changes and create a new branch for you sometime tomorrow.

EDIT: There is a branch called gotham for you to use. It *should* work, but I don't have gotham installed to test. Let me know.
Reply
And sorry to hear you were sick. I hope you're well along your path to healing up.
Reply
http://pastebin.com/4NpJ4nNc

Thanks for your good wishes. Doing better now.
After I sent that 1st note, I did get an exception so have attached a pastebin link.
It was a divide by zero error. I can see the error, but don't know what may be causing it.

Sorry to hear it won't work with Gotham, but not surprised as there is a lot more this new version can do then the older one. I doubt some of those things were possible in Gotham. So no need to give me new branch. Going to try my revised code over on the Gotham system tomorrow and I think it should work fine with your old version. I kinda wrote my revised code that way just in case.
If the Kodi team gets 1 problem fixed (that started with Helix) I will eventually get to a newer version which can use your newer code. But Gotham is still working just fine on my main HTPC. Using Jarvis on 2 other systems I have, but I don't let those 2 system erase anything, so they don't have the "Resume, Delete, play another show" function installed.

Again, thanks for your support.
Reply
I pushed an update to the gotham branch. Hopefully that fixes your problem, but you may not be able to use the 'percent played' variable for playback ended.
Reply
Thanks. I'm not using that "percent played" variable anyway. I imagine that is where the divide by zero came into play.

Only vars I am using is onPlaybackStarted, onPlaybackResumed, and onPlaybackStopped. The vars I use are event, media type, and filename.
It's working great.
Thanks much.
Reply
Is it possible to set delay for the event?

Lets say i want to turn off the amp when the movie stops. But if i start new movie in less than 1min, amp does not power off but it stays on. (1 min delay).
Reply
  •   
  • 1
  • 6
  • 7
  • 8(current)
  • 9
  • 10
  • 21
  •   



Logout Mark Read Team Forum Stats Members Help
Execute user tasks for Kodi events (callbacks ver2)3
This forum uses Lukasz Tkacz MyBB addons.