diff --git a/data/interfaces/default/index.html b/data/interfaces/default/index.html index 53a78439..f63a2cad 100644 --- a/data/interfaces/default/index.html +++ b/data/interfaces/default/index.html @@ -46,7 +46,7 @@ "aTargets": [ 0 ], "mData":"ArtistID", "mRender": function ( data, type, full ) { - return '
'; + return '
'; } }, {"aTargets":[1],"mDataProp":"ArtistSortName"}, @@ -73,7 +73,6 @@ }, "fnInitComplete": function(oSettings, json) { - getArtistArt(); }}); diff --git a/headphones/webserve.py b/headphones/webserve.py index a2f0fa89..5926dfe9 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -872,3 +872,37 @@ class WebInterface(object): return simplejson.dumps(image_dict) getImageLinks.exposed = True + +class Thumbs(object): + def index(self): + return "Here be thumbs" + index.exposed = True + def default(self,ArtistOrAlbum="",ID=None): + from headphones import cache + ArtistID = None + AlbumID = None + if ArtistOrAlbum == "artist": + ArtistID = ID + elif ArtistOrAlbum == "album": + AlbumID = None + + relpath = cache.getThumb(ArtistID,AlbumID) + + if not relpath: + if ArtistOrAlbum == "artist": + relpath = "data/interfaces/default/images/no-cover-artist.png" + elif ArtistOrAlbum == "album": + relpath = "data/interfaces/default/images/no-cover-art.png" + cherrypy.response.headers['Content-type'] = 'image/png' + cherrypy.response.headers['Cache-Control'] = 'no-cache' + else: + fileext = os.path.splitext(relpath)[1][1::] + cherrypy.response.headers['Content-type'] = 'image/' + fileext + cherrypy.response.headers['Cache-Control'] = 'max-age=31556926' + + path = os.path.abspath(relpath) + f = open(path,'rb') + return f.read() + default.exposed = True + +WebInterface.thumbs = Thumbs()