#!/usr/bin/env python # # usage: ./telos.py # # # To use on a linux system # Make sure you have python-shout, libshout3, python-dev # # Run python setup.py install on the python-shout package # # Modify the settings below to fit your server # Then this should work. # There might be some fat to be trimmed out. # # I used this script to connect to my Telos Audioactive unit # (A great unit!) and then connect to icecast. I ran it in a # loop so that when my internet provider cut my service out # to do CMTS upgrades at 2AM I wouldn't need to hit reconnect # on the Telos unit. There is probably a better way to do this. # But it worked for 2 years solid. # # - Ethan O'Toole # # # To do: # Auto loop # Logging import shout import sys import string import time import socket s = shout.Shout() print "Using libshout version %s" % shout.version() # # Telos AudioActive port and IP address # Set unit IP address and RawTCP mode # telosport = 8000 telosip = '192.168.2.230' # # IceCast Server Settings # This will connect as a source # # Remote server IP, port, format, password and mountpoint s.host = '8.8.4.4' s.port = 8000 s.format = 'mp3' s.password = 'yourpass' s.mount = "/telos" # s.user = 'source' # s.format = 'vorbis' | 'mp3' # s.protocol = 'http' | 'xaudiocast' | 'icy' # s.name = '' # s.genre = '' # s.url = '' # s.public = 0 | 1 # s.audio_info = { 'key': 'val', ... } # (keys are shout.SHOUT_AI_BITRATE, shout.SHOUT_AI_SAMPLERATE, # shout.SHOUT_AI_CHANNELS, shout.SHOUT_AI_QUALITY) s.open() total = 0 st = time.time() print "opening telos unit at %s : %d" % (telosip, telosport) sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) sock.connect( (telosip, telosport) ) nbuf = sock.recv(4096) while 1: buf = nbuf nbuf = sock.recv(4096) total = total + len(buf) if len(buf) == 0: break s.send(buf) s.sync() f.close() et = time.time() br = total*0.008/(et-st) print "Sent %d bytes in %d seconds (%f kbps)" % (total, et-st, br) print s.close()