Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Topic:
HTTP GET for Dreambox
This thread has 11 replies. Displaying all posts.
Post 1 made on Tuesday August 21, 2007 at 14:32
thoupis
Long Time Member
Joined:
Posts:
August 2007
124
I have a module which I created in Crestron for Dreambox STB units in which I use the HTTP GET command with two carriage returns to execute over IP. How would this command be substituted in Pronto Script?
Demetris
Post 2 made on Tuesday August 21, 2007 at 18:54
sWORDs
Long Time Member
Joined:
Posts:
November 2006
373
Use the read method of the TCPSocket class.
Post 3 made on Tuesday August 21, 2007 at 19:46
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
You actually have to build socket script to issue HTTP protocol. Look at the Dev Guide for an example of how they are browsing google.com.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 4 made on Saturday December 22, 2007 at 09:00
snelvuur
Long Time Member
Joined:
Posts:
November 2007
55
Still needs more work, will add word wrapping to it when i have the time. (following lyndels advise on some wrapping then)

This snippet will show you the current and the next item what is on the dreambox. I have this on my main tv screen on the pronto. Also have a button which shows the relevant info about the show that is playing. Which is basicly the same like below code, if someone wants that too let me know.

Change the ip, and make sure your pronto is allowed to go to the website withou authorisation. Hope this works on other dreamboxes too (depending on your build)

Eric

var result = "";
var socket = new TCPSocket(false);
var t1,t2,t3,t4,t5;
var event1,event2;
var descrip1, descrip2;

socket.onConnect = function()
{
socket.write("GET /cgi-bin/channelinfo HTTP/1.1\r\n");
socket.write("Accept: */*\r\n");
socket.write("Host: 192.168.1.99\r\n");
socket.write("\r\n");
};

socket.onData = function()
{
result += socket.read(5000,1000);

t0 = result.indexOf("class=\"time\">", 0)+13;
t10 = result.indexOf("/span>",t0)-1;
tijd1 = result.substring(t0,t10);

t1 = result.indexOf("class=\"event\">", 0)+14;
t2 = result.indexOf("/span>",t1)-1;
event1 = result.substring(t1,t2);
CF.widget("channel1").label=event1;

t4 = result.indexOf("class=\"description\">", t2)+20;
t5 = result.indexOf("/span>",t4)-1;

t6 = result.indexOf("class=\"event\">", t5)+14;
t7 = result.indexOf("/span>",t6)-1;
event2 = result.substring(t6,t7);
CF.widget("channel2").label=event2;

};


socket.onClose = function()
{
};


socket.onIOError = function(e)
{
};


if(socket.connected == false)
{
socket.connect('192.168.1.99', 80, 3000);
};
Post 5 made on Saturday December 22, 2007 at 10:43
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
One change I would recommend here.

socket.write("GET /cgi-bin/channelinfo HTTP/1.0\r\n");

Why? Because HTTP 1.0 automatically closes sockets at the end of the request. You'll thank me in a month or so. ;-)
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 6 made on Sunday December 23, 2007 at 07:44
Chak
Long Time Member
Joined:
Posts:
July 2005
48
On December 22, 2007 at 10:43, Lyndel McGee said...
One change I would recommend here.


socket.write("GET /cgi-bin/channelinfo HTTP/1.0\r\n");

Why? Because HTTP 1.0 automatically closes sockets at
the end of the request. You'll thank me in a month or
so. ;-)

Thanks for the tip...:)
Post 7 made on Sunday December 23, 2007 at 09:05
rvdvoort
Lurking Member
Joined:
Posts:
August 2005
8
Snelvuur,

Thanks for the Code. It works great on my 7020 Dreambox. If you also have the code for the "info" of a show I would appreciate when you could publish it.

Thx,
Rob
Post 8 made on Sunday December 23, 2007 at 12:41
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
Update - Http 1.0 was supposed to close sockets but I've found cases where some servers don't (Escient Fireball PC). So, you should also put in a request header in the body as a hint.

Connection: close\r\n

Happy Holidays
Lyndel
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 9 made on Thursday December 27, 2007 at 09:04
snelvuur
Long Time Member
Joined:
Posts:
November 2007
55
@rdvoort: i'll put it here too, but it does not have word wrapping yet. Only wraps at a certain amount of characters.
Post 10 made on Friday December 28, 2007 at 05:39
rvdvoort
Lurking Member
Joined:
Posts:
August 2005
8
@snelvuur
I have modified your script and also tried to add word rapping (adjust value "a" for the width of your panel). Probably not the most efficient way to do it but unfortunately I don't have any experience with Javascript. My program knowledge stops at programming in Fortran 77 many years ago ;-)

