2012-02-24, 10:28
see: this post
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,tempstr.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>
var obj = eval('(' + xmlDoc + ')');
CrazyChicken132 Wrote:The resources/channelmap file doesn't exist just the m2xml stuff.
The other file is reachable at this link.
Channel Map.zip
CrazyChicken132 Wrote:No worries, new link below.
Channel list
CrazyChicken132 Wrote: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.
uspino Wrote:So did you find a way to allow selection of favorite channels?
How's everything coming up?
uspino Wrote:A few things/ideas:
- A lot of (small) .ts files remain in the webfiles folder. Should there be a clean up line in the code?
- It would be good to be able to select the temp folder for the transcoding files.
- Are you thinking about a different interface for iPhone/iPad (on iPad looks extremely small)
- Is there a way to start a video stream on an iOS device from a shortcut containing channel & transcode settings, the same way you can do it on VLC? That would be fantastic: you could create a shortcut to, say, ESPN, and just start streaming, or we could create a folder with shortcuts to favourite channels (and there are free apps on the store to assign a logo to each shortcut)
mcheng89 Wrote:Gonna start again right now
Removed input channel tab. Replaced with search button
Quote:Current Bitrates:
"720":["1250","1500","1750"],
"576":["1000","1200","1400"],
"480":["800","1000","1200"],
"320":["500","600","800"],
"240":["300","400","500"]