From 1cf771c15d8d65cb981bb241c033b499b73abc13 Mon Sep 17 00:00:00 2001 From: Remy Date: Wed, 20 Jul 2011 03:05:09 -0700 Subject: [PATCH] Fixed DATETIME typo, improved searching --- headphones/importer.py | 7 +------ headphones/mb.py | 9 +++++++-- headphones/searcher.py | 2 +- headphones/webserve.py | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/headphones/importer.py b/headphones/importer.py index 4ca5a550..8af1bd36 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -19,12 +19,7 @@ def scanMusic(dir=None): for r,d,f in os.walk(dir): for files in f: if any(files.endswith(x) for x in (".mp3", ".flac", ".aac", ".ogg", ".ape")): - #logger.debug('File found: %s' % files) - try: - results.append(os.path.join(r.encode('UTF-8'), files.encode('UTF-8'))) - except UnicodeDecodeError, e: - logger.error('Can not decode file %s. Error: %s' % (str(files), str(e))) - continue + results.append(os.path.join(r, files)) logger.info(u'%i music files found. Reading metadata....' % len(results)) diff --git a/headphones/mb.py b/headphones/mb.py index aec9d48b..dfab9bc3 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -18,11 +18,16 @@ mb_lock = threading.Lock() def findArtist(name, limit=1): with mb_lock: - + artistlist = [] attempt = 0 artistResults = None - term = '"'+name+'"' + + chars = set('!?') + if any((c in chars) for c in name): + term = '"'+name+'"' + else: + term = name while attempt < 5: diff --git a/headphones/searcher.py b/headphones/searcher.py index e0b09999..badf67dd 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -261,4 +261,4 @@ def searchNZB(albumid=None): break myDB.action('UPDATE albums SET status = "Snatched" WHERE AlbumID=?', [albums[2]]) - myDB.action('INSERT INTO snatched VALUES( ?, ?, ?, ?, DATEIME("NOW", "localtime"), ?)', [albums[2], bestqual[0], bestqual[1], bestqual[2], "Snatched"]) \ No newline at end of file + myDB.action('INSERT INTO snatched VALUES( ?, ?, ?, ?, DATETIME("NOW", "localtime"), ?)', [albums[2], bestqual[0], bestqual[1], bestqual[2], "Snatched"]) \ No newline at end of file diff --git a/headphones/webserve.py b/headphones/webserve.py index 28454f0b..134824da 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -198,7 +198,7 @@ class WebInterface(object): raise cherrypy.HTTPRedirect("home") else: artistResults = mb.findArtist(name, limit=10) - if len(artistResults) == 0: + if not artistResults: logger.info(u"No results found for " + name) page.append('''

No results! Go back

''') return page