From lua to AppleScript

Posted on
Sat Feb 14, 2015 2:29 pm
davinci offline

From lua to AppleScript

I want to use this code in AppleScript to control my TV.

Code: Select all
TV = Net.FHttp("192.168.1.6",1925)
jsonString = {id="hdmi1"}
jsonTable = json.encode(jsonString)
response, status, errorCode = TV:POST("/1/sources/current?callback=", jsonTable )


Is there a guide for how to do this? If I just use curl and try to post the jsonString it gives back "bad argument".

Posted on
Mon Feb 16, 2015 6:13 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: From lua to AppleScript

AppleScript isn't very well suited to this task. Python, however, is quite good at both HTTP and JSON.

I'm unclear from your example exactly what's happening though: it looks like you're doing a POST of some JSON data to a url that looks incomplete ("http://192.168.1.6:1925/1/sources/current?callback="). I don't know LUA so I can't really translate. If you can describe exactly what the communication looks like then we can probably figure out the right Python.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Feb 23, 2015 11:55 am
davinci offline

Re: From lua to AppleScript

I'm basically doing this:
http://jointspace.sourceforge.net/proje ... c/API.html

Thanks for further help. I'm now getting into Python. :)

Posted on
Mon Feb 23, 2015 10:04 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: From lua to AppleScript

Yep, that should be quite straight-forward in Python. I highly recommend finding one of the many Python tutorials out on the net and just working your through it. It won't take long and will give you a much better base of understanding before trying to tackle something more complex.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Feb 24, 2015 5:00 am
davinci offline

Re: From lua to AppleScript

I'm doing this learning by doing. But something like this has been done before, so I'm actually looking forward to a code snippet from somebody who does this already.

Posted on
Tue Feb 24, 2015 11:14 am
BassMint offline
Posts: 105
Joined: Dec 24, 2013

Re: From lua to AppleScript

Try putting together the url and test it in your browser. If it gives the right response, then use curl in an shell script or applescript

i.e.

Code: Select all
#!/bin/sh
curl "http://192.168.1.6:1925/1/sources/current?callback=(whatever this is)"


Like Jay said, the url appears incomplete as there should be something after the "="
I learn like you, trial and error, copy and paste.
I am just taking a stab as I really don't know....

in applescript it would be something like:

Code: Select all
do shell script "curl 'http//192.168.1.6:1925/1/sources/current?callback=(whatever this is)'"

Posted on
Wed Feb 25, 2015 9:32 am
davinci offline

Re: From lua to AppleScript

Thanks.

It is all described here:
http://jointspace.sourceforge.net/proje ... -POST.html


For someone like jay an easy task I guess. What do you think?

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 25 guests