1 diff --git a/Sipie/Factory.py b/Sipie/Factory.py
2 index 667feb2..9e7cb1c 100644
5 @@ -203,6 +203,7 @@ class Factory:
6 #self.__dbfd("MediaPlayer.html",data) #DEBUG
7 if data.find('bg-now-playing-mac-large') > 0: #already authed
9 + data = self.sanitize(data)
10 soup = BeautifulSoup(data)
12 self.token = soup.find('input', {'name': 'token'})['value']
13 @@ -263,6 +264,9 @@ class Factory:
14 #self.__dbfd("debug-ERROR.html",data) #DEBUG
15 print "Unsuccessful Login. Please check username and password." #DEBUG 0
17 + elif data.find('Too Many Login Attempts') <> -1: #IF FOUND
18 + print "Too Many Login Attempts, try again later."
22 def tryGetStreams(self):
23 @@ -295,6 +299,7 @@ class Factory:
25 #self.__dbfd("miniplayer.html",data) #DEBUG XXX
26 #data = open('small_playing_100.html').read() # DEBUG
27 + data = self.sanitize(data)
28 soup = BeautifulSoup(data)
29 for catstrm in soup.findAll('option'):
30 if catstrm['value'].find('|') <> -1: # IF FOUND
31 @@ -341,6 +346,7 @@ class Factory:
33 #self.printcookies() #DEBUG
34 #self.__dbfd ("streamselect.html",data) #DEBUG
35 + data = self.sanitize(data)
36 soup = BeautifulSoup(data)
38 asxURL = soup.find('param', {'name': 'FileName'})['value']
39 @@ -470,3 +476,17 @@ class Factory:
41 nowplaying['new'] = False
44 + def sanitize(self, data):
45 + """ Sanitizes Data against specific errors in the Sirus HTML that
46 + Beautiful soup can not handle."""
48 + data = re.sub(r'style=["\']?(\{.*\})["\']?', r'style="\1" ', data)
49 + data = re.sub(r'width=["\']?(\d+)["\']?', r'width="\1"', data)
50 + #data = re.sub(r'width=["\']?(\d+i)[^\d]*%["\']?', r'width="\1%"', data)
51 + data = re.sub(r'width="100"%"', r'width="100%"', data)
52 + data = re.sub(r'onclick=["\']?([^\s<>]*)["\']?', r'onclick=""', data)
57 diff --git a/Sipie/cliPlayer.py b/Sipie/cliPlayer.py
58 index 2cb8ba6..49187a4 100644
59 --- a/Sipie/cliPlayer.py
60 +++ b/Sipie/cliPlayer.py
61 @@ -38,6 +38,8 @@ def cliPlayer():
64 stream = raw_input("Enter stream: ")
65 + stream = stream.strip()
66 + #print "|" + stream + "|" #Debug
67 except (EOFError, KeyboardInterrupt):
68 print "Thanks for playing"