mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-21 08:24:00 +01:00
Fixed DATETIME typo, improved searching
This commit is contained in:
@@ -19,12 +19,7 @@ def scanMusic(dir=None):
|
|||||||
for r,d,f in os.walk(dir):
|
for r,d,f in os.walk(dir):
|
||||||
for files in f:
|
for files in f:
|
||||||
if any(files.endswith(x) for x in (".mp3", ".flac", ".aac", ".ogg", ".ape")):
|
if any(files.endswith(x) for x in (".mp3", ".flac", ".aac", ".ogg", ".ape")):
|
||||||
#logger.debug('File found: %s' % files)
|
results.append(os.path.join(r, 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
|
|
||||||
|
|
||||||
logger.info(u'%i music files found. Reading metadata....' % len(results))
|
logger.info(u'%i music files found. Reading metadata....' % len(results))
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -18,11 +18,16 @@ mb_lock = threading.Lock()
|
|||||||
def findArtist(name, limit=1):
|
def findArtist(name, limit=1):
|
||||||
|
|
||||||
with mb_lock:
|
with mb_lock:
|
||||||
|
|
||||||
artistlist = []
|
artistlist = []
|
||||||
attempt = 0
|
attempt = 0
|
||||||
artistResults = None
|
artistResults = None
|
||||||
term = '"'+name+'"'
|
|
||||||
|
chars = set('!?')
|
||||||
|
if any((c in chars) for c in name):
|
||||||
|
term = '"'+name+'"'
|
||||||
|
else:
|
||||||
|
term = name
|
||||||
|
|
||||||
while attempt < 5:
|
while attempt < 5:
|
||||||
|
|
||||||
|
|||||||
@@ -261,4 +261,4 @@ def searchNZB(albumid=None):
|
|||||||
break
|
break
|
||||||
|
|
||||||
myDB.action('UPDATE albums SET status = "Snatched" WHERE AlbumID=?', [albums[2]])
|
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"])
|
myDB.action('INSERT INTO snatched VALUES( ?, ?, ?, ?, DATETIME("NOW", "localtime"), ?)', [albums[2], bestqual[0], bestqual[1], bestqual[2], "Snatched"])
|
||||||
@@ -198,7 +198,7 @@ class WebInterface(object):
|
|||||||
raise cherrypy.HTTPRedirect("home")
|
raise cherrypy.HTTPRedirect("home")
|
||||||
else:
|
else:
|
||||||
artistResults = mb.findArtist(name, limit=10)
|
artistResults = mb.findArtist(name, limit=10)
|
||||||
if len(artistResults) == 0:
|
if not artistResults:
|
||||||
logger.info(u"No results found for " + name)
|
logger.info(u"No results found for " + name)
|
||||||
page.append('''<div class="table"><p class="center">No results! <a class="blue" href="home">Go back</a></p></div>''')
|
page.append('''<div class="table"><p class="center">No results! <a class="blue" href="home">Go back</a></p></div>''')
|
||||||
return page
|
return page
|
||||||
|
|||||||
Reference in New Issue
Block a user