Hi Romain, wow, that was one quick response.
Romain wrote: > Well, I should prepare a new package.. That would be great. > If you have time to propose a patch, I would be very happy to review and > upload it.. Please find attached a proposal for a patch. I'm not a pro at this, so feedback will be much appreciated if anything went wrong. I'd be happy to do some testing of a fixed package -- just let me know what you need me to do. Thanks, Daniel
diff -rc lastfmproxy-1.3b-origdeb/lastfm.py lastfmproxy-1.3b/lastfm.py *** lastfmproxy-1.3b-origdeb/lastfm.py 2007-12-13 19:07:04.000000000 +0100 --- lastfmproxy-1.3b/lastfm.py 2010-12-19 18:04:42.494144984 +0100 *************** *** 8,15 **** class lastfm: def __init__(self): ! self.version = "1.3.1.1" ! self.platform = "linux" self.host = "ws.audioscrobbler.com" self.port = 80 self.info = None --- 8,19 ---- class lastfm: def __init__(self): ! self.version = "1.5.4.24567" ! self.platform = "win32" ! self.platformversion = "Windows%20XP" ! self.player = "LastFMProxy" ! # self.api_key = "9d1bbaef3b443eb97973d44181d04e4b" ! self.api_key = "d50ed5584be64a1564a5d1a12e3fef7f" self.host = "ws.audioscrobbler.com" self.port = 80 self.info = None *************** *** 35,41 **** def connect(self, username, password): s = httpclient.httpclient(self.host, self.port) ! s.req("/radio/handshake.php?version=" + self.version + "&platform=" + self.platform + "&username=" + username + "&passwordmd5=" + password + "&language=en&player=lastfmproxy") self.info = self.parselines(s.response) --- 39,45 ---- def connect(self, username, password): s = httpclient.httpclient(self.host, self.port) ! s.req("/radio/handshake.php?version=" + self.version + "&platform=" + self.platform + "&username=" + username + "&passwordmd5=" + password + "&language=en&api_key=" + self.api_key + "&player=" + self.player) self.info = self.parselines(s.response) *************** *** 52,57 **** --- 56,62 ---- # debug if self.debug: + sys.stderr.write("Saving playlist...\n") if len(self.playlist.data.tracks): f = open("playlist.xspf", "w") f.write(s.response) diff -rc lastfmproxy-1.3b-origdeb/main.py lastfmproxy-1.3b/main.py *** lastfmproxy-1.3b-origdeb/main.py 2007-12-20 09:31:33.000000000 +0100 --- lastfmproxy-1.3b/main.py 2010-12-19 18:04:42.494144984 +0100 *************** *** 29,34 **** --- 29,35 ---- self.basedir = "." self.quit = False self.skip = 0 + self.redirect = 0 self.stop = False self.version = "1.3b" self.streaming = 0 *************** *** 293,302 **** cont = u"np_streaming = " + str(self.streaming) + ";\n" ! if self.streaming: ! try: title = self.lastfm.playlist.data.title except: title = "Wait..." --- 294,304 ---- cont = u"np_streaming = " + str(self.streaming) + ";\n" ! if self.streaming == 1: ! try: title = self.lastfm.playlist.data.title + title = "hello"; except: title = "Wait..." *************** *** 383,389 **** cont = cont + "<link rel=\"icon\" href=\"/data/favicon.ico\" />\n" cont = cont + "<link rel=\"icon\" type=\"image/png\" href=\"/data/nice_favicon.png\" />\n" cont = cont + "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"data/" + config.theme + ".css\" />\n" ! cont = cont + "<script>\n" cont = cont + "var host = 'http://" + http["Host"] + "';\n" f = open(os.path.join(self.basedir, "data", "main.js"), "r") cont = cont + f.read() --- 385,391 ---- cont = cont + "<link rel=\"icon\" href=\"/data/favicon.ico\" />\n" cont = cont + "<link rel=\"icon\" type=\"image/png\" href=\"/data/nice_favicon.png\" />\n" cont = cont + "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"data/" + config.theme + ".css\" />\n" ! cont = cont + "<script type=\"text/javascript\">\n" cont = cont + "var host = 'http://" + http["Host"] + "';\n" f = open(os.path.join(self.basedir, "data", "main.js"), "r") cont = cont + f.read() *************** *** 435,441 **** cont = cont + gui cont = cont + "</form>" ! cont = cont + "<script>\ntick();\n</script>\n" cont = cont + "</body></html>\n" try: --- 437,443 ---- cont = cont + gui cont = cont + "</form>" ! cont = cont + "<script type=\"text/javascript\">\ntick();\n</script>\n" cont = cont + "</body></html>\n" try: *************** *** 572,623 **** self.skip = 0 track = playlist.data.tracks[playlist.pos] - url = track["location"] - url = "%s" % url - url = string.split(url, "/", 3) ! host = string.split(url[2], ":") ! if len(host) != 2: ! host = [ host[0], 80 ] ! else: ! host[1] = int(host[1]) ! if self.lastfm.debug: ! sys.stderr.write("GET http://" + host[0] + ":" + str(host[1]) + "/" + url[3] + " HTTP/1.0\r\n") ! # Connect to actual server and request stream ! streamsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! if config.useproxy: ! streamsock.connect((config.proxyhost, config.proxyport)) ! streamsock.sendall("GET http://" + host[0] + ":" + str(host[1]) + "/" + url[3] + " HTTP/1.0\r\n") ! else: ! streamsock.connect((host[0], host[1])) ! streamsock.sendall("GET /" + url[3] + " HTTP/1.0\r\n") ! streamsock.sendall("Host: " + host[0] + "\r\n") ! streamsock.sendall("\r\n") ! ! # Read HTTP headers ! while True: ! line = "" while True: ! c = streamsock.recv(1) ! line = line + c ! if c == '\n': break ! if self.lastfm.debug: ! sys.stderr.write("<<< " + line) ! # Handle "403 Invalid ticket" more gracefully ! if line[:6] == "HTTP/1": ! tmp = string.split(line, " ", 3) ! if tmp[1] != "200": ! self.skip = 1 break ! if line == "\r\n": ! break if self.skip: continue --- 574,646 ---- self.skip = 0 track = playlist.data.tracks[playlist.pos] url = track["location"] ! self.redirect=1 ! while self.redirect == 1: ! url = "%s" % url ! url = string.split(url, "/", 3) ! host = string.split(url[2], ":") ! if len(host) != 2: ! host = [ host[0], 80 ] ! else: ! host[1] = int(host[1]) ! ! if self.lastfm.debug: ! sys.stderr.write("GET http://" + host[0] + ":" + str(host[1]) + "/" + url[3] + " HTTP/1.0\r\n") ! ! # Connect to actual server and request stream ! streamsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! if config.useproxy: ! streamsock.connect((config.proxyhost, config.proxyport)) ! streamsock.sendall("GET http://" + host[0] + ":" + str(host[1]) + "/" + url[3] + " HTTP/1.0\r\n") ! else: ! streamsock.connect((host[0], host[1])) ! streamsock.sendall("GET /" + url[3] + " HTTP/1.0\r\n") ! streamsock.sendall("Host: " + host[0] + "\r\n") ! streamsock.sendall("\r\n") ! ! # Read HTTP headers while True: ! line = "" ! while True: ! c = streamsock.recv(1) ! line = line + c ! if c == '\n': ! break ! ! if self.lastfm.debug: ! sys.stderr.write("<<< " + line) ! ! if line[:9] == "Location:": ! # get redirected url ! tmp = string.split(line, " ") ! url = tmp[1][0:-2] ! streamsock.close() ! self.redirect = 1 break ! # Handle "403 Invalid ticket" more gracefully ! if line[:12] == "HTTP/1.1 403": ! tmp = string.split(line, " ", 3) ! if tmp[1] != "200": ! self.skip = 1 ! self.redirect = 0 ! break ! # Escape on "200 OK" ! if line[:12] == "HTTP/1.1 200": ! self.skip = 0 ! self.redirect = 0 break ! if line == "\r\n": ! self.redirect = 0 ! break ! ! if self.skip: continue