diff --git a/plugins/web_server.py b/plugins/web_server.py index cfb17805..01f083e2 100644 --- a/plugins/web_server.py +++ b/plugins/web_server.py @@ -3,10 +3,12 @@ import ocarina import imp from libsaria import threads +from libsaria import lastfm path = ocarina.libsaria.path exists = path.exists join = path.join +sep = path.sep basename = path.basename from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer @@ -15,7 +17,8 @@ html = join(path.cwd(), "html") server = None types = {".html":"text/html", ".js":"text/javascript", ".ico":"image/vnd.microsoft.icon", - ".py":"text/html"} + ".py":"text/html", + ".jpg":"image/jpeg"} class HTTPRequest(BaseHTTPRequestHandler): @@ -24,8 +27,18 @@ class HTTPRequest(BaseHTTPRequestHandler): if self.path == "" or self.path == "/": self.path = "/index.html" try: - fpath = html + self.path - print fpath + split = self.path.strip(sep).split(sep) + #print split + if split[0] == "artwork": + split = split[1].split(".") + artist, album = split[0], split[1] + artist = artist.replace("%20", " ") + album = album.replace("%20", " ") + # print "%s, %s" % (artist, album) + fpath = lastfm.get_artwork_tags(artist, album) + else: + fpath = html + self.path + #print fpath if not exists(fpath): raise IOError base, ext = path.splitext(fpath)