I am trying to create a web radio server to stream 3 sources at once. I am using python to create a source client for icecast2 using the python-shout library. I am not too familiar with the language (python). however, i got a sample program which does what i need to and more and i have tweaked it for my need. However, I can only create two streams, and after that, i get the error message shown below. I don't know what i'm doing wrong so i hope you guys can help me figure that out.
hostname ="localhost"
port= 8000
password = "password"import shout
import sys
import threading
from glob import glob
from random import shuffle,choiceclass RunStream (threading.Thread):def __init__ (self, channel_mount, music_directory, station_url, genre,name, description, bitrate="128", samplerate="44100", channels="5",music_format="mp3", ogv=0):#connection to icecastglobal hostname,port,passwordself.song_conter= 0self.s = shout.Shout()self.s.audio_info = {shout.SHOUT_AI_BITRATE:bitrate, shout.SHOUT_AI_SAMPLERATE:samplerate, shout.SHOUT_AI_CHANNELS:channels}self.s.name = nameself.s.url = station_urlself.s.mount = channel_mountself.s.port = portself.ogv = ogvself.s.password = passwordself.s.genre = genreself.music_directory = music_directoryself.s.description = descriptionself.s.host = hostnameself.s.format = music_format #using mp3 but it can also be ogg vorbisprint self.s.open()threading.Thread.__init__ (self)#checking directories for files to streamdef scan_directories(self):self.files_array = glob(self.music_directory+"/*.[mM][Pp]3") + glob(self.music_directory+"/*/*.[mM][Pp]3") + glob(self.music_directory+"/*/*/*.[mM][Pp]3") #checks the specified directory down to the third depthprint str(len(self.files_array))+" files" #display number of matching files foundshuffle(self.files_array) # randomize playlistdef run (self):while 1: #infinityself.scan_directories() # rescan dir, maybe in time you add some new songsself.song_counter = 0 for e in self.files_array:self.write_future()self.sendfile(e)self.song_counter = self.song_counter + 1def format_songname(self,song): # format song name - on filename (strip "mp3", change _ to " ". Formatting name of song for writing into a text fileresult = song.split("/")[-1].split(".")result = ".".join(result[:len(result)-1]).replace("_"," ").replace("-"," - ")return resultdef write_future(self): #write playlistfilename = self.s.mount.replace("/","")+"-current.txt"fa = open(filename,"w")aid = self.song_counterpos = 7 # CHANGE if you want more songs in future playlistfor s in self.files_array[aid:]:fa.write(self.format_songname(s)+"\n")pos = pos - 1if (pos==0):breakif (pos>0):for s in self.files_array[:pos+1]:fa.write(self.format_songname(s)+"\n")fa.close() def sendfile(self,fa):print "opening file %s" % faf = open(fa)self.s.set_metadata({'song': self.format_songname(fa)})nbuf = f.read(4096)while 1:buf = nbufnbuf = f.read(4096)if len(buf) == 0:breakself.s.send(buf)self.s.sync()f.close()#running the first stream
RunStream(channel_mount = "/stream", music_directory = "/home/CUWebRadio1/music_one", station_url = "http://webradio.com", genre = "new",name = "Web Radio Channel2", description = "bla bla bla").start()#running the second stream
RunStream(channel_mount = "/stream_2", music_directory = "/home/CUWebRadio1/music_twos", station_url = "http://webradio.com", genre = "music",name = "Web Radio Music", description = "bla bla bla").start()#running the Third Stream
RunStream(channel_mount = "/stream_3", music_directory = "/home/CUWebRadio1/music_three", station_url = "http://webradio.com", genre = "Music",name = "CU Web Radio Music3", description = "bla bla bla").start()
the Error message i get
Traceback (most recent call last):File "new_threads.py", line 96, in <module>RunStream(channel_mount = "/stream_3", music_directory = "/home/CUWebRadio1/music_three", station_url = "http://webradio.com", genre = Music",name = "CU Web Radio Music3", description = "bla bla bla").start()File "new_threads.py", line 37, in __init__print self.s.open()
shout.ShoutException: Login failed
Any help would be greatly appreciated.