tdhz77 Posted January 13, 2009 Share Posted January 13, 2009 I want to try and script a small program that simply $GET's my broadcast video only if my stream is up. http://techblog.justin.tv/2007/11/jtv-search-api.html For more information. I'm so lost. Any documentation, ideas or pointers would be great. I would like to do this thing on my own, but any examples on how to go about an HTTP request would be nice. Link to comment https://forums.phpfreaks.com/topic/140638-justintv-api/ Share on other sites More sharing options...
redarrow Posted January 13, 2009 Share Posted January 13, 2009 would file_get_contents() work i wonder example try it. <?php $stream_url='what_ever'; if(file_get_contents("$stream_url")){ echo working; }else{ echo "Not working"; } ?> Link to comment https://forums.phpfreaks.com/topic/140638-justintv-api/#findComment-735996 Share on other sites More sharing options...
redarrow Posted January 13, 2009 Share Posted January 13, 2009 Sorry but there no way to see if the tv program is live, The only way is to cheek to see if the url exists. this is what the current database let you see what going on. But the database does not tell you if the tv program is currently live. The only way you can rely cheek this, is to alter the database and use a cron, and update a database field each time a user press the watch button. But that wont even help rely, Only tell you at that time, The tv stream was working. Your have to rely on the url exists i think sorry. But that does not tell you the stream is live only the url is there. Even if you ping the streaming url your still only cheeking the url exists. [{"type": "video_archive", "broadcaster": "ggjeffy", "id": 28144, "title": "Cat doing cat stuffs", "start_time": 1186542932, "duration": 180}, {"type": "video_archive", "broadcaster": "nekomimi_lisa", "id": 39175, "title": "Nekomimi Cat Doing The Cat Dance", "start_time": 1191805139, "duration": 108}, {"type": "video_archive", "broadcaster": "nekomimi_lisa2", "id": 9832, "title": "CAT FIGHT!!", "start_time": 1185954224, "duration": 180}, {"type": "video_archive", "broadcaster": "nekomimi_lisa2", "id": 9818, "title": "cat trying to hump blanket", "start_time": 1185939617, "duration": 180}, {"type": "video_archive", "broadcaster": "ashleymarie", "id": 36553, "title": "Sister Cat Fight Part 1", "start_time": 1190060150, "duration": 80}, {"type": "video_archive", "broadcaster": "ibrbigottopee", "id": 34698, "title": "I thought i saw a putty cat", "start_time": 1189149636, "duration": 66}, {"type": "video_archive", "broadcaster": "ashleymarie", "id": 36555, "title": "Sister Cat Fight Part 2", "start_time": 1190060349, "duration": 66}, {"type": "video_archive", "broadcaster": "audratv", "id": 39679, "title": "Attack of the Fuzzy Cat Part 2", "start_time": 1191985459, "duration": 180}, {"type": "video_archive", "broadcaster": "audratv", "id": 39656, "title": "Cat Attack", "start_time": 1191980666, "duration": 180}, {"type": "video_archive", "broadcaster": "xk3ll3yx", "id": 40879, "title": "Cat on Head!", "start_time": 1192431728, "duration": 71}] Link to comment https://forums.phpfreaks.com/topic/140638-justintv-api/#findComment-736005 Share on other sites More sharing options...
Prismatic Posted January 13, 2009 Share Posted January 13, 2009 Sorry but there no way to see if the tv program is live, The only way is to cheek to see if the url exists. this is what the current database let you see what going on. But the database does not tell you if the tv program is currently live. The only way you can rely cheek this, is to alter the database and use a cron, and update a database field each time a user press the watch button. But that wont even help rely, Only tell you at that time, The tv stream was working. Your have to rely on the url exists i think sorry. But that does not tell you the stream is live only the url is there. Even if you ping the streaming url your still only cheeking the url exists. [{"type": "video_archive", "broadcaster": "ggjeffy", "id": 28144, "title": "Cat doing cat stuffs", "start_time": 1186542932, "duration": 180}, {"type": "video_archive", "broadcaster": "nekomimi_lisa", "id": 39175, "title": "Nekomimi Cat Doing The Cat Dance", "start_time": 1191805139, "duration": 108}, {"type": "video_archive", "broadcaster": "nekomimi_lisa2", "id": 9832, "title": "CAT FIGHT!!", "start_time": 1185954224, "duration": 180}, {"type": "video_archive", "broadcaster": "nekomimi_lisa2", "id": 9818, "title": "cat trying to hump blanket", "start_time": 1185939617, "duration": 180}, {"type": "video_archive", "broadcaster": "ashleymarie", "id": 36553, "title": "Sister Cat Fight Part 1", "start_time": 1190060150, "duration": 80}, {"type": "video_archive", "broadcaster": "ibrbigottopee", "id": 34698, "title": "I thought i saw a putty cat", "start_time": 1189149636, "duration": 66}, {"type": "video_archive", "broadcaster": "ashleymarie", "id": 36555, "title": "Sister Cat Fight Part 2", "start_time": 1190060349, "duration": 66}, {"type": "video_archive", "broadcaster": "audratv", "id": 39679, "title": "Attack of the Fuzzy Cat Part 2", "start_time": 1191985459, "duration": 180}, {"type": "video_archive", "broadcaster": "audratv", "id": 39656, "title": "Cat Attack", "start_time": 1191980666, "duration": 180}, {"type": "video_archive", "broadcaster": "xk3ll3yx", "id": 40879, "title": "Cat on Head!", "start_time": 1192431728, "duration": 71}] There is a way. I should have a solution soon. Link to comment https://forums.phpfreaks.com/topic/140638-justintv-api/#findComment-736007 Share on other sites More sharing options...
redarrow Posted January 13, 2009 Share Posted January 13, 2009 How theo, i got this one but how you going to do this intresting. would socket help? <?php // set some variables $host = "192.168.1.99"; $port = 1234; // don't timeout! set_time_limit(0); // create socket $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); // bind socket to port $result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n"); // start listening for connections $result = socket_listen($socket, 3) or die("Could not set up socket listener\n"); // accept incoming connections // spawn another socket to handle communication $spawn = socket_accept($socket) or die("Could not accept incoming connection\n"); // read client input $input = socket_read($spawn, 1024) or die("Could not read input\n"); // clean up input string $input = trim($input); // reverse client input and send back $output = strrev($input) . "\n"; socket_write($spawn, $output, strlen ($output)) or die("Could not write output\n"); // close sockets socket_close($spawn); socket_close($socket); ?> Link to comment https://forums.phpfreaks.com/topic/140638-justintv-api/#findComment-736012 Share on other sites More sharing options...
Prismatic Posted January 13, 2009 Share Posted January 13, 2009 My idea is to use some tools to extract a frame from the stream it's self. Then compare that frame with the default non-streaming image. If the frame is different the stream is most likely active, if it's not the stream is most likely not active. Link to comment https://forums.phpfreaks.com/topic/140638-justintv-api/#findComment-736038 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.