Web server album art
The web server can now serve up album art from the artwork cache.
This commit is contained in:
parent
849f071d58
commit
ac8c4abd9e
|
@ -3,10 +3,12 @@
|
||||||
import ocarina
|
import ocarina
|
||||||
import imp
|
import imp
|
||||||
from libsaria import threads
|
from libsaria import threads
|
||||||
|
from libsaria import lastfm
|
||||||
|
|
||||||
path = ocarina.libsaria.path
|
path = ocarina.libsaria.path
|
||||||
exists = path.exists
|
exists = path.exists
|
||||||
join = path.join
|
join = path.join
|
||||||
|
sep = path.sep
|
||||||
basename = path.basename
|
basename = path.basename
|
||||||
|
|
||||||
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
||||||
|
@ -15,7 +17,8 @@ html = join(path.cwd(), "html")
|
||||||
server = None
|
server = None
|
||||||
types = {".html":"text/html", ".js":"text/javascript",
|
types = {".html":"text/html", ".js":"text/javascript",
|
||||||
".ico":"image/vnd.microsoft.icon",
|
".ico":"image/vnd.microsoft.icon",
|
||||||
".py":"text/html"}
|
".py":"text/html",
|
||||||
|
".jpg":"image/jpeg"}
|
||||||
|
|
||||||
class HTTPRequest(BaseHTTPRequestHandler):
|
class HTTPRequest(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
|
@ -24,8 +27,18 @@ class HTTPRequest(BaseHTTPRequestHandler):
|
||||||
if self.path == "" or self.path == "/":
|
if self.path == "" or self.path == "/":
|
||||||
self.path = "/index.html"
|
self.path = "/index.html"
|
||||||
try:
|
try:
|
||||||
fpath = html + self.path
|
split = self.path.strip(sep).split(sep)
|
||||||
print fpath
|
#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):
|
if not exists(fpath):
|
||||||
raise IOError
|
raise IOError
|
||||||
base, ext = path.splitext(fpath)
|
base, ext = path.splitext(fpath)
|
||||||
|
|
Loading…
Reference in New Issue