bgneal@4: A TeamSpeak 3 viewer with Python & Javascript bgneal@4: ############################################# bgneal@4: bgneal@4: :date: 2012-01-20 19:15 bgneal@4: :tags: Python, Javascript, TeamSpeak bgneal@4: :slug: a-teamspeak-3-viewer-with-python-javascript bgneal@4: :author: Brian Neal bgneal@7: :summary: Here's how I cobbled together a TeamSpeak 3 viewer in Python & Javascript. And there might even be some PHP involved too... bgneal@4: bgneal@4: The Problem bgneal@4: =========== bgneal@4: bgneal@4: My gaming clan started using `TeamSpeak 3`_ (TS3) for voice communications, so bgneal@4: it wasn't long before we wanted to see who was on the TS3 server from the clan's bgneal@4: server status page. Long ago, before I met Python, I had built the clan a server bgneal@4: status page in PHP. This consisted of cobbling together various home-made and bgneal@4: 3rd party PHP scripts for querying game servers (Call of Duty, Battlefield) and bgneal@4: voice servers (TeamSpeak 2 and Mumble). But TeamSpeak 3 was a new one for us, bgneal@4: and I didn't have anything to query that. My interests in PHP are long behind bgneal@4: me, but we needed to add a TS3 viewer to the PHP page. The gaming clan's web bgneal@4: hosting is pretty vanilla; in other words PHP is the first class citizen. If I bgneal@4: really wanted to host a Python app I probably could have resorted to Fast CGI or bgneal@4: something. But I had no experience in that and no desire to go that way. bgneal@4: bgneal@4: I briefly thought about finding a 3rd party PHP library to query a TS3 server. bgneal@4: The libraries are out there, but they are as you might expect: overly bgneal@4: complicated and/or pretty amateurish (no public source code repository). I even bgneal@4: considered writing my own PHP code to do the job, so I started looking for any bgneal@4: documentation on the TS3 server query protocol. Luckily, there is a `TS3 bgneal@4: query protocol document`_, and it is fairly decent. bgneal@4: bgneal@4: But, I just could not bring myself to write PHP again. On top of this, the bgneal@4: gaming clan's shared hosting blocks non-standard ports. If I did have a PHP bgneal@4: solution, the outgoing query to the TS3 server would have been blocked by the bgneal@4: host's firewall. It is a hassle to contact their technical support and try to bgneal@4: find a person who knows what a port is and get it unblocked (we've had to do bgneal@4: this over and over as each game comes out). Thus it ultimately boiled down to me bgneal@4: wanting to do this in Python. For me, life is too short to write PHP scripts. bgneal@4: bgneal@4: I started thinking about writing a query application in Python using my bgneal@4: dedicated server that I use to host a few Django_ powered websites. At first I bgneal@4: thought I'd generate the server status HTML on my server and display it in an bgneal@4: ``