Tuesday, January 17, 2012

SC2ReplayHandler – contribution to the SC2 community

For those who know me, I grew up playing computer games and kind of never stopped. about 1.5yrs ago one of my favorite games came out which was Starcraft 2, and has become the only game I play.

So why do I blog about it ? I believe that everyone have their own skills and abilities to make things they like into bigger things, mine is coding I guess..

I created a tool that automatically renames ingame replay files based on parsed metadata of the replay files, and posted it on the biggest community site – TeamLiquid.net

I present to you : SC2ReplayHandler ( soon to be open source )

just a small tool that hooks to Windows’s event dispatcher for identifying when new replay files arrive, then parses them and renames them based on patterns defined by the user.

hope you like.

Sunday, January 01, 2012

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.


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