XBMC Community Forum
[dev] CetonTV+HDHomeRun - Watch TV on XBMC (WIN/OSX) - Printable Version

+- XBMC Community Forum (http://forum.xbmc.org)
+-- Forum: Development (/forumdisplay.php?fid=32)
+--- Forum: Python Add-on Development (/forumdisplay.php?fid=26)
+--- Thread: [dev] CetonTV+HDHomeRun - Watch TV on XBMC (WIN/OSX) (/showthread.php?tid=119865)



- europorsche914 - 2012-02-24 10:28

see: this post


Issue with remoteCeton application - CrazyChicken132 - 2012-02-24 15:01

I'm not sure what is wrong with either my setup, only getting the startup and the found tuner lines in the window and nothing else.

[Image: remotecetonscreen.png]

Any Ideas?


- mcheng89 - 2012-02-24 15:45

Can you send me a copy of the web page:
http://<ceton ip>/Services/ChannelMap.html

I couldn't find a upnp call for the channel map, so I just rip it off the HTML.

Also, can you send me the resources/channelmap.csv file, if it exists.


- mcheng89 - 2012-02-24 15:53

europorsche914 Wrote:so I spent the last 12 hours getting epg data parsed into a table that correctly handles time zone differences of the host/client computers (if client is in a different timezone it will still show epg data of the host computer or atleast that is how its suppose to work, I havent tested it yet), It also adjusts for am/pm and shows 10 channels at a time, feel free to use any of this code as needed and it is by no means a finished web epg, I will update this post as I continue to improve this code.

To modify this code to fullfill your needs the channellist should list the channels you would like to display guide data for, and chlindex is how many channels you want to guide for minus one (10 channels, chlindex=9) also modify xmlhttp.open to the ip address running the remoteceton api. Im too tired right now to streamline it anymore, let me know if there are any issues

Code:
<html>
<head>
<script language="javascript" type="text/javascript">
  var currentTime = new Date();

  var tzone = currentTime.getTimezoneOffset()/60;
  var currentHours = currentTime.getHours()+tzone-5;
  var currentMinutes = currentTime.getMinutes();

  // Pad the minutes and seconds with leading zeros, if required
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;

  // Choose either "AM" or "PM" as appropriate
  var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

  // Convert the hours component to 12-hour format if needed
  currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

  // Convert an hours component of "0" to "12"
  currentHours = ( currentHours == 0 ) ? 12 : currentHours;


function getEPGData() {
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    } else
    {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    [b]xmlhttp.open("POST","http://******:8555/getEPGData",false);[/b]
    var timeoff = new Date().getTimezoneOffset();
    var ctime = (new Date().getTime()+(timeoff*60000)-(5*3600*1000));
    var start_time = ctime/1000;
    var end_time = (parseInt(ctime/1000)+5400);

    var myEPG = new Array();

        
    [b]channellist = "3,6,8,10,12,13,14,15,477,551";[/b]

    xmlhttp.send("{\"start_time\":"+start_time+",\"end_time\":"+end_time+",\"channels\":["+channellist+"]}");
    xmlDoc=xmlhttp.responseText;
    currenttable="<table border='1'><tr><th>Channel</th><th>"+currentHours+":"+currentMinutes+" "+timeOfDay+"</th><tr>";
    tempstr=xmlDoc.substr(2);
    tempindex=tempstr.indexOf('"');
    var chlindex=0;
    var i=0;

    while ([b]chlindex<=9[/b]) {
        while (tempindex>=1) {
            myEPG[chlindex,0+i]=tempstr.substring(0,tempstr.indexOf('":'));
            tempstr=tempstr.substr(tempstr.indexOf("program_title"));
            myEPG[chlindex,1+i]=tempstr.substring(16,tempstr.indexOf('",'));
            tempstr=tempstr.substr(tempstr.indexOf("start_time"))
            myEPG[chlindex,2+i]=parseInt(currentMinutes)-(Math.floor(((ctime/1000)-parseInt(tempstr.substring(12,tempstr.indexOf(',"'))))/60));
            tempstr=tempstr.substr(tempstr.indexOf("end_time"))
            myEPG[chlindex,3+i]=parseInt(currentMinutes)+Math.ceil(Math.abs(parseInt(tempstr.substring(10,temps​tr.indexOf('}'))-(ctime/1000))/60));
            tempstr=tempstr.substr(tempstr.indexOf('"'));
            myEPG[chlindex,4+i]=currentHours;
            myEPG[chlindex,5+i]=timeOfDay;
            myEPG[chlindex,6+i]=currentHours;
            myEPG[chlindex,7+i]=timeOfDay;

            while ((myEPG[chlindex,2+i]/-60)>=1) {
                myEPG[chlindex,4+i]=myEPG[chlindex,4+i]-1;
                myEPG[chlindex,2+i]=myEPG[chlindex,2+i]+60;
            }
            while ((myEPG[chlindex,2+i]/60)>=1) {
                myEPG[chlindex,4+i]=myEPG[chlindex,4+i]+1;
                myEPG[chlindex,2+i]=myEPG[chlindex,2+i]-60;
            }
            myEPG[chlindex,2+i]=Math.abs(myEPG[chlindex,2+i]);

            while ((myEPG[chlindex,3+i]/60)>=1) {
                myEPG[chlindex,6+i]=myEPG[chlindex,6+i]+1;
                myEPG[chlindex,3+i]=myEPG[chlindex,3+i]-60;
            }


            if (myEPG[chlindex,4+i]<1) {
                myEPG[chlindex,4+i]=12+myEPG[chlindex,4+i];
                if (myEPG[chlindex,5+i]="AM")
                    myEPG[chlindex,5+i]="PM";
                else
                    myEPG[chlindex,5+i]="AM";

            }

            if (myEPG[chlindex,6+i]>12) {
                myEPG[chlindex,6+i]=myEPG[chlindex,6+i]-12;
                if (myEPG[chlindex,7+i]="AM")
                    myEPG[chlindex,7+i]="PM";
                else
                    myEPG[chlindex,7+i]="AM";
        
            }

            if (myEPG[chlindex,4+i]==12) {
                if (myEPG[chlindex,5+i]=="PM")
                    myEPG[chlindex,5+i]="AM";
                else
                    myEPG[chlindex,5+i]="PM";
            }

            if (myEPG[chlindex,6+i]==12) {
                if (myEPG[chlindex,7+i]=="PM")
                    myEPG[chlindex,7+i]="AM";
                else
                    myEPG[chlindex,7+i]="PM";
            }

            if (myEPG[chlindex,2+i]<=9)
                myEPG[chlindex,2+i]="0"+myEPG[chlindex,2+i];

            if (myEPG[chlindex,3+i]<=9)
                myEPG[chlindex,3+i]="0"+myEPG[chlindex,3+i];
            if (myEPG[chlindex,0+i]!="")
                currenttable=currenttable+"<td ALIGN=Center>"+myEPG[chlindex,0+i]+"</td>";

            currenttable=currenttable+"<td ALIGN=Center>"+myEPG[chlindex,1+i]+"\n"+myEPG[chlindex,4+i]+":"+myEPG[chlindex,2+i]+myEPG[chlindex,5+i]+"-"+myEPG[chlindex,6+i]+":"+myEPG[chlindex,3+i]+myEPG[chlindex,7+i]+"</td>";

            tempindex=tempstr.indexOf('{"');
            if (tempstr.indexOf(',{"')!=0)
                i=i+10;
                if (tempstr.indexOf(',"')<=tempindex) {
                    tempindex=tempstr.indexOf('{"');
                    i=0;
                    chlindex=chlindex+3;
                    currenttable=currenttable+"</tr><tr>";
                    tempstr=tempstr.substr(tempstr.indexOf('],"')+3);
                }
        

        }
    }
    document.getElementById("epg").innerHTML=currenttable+"</tr></table>";
    xmlhttp.close;
}
</script>
</head>
<body onload="getEPGData()">
<div id=epg></div>
</body>
</html>

Hmm... Maybe a
Code:
var obj = eval('(' + xmlDoc + ')');
Would work too... (forgot about this)


- CrazyChicken132 - 2012-02-24 16:05

The resources/channelmap file doesn't exist just the m2xml stuff.

The other file is reachable at this link.

Channel Map.zip


- mcheng89 - 2012-02-24 16:11

CrazyChicken132 Wrote:The resources/channelmap file doesn't exist just the m2xml stuff.

The other file is reachable at this link.

Channel Map.zip

Sorry I gave you the wrong URL.
It's this one: http://<ceton_ip>/view_channel_map.cgi?page=0


- CrazyChicken132 - 2012-02-24 17:22

No worries, new link below.

Channel list


- mcheng89 - 2012-02-24 18:11

CrazyChicken132 Wrote:No worries, new link below.

Channel list

I'll let you know when I get home. Have to check if there's an issue parsing your channel map... Won't be until tonight

Also, gonna release a newer iPhone layout...


- CrazyChicken132 - 2012-02-24 18:24

Sounds, good.

I can setup remote access if you would like and Visual Studio 2010 on the box, if it will help.


- CrazyChicken132 - 2012-02-24 20:16

Got it working after installing the latest firmware update for the card...

Also installed visual studio so it may have been a combination of a couple things.