« Home | StarCraft 2 GPU Overheating FIX » | Starcraft 2 - 0day Download Experience - Boosted » | How To Downgrade Windows 7 Ultimate to Professiona... » | first impressions of Google’s Skipfish WVS » | My New ESXi Lab System » | Released : JSecurityModule » | Install MySQL 5.1 on Debian 5.0.3 HOW-TO » | הזמנה – הרצאה על אבטחת מסדי נתונים, במיקרוסופט ישר... » | איך להתקין Windows 7 מ USB DiskOnKey » | iSCSI Storage Initiator / Target in a Linux Enviro... »

Checking if a Stream is Online/Offline (PHP)

For the past year I have been watching SOOO many streams online. it got to a point where it almost completely replaces my TV view time.

as of 2011 the main streaming sites for video games are Justin.TV, Own3d.TV, Regame.TV.

all of these sites allow you to stream video over RTMP, and have become very popular with many sites and companies embedding such mechanisms to broadcast video on demand, and live streaming of events and games/tournaments.

each site therefor has its own API for developers/site builders to be able to embed things from their streams, and the most basic thing is an ONLINE Indicator.

so my 0.02 cents here will be to list functions that will enable you to have an Online indicator for each of the above, hoping that its saves some time…

for the examples, I used PHP for some quick and dirty coding.

for Justin.TV --

//justintv status check
function justinTVcheck ($channelName) {
$channelName = strtolower($channelName);
$json_file =
http://api.justin.tv/api/stream/list.json?channel=" . $channelName;
$json = file_get_contents($json_file);
if (strpos($json, 'name')) {
return (1); //online
} else {
return (0); //offline
}
}

for own3d.TV --

//own3d status check
function ownedTVcheck ($channelName) {
$request = '
http://api.own3d.tv/liveCheck.php?live_id=';
$arg = $channelName;
$session = curl_init($request.$arg);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);

if (preg_match("/true/",$response, $result)) {
return (1); //online
} else {
return (0); //offline
}
}

for regame.TV --

//regame status check
function regameTVcheck ($channelName) {
$url = '
http://www.regame.tv/liveview_xml_multiple.php?stream_ids=';
$arg = $channelName;
$xml = simplexml_load_file($url.$arg);
$status=$xml->stream->online;
if (strcmp($status,'true')==0) {
return (1); //online
} else {
return (0); //offline
}
}

pretty straight forward, functions return 1 if the stream is online, and 0 if not. and should be easily transferable to other languages.

Syndication : Digg It  Add to Technorati Favorites  Stumble It  Worth Reading 

so you watch starcraft instead of posting in the blog ?:(

i admit i have been quite inactive in this blog due to the high demand of time of my current job. but ill try to post more :)

happy new year !

Post a Comment

About

    My Name is Barry Shteiman, im a devoted tech junkie, and this is my blog.
    E: barry.shteiman -at- gmail.com
    Twitter : bshteiman

Tags & Categories

Mailing List & RSS

Stay Updated  
Add to Technorati Favorites