mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-07 04:09:32 +01:00
Music scan fix for Synology/NAS users.Fixed error message when retrying a download with no more matches
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
import os, sys, locale
|
||||
import os, sys
|
||||
|
||||
from lib.configobj import ConfigObj
|
||||
|
||||
@@ -24,11 +24,6 @@ def main():
|
||||
headphones.PROG_DIR = os.path.dirname(headphones.FULL_PATH)
|
||||
headphones.ARGS = sys.argv[1:]
|
||||
|
||||
try:
|
||||
locale.setlocale(locale.LC_ALL, "")
|
||||
except Exception, e:
|
||||
pass
|
||||
|
||||
# Set up and gather command line arguments
|
||||
parser = argparse.ArgumentParser(description='Music add-on for SABnzbd+')
|
||||
|
||||
|
||||
@@ -12,6 +12,13 @@ def scanMusic(dir=None):
|
||||
|
||||
if not dir:
|
||||
dir = headphones.MUSIC_DIR
|
||||
|
||||
try:
|
||||
dir = str(dir)
|
||||
except UnicodeEncodeError:
|
||||
dir = unicode(dir).encode('unicode_escape')
|
||||
|
||||
logger.info('Starting Music Scan with directory: %s' % dir)
|
||||
|
||||
results = []
|
||||
|
||||
@@ -32,7 +39,8 @@ def scanMusic(dir=None):
|
||||
f = MediaFile(song)
|
||||
#logger.debug('Reading: %s' % song.decode('UTF-8'))
|
||||
except:
|
||||
logger.warn('Could not read file: %s' % song.decode('UTF-8'))
|
||||
logger.warn('Could not read file: %s' % song)
|
||||
continue
|
||||
else:
|
||||
if f.albumartist:
|
||||
artist = f.albumartist
|
||||
|
||||
@@ -14,7 +14,8 @@ def searchNZB(albumid=None, new=False):
|
||||
results = myDB.select('SELECT ArtistName, AlbumTitle, AlbumID, ReleaseDate from albums WHERE Status="Wanted" AND AlbumID=?', [albumid])
|
||||
else:
|
||||
results = myDB.select('SELECT ArtistName, AlbumTitle, AlbumID, ReleaseDate from albums WHERE Status="Wanted"')
|
||||
|
||||
new = True
|
||||
|
||||
for albums in results:
|
||||
|
||||
albumid = albums[2]
|
||||
@@ -107,7 +108,6 @@ def searchNZB(albumid=None, new=False):
|
||||
|
||||
d = feedparser.parse(searchURL)
|
||||
|
||||
|
||||
if not len(d.entries):
|
||||
logger.info(u"No results found from %s for %s" % (headphones.NEWZNAB_HOST, term))
|
||||
pass
|
||||
@@ -233,6 +233,12 @@ def searchNZB(albumid=None, new=False):
|
||||
bestqual = nzblist[i]
|
||||
break
|
||||
|
||||
try:
|
||||
x = bestqual[0]
|
||||
except UnboundLocalError:
|
||||
logger.info('No more matches for %s' % term)
|
||||
return
|
||||
|
||||
else:
|
||||
bestqual = nzblist[0]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user