The only problem I currently have is that special characters like for example "ö" or "ü" do not show up correctly. Not sure if someone knows a solution for this problem.

====================================

var result = "";
var socket = new TCPSocket(false);
var t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;
var event1,event2,tijd1,tijd2,prog1;
var str1,str2,descrip1, descrip2;
var patt1 = /\s+/;
var woord = new Array();
var woord2 = new Array();
var a;
a = 0;
var descrip1="";
var descrip2="";

socket.onConnect = function()
{
socket.write("GET /cgi-bin/channelinfo HTTP/1.1\r\n");
socket.write("Accept: */*\r\n");
socket.write("Host: 192.168.0.9\r\n");
socket.write("\r\n");
};

socket.onData = function()
{
result += socket.read(5000,1000);

t1 = result.indexOf("colspan=\"3\">", 0)+12;
t2 = result.indexOf("/th",t1)-1;
prog1 = result.substring(t1,t2);
CF.widget("program").label=prog1;

t3 = result.indexOf("class=\"time\">", 0)+13;
t4 = result.indexOf("/span>",t3)-1;
tijd1 = result.substring(t3,t4);
CF.widget("time1").label=tijd1;

t5 = result.indexOf("class=\"event\">", 0)+14;
t6 = result.indexOf("/span>",t5)-1;
event1 = result.substring(t5,t6);
CF.widget("eventnow").label=event1;

t7 = result.indexOf("class=\"description\">", t6)+20;
t8 = result.indexOf("/span>",t7)-1;
str1 = result.substring(t7,t8);
woord = str1.split(patt1);
for (x in woord)
{
a= a + woord[x].length;
if (a < 50)
{
descrip1 = descrip1 + woord[x]+" ";
a=a+1;
}
else
{
descrip1 = descrip1 + "\r\n"+woord[x]+" ";
a = woord[x].length+1;
}
};
CF.widget("info1").label=descrip1;
a=0;

t9 = result.indexOf("class=\"time\">", t8)+13;
t10 = result.indexOf("/span>",t9)-1;
tijd2 = result.substring(t9,t10);
CF.widget("time2").label=tijd2;

t11 = result.indexOf("class=\"event\">", t8)+14;
t12 = result.indexOf("/span>",t11)-1;
event2 = result.substring(t11,t12);
CF.widget("eventlater").label=event2;

t13 = result.indexOf("class=\"description\">", t11)+20;
t14 = result.indexOf("/span>",t13)-1;
str2 = result.substring(t13,t14);
woord2 = str2.split(patt1);
for (x in woord2)
{
a= a + woord2[x].length;
if (a < 50)
{
descrip2 = descrip2 + woord2[x]+" ";
a=a+1;
}
else
{
descrip2 = descrip2 + "\r\n"+woord2[x]+" ";
a = woord2[x].length+1;
}
};
CF.widget("info2").label=descrip2;
};


socket.onClose = function()
{
};


socket.onIOError = function(e)
{
};


if(socket.connected == false)
{
socket.connect('192.168.0.9', 80, 3000);
};
Post 11 made on Friday December 28, 2007 at 07:41
snelvuur
Long Time Member
Joined:
Posts:
November 2007
55
me neither, although lyndel pointed out [Link: snippets.dzone.com] this snippet. Which basicly would be a bit better (i think) not sure.
Post 12 made on Sunday December 30, 2007 at 06:43
frankbe
Long Time Member
Joined:
Posts:
December 2007
10
Here's a function to convert utf-8 to ascii i found somewhere on the web:

System.print(utfconf(descrip1));

prints the correct special characters on the debug panel. Unfortunately if you try to
assign the converted string to a label, there are the wrong chars again.

this seems to be a bug in the firmware as Barry Gordon mentioned in thread:
[PS] Displaying special characters
[Link: remotecentral.com]




Ciao
Frank


function utfconv(utftext)
{
var string = "";
var i = 0;
var c = c1 = c2 = 0;

while ( i < utftext.length ) {
c = utftext.charCodeAt(i);

if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}

}

return string;
}


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse