From 48ed99c38076f0dbee3ea6ff16bd780e9750a941 Mon Sep 17 00:00:00 2001 From: Patrick Speiser Date: Sun, 7 Oct 2012 05:46:41 +0200 Subject: [PATCH 1/3] Artwork requests would always use the working directory as the location of the image insted of using the configured CACHE_DIR --- headphones/webserve.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index 118416d6..4097dab3 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -30,6 +30,8 @@ from headphones.helpers import checked, radio,today import lib.simplejson as simplejson +import sys + def serve_template(templatename, **kwargs): @@ -926,14 +928,18 @@ class Artwork(object): if not relpath: relpath = "data/interfaces/default/images/no-cover-art.png" + basedir = os.path.dirname(sys.argv[0]) + path = os.path.join(basedir,relpath) cherrypy.response.headers['Content-type'] = 'image/png' cherrypy.response.headers['Cache-Control'] = 'no-cache' else: + relpath = relpath.replace('cache/','',1) + path = os.path.join(headphones.CACHE_DIR,relpath) 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) + path = os.path.normpath(path) f = open(path,'rb') return f.read() default.exposed = True @@ -955,14 +961,18 @@ class Artwork(object): if not relpath: relpath = "data/interfaces/default/images/no-cover-artist.png" + basedir = os.path.dirname(sys.argv[0]) + path = os.path.join(basedir,relpath) cherrypy.response.headers['Content-type'] = 'image/png' cherrypy.response.headers['Cache-Control'] = 'no-cache' else: + relpath = relpath.replace('cache/','',1) + path = os.path.join(headphones.CACHE_DIR,relpath) 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) + path = os.path.normpath(path) f = open(path,'rb') return f.read() default.exposed = True From 5695c8196ae41ef4bbecf1971ae2449931b734a0 Mon Sep 17 00:00:00 2001 From: Patrick Speiser Date: Sun, 7 Oct 2012 05:51:55 +0200 Subject: [PATCH 2/3] Calling _findfilesstartingwith with a non-existing folder would raise an exception, will return an empty list now --- headphones/cache.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/headphones/cache.py b/headphones/cache.py index 9592e8f3..78cd0c47 100644 --- a/headphones/cache.py +++ b/headphones/cache.py @@ -65,7 +65,8 @@ class Cache(object): def _findfilesstartingwith(self,pattern,folder): files = [] - for fname in os.listdir(folder): + if os.path.exists(folder): + for fname in os.listdir(folder): if fname.startswith(pattern): files.append(os.path.join(folder,fname)) return files From cda2d5ddf3dd623b3dc0e79990d78d639b63595c Mon Sep 17 00:00:00 2001 From: Patrick Speiser Date: Sun, 7 Oct 2012 06:22:03 +0200 Subject: [PATCH 3/3] Special purpose artists can have multiple ids, 0035056d-72ac-41fa-8ea6-0e27e55f42f7 and 125ec42a-7229-4250-afc5-e057484327fe, added a ban by name in addition to the existing id bans, also removes the artist if its already in the db --- headphones/importer.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/headphones/importer.py b/headphones/importer.py index 404ffe7e..158d703f 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -21,7 +21,7 @@ from lib.beets.mediafile import MediaFile import headphones from headphones import logger, helpers, db, mb, albumart, lastfm -#[anonymous],[data],[no artist],[traditional],[unknown],Various Artists +blacklisted_special_artist_names = ['[anonymous]','[data]','[no artist]','[traditional]','[unknown]','Various Artists'] blacklisted_special_artists = ['f731ccc4-e22a-43af-a747-64213329e088','33cf029c-63b0-41a0-9855-be2a3665fb3b',\ '314e1c25-dde7-4e4d-b2f4-0a7b9f7c56dc','eec63d3c-3b81-4ad4-b1e4-7c147d4d2b61',\ '9be7f096-97ec-4615-8957-8d40b5dcbc41','125ec42a-7229-4250-afc5-e057484327fe',\ @@ -138,6 +138,14 @@ def addArtisttoDB(artistid, extrasonly=False): artist = mb.getArtist(artistid, extrasonly) + if artist and artist.get('artist_name') in blacklisted_special_artist_names: + logger.warn('Cannot import blocked special purpose artist: %s' % artist.get('artist_name')) + myDB.action('DELETE from artists WHERE ArtistID=?', [artistid]) + #in case it's already in the db + myDB.action('DELETE from albums WHERE ArtistID=?', [artistid]) + myDB.action('DELETE from tracks WHERE ArtistID=?', [artistid]) + return + if not artist: logger.warn("Error fetching artist info. ID: " + artistid) if dbartist is None: