First post! After actively using the Internet since 1994, I've finally found some motivation to open one of these blog thingys. Naturally, that motivation is nerdy in nature. My intention is to post those shell scripts (and other computer-y hacks) that I've created in that time. Here's the first one. It's timestamp is dated 2007-11-08. I use it to play the BBC7 Live Stream without having to fire up a web browser to their difficult-to-navigate website. It also avoids having to install RealPlayer because it uses mplayer. It also requires the 'LWP' Perl Module (for GET), but that could be replaced easily enough. Finally, it assumes the BBC won't change the URL for the stream.
BEGIN bbc7live
#!/bin/bash
while true; do
mplayer -cache-min 5 "`GET http://www.bbc.co.uk/bbc7/realplayer/ds atg2.ram`";
done
END bbc7live
The infinite loop is necessary because mplayer doesn't reconnect when the stream breaks (realplayer does). The -cache-min tells mplayer how much to cache (in seconds, I believe). I chose 5 seconds over whatever the longer default was because the time it was taking to fill the cache would be lost when the stream breaks: at each break mplayer would drop the cache contents and reconnect (thanks to the while loop). But it wouldn't reconnect where it left off (because it's a real-time stream) but rather at the current time, which thanks to the previous large cache is several 10s of seconds later than where it broke off.
BEGIN bbc7live
#!/bin/bash
while true; do
mplayer -cache-min 5 "`GET http://www.bbc.co.uk/bbc7/realplayer/ds
done
END bbc7live
The infinite loop is necessary because mplayer doesn't reconnect when the stream breaks (realplayer does). The -cache-min tells mplayer how much to cache (in seconds, I believe). I chose 5 seconds over whatever the longer default was because the time it was taking to fill the cache would be lost when the stream breaks: at each break mplayer would drop the cache contents and reconnect (thanks to the while loop). But it wouldn't reconnect where it left off (because it's a real-time stream) but rather at the current time, which thanks to the previous large cache is several 10s of seconds later than where it broke off.
Leave a comment
