Dan’s View

2010/03/01

ShoutCast Stream Meta script

Filed under: Geek,Programming — Tags: , — dan @ 10:00

Using the following python script you can pull the meta info from a playing stream. The headers variable will contain the Radio Name and other things, and the meta’s returned will include the currently playing track.

source

Example output:
dan@x ~/ $ ./get_icy_name.py
{'headers': {'icy-genre': 'Techno Drum and Bass', 'icy-notice2': 'SHOUTcast Distributed Network Audio Server/Linux v1.9.93atdn
', 'icy-pub': '1', 'icy-br': '128', 'icy-name': 'Bassdrive - Worldwide Drum and Bass Radio', 'content-type': 'audio/mpeg', 'icy-metaint': '24576'}, 'metas': {'StreamTitle': 'G-Shock Radio Feb 25th 2010 - hosted by Kasio', 'StreamUrl': ''}}
dan@x ~/ $

2008/10/25

Life the universe and 99% Javascript Apps

Filed under: Programming — Tags: — dan @ 13:59

So I have been tinkering with creating a web frontend for a simple tool for use at work. On thursday I knocked up the app in vanilla, MySQL+PHP+bTemplate and a few jokes were made about it not being very pritty, etc. So I have spent a few hours getting the logic sorted out for an application that has virtually no HTML. The browser load the HTML, and associated scripts and then all the rest runs in JavaScript. Dynamically generate the login form, handle cookies, etc… Although it is a very simple app it does work very quickly. Dynamically creating DOM/HTML nodes seems so far to be quick enough. Who knows maybe in the future I don’t touch HTML at all!

An example of the HTML is:

<html>
<head>
<script type=”text/javascript” src=”external/JSONError.js”></script>
<script type=”text/javascript” src=”external/JSON.js”></script>
<script type=”text/javascript” src=”js/lib.js”></script>
<script type=”text/javascript” src=”js/handlers.js”></script>
<script type=”text/javascript” src=”js/gui.js”></script>
<script type= “text/javascript”>
/*<![CDATA[*/
var jsonURL = "json.php";
/*]]>*/
</script>
</head>
<body>
<script type=”text/javascript” src=”js/init.js”></script>
</body>
</html>

And an example of init.js:

var body = document.body;

var cookies = new Cookies();
var divs = {};

var login = true;
var t = cookies.read(“LoggedIn”);
if(t != null && t == “1″) {
if(isLoggedIn()) {
login = false;
}
}

if(login == true) {
guiLoginBuild();
} else {
guiMainBuild();
}

Once it’s a bit more completed I will post the app up for people to enjoy.

Powered by WordPress