mirror of
https://github.com/rembo10/headphones.git
synced 2026-03-26 14:49:26 +00:00
Bug fixes: more info error, ascii fix maybe?
This commit is contained in:
@@ -16,16 +16,15 @@ def scanMusic(dir=None):
|
||||
|
||||
results = []
|
||||
|
||||
for r,d,f in os.walk(str(dir)):
|
||||
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")):
|
||||
try:
|
||||
file = unicode(files)
|
||||
root = unicode(r)
|
||||
results.append(os.path.join(root,file))
|
||||
except UnicodeDecodeError, e:
|
||||
logger.error('Can not decode file %s. Error: %s' % (str(files), str(e)))
|
||||
continue
|
||||
logger.debug('File found: %s' % files)
|
||||
try:
|
||||
results.append(os.path.join(r, files))
|
||||
except UnicodeDecodeError, e:
|
||||
logger.error('Can not decode file %s. Error: %s' % (str(files), str(e)))
|
||||
continue
|
||||
|
||||
logger.info(u'%i music files found' % len(results))
|
||||
|
||||
@@ -56,8 +55,11 @@ def scanMusic(dir=None):
|
||||
|
||||
# Get the average bitrate if the option is selected
|
||||
if headphones.DETECT_BITRATE:
|
||||
headphones.PREFERRED_BITRATE = sum(bitrates)/len(bitrates)/1000
|
||||
|
||||
try:
|
||||
headphones.PREFERRED_BITRATE = sum(bitrates)/len(bitrates)/1000
|
||||
except ZeroDivisionError:
|
||||
logger.error('No bitrates found - cannot automatically detect preferred bitrate')
|
||||
|
||||
artistlist = {}.fromkeys(lst).keys()
|
||||
logger.info(u"Preparing to import %i artists" % len(artistlist))
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ def getArtist(artistid):
|
||||
artist_dict['artist_uniquename'] = artist.getUniqueName()
|
||||
artist_dict['artist_type'] = u.extractFragment(artist.type)
|
||||
artist_dict['artist_begindate'] = artist.beginDate
|
||||
artist_dict['artist_endDate'] = artist.endDate
|
||||
artist_dict['artist_enddate'] = artist.endDate
|
||||
|
||||
releasegroups = []
|
||||
|
||||
|
||||
@@ -20,7 +20,10 @@ def searchNZB(albumid=None):
|
||||
|
||||
albumid = albums[2]
|
||||
reldate = albums[3]
|
||||
year = reldate[:4]
|
||||
try:
|
||||
year = reldate[:4]
|
||||
except TypeError:
|
||||
year = ''
|
||||
clname = string.replace(helpers.latinToAscii(albums[0]), ' & ', ' ')
|
||||
clalbum = string.replace(helpers.latinToAscii(albums[1]), ' & ', ' ')
|
||||
term1 = re.sub('[\.\-]', ' ', '%s %s %s' % (clname, clalbum, year)).encode('utf-8')
|
||||
@@ -66,8 +69,8 @@ def searchNZB(albumid=None):
|
||||
else:
|
||||
logger.info('%s is larger than the maxsize for this category, skipping. (Size: %i bytes)' % (title, size))
|
||||
|
||||
except Exception, e:
|
||||
logger.info(u"No results found. %s" % e)
|
||||
except AttributeError, e:
|
||||
logger.info(u"No results found.")
|
||||
|
||||
if headphones.NEWZNAB:
|
||||
|
||||
@@ -91,19 +94,24 @@ def searchNZB(albumid=None):
|
||||
d = feedparser.parse(searchURL)
|
||||
logger.debug('Parsing complete. Found %i results' % len(d.entries))
|
||||
|
||||
for item in d.entries:
|
||||
try:
|
||||
url = item.link
|
||||
title = item.title
|
||||
size = int(item.links[1]['length'])
|
||||
if size < maxsize:
|
||||
resultlist.append((title, size, url))
|
||||
logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size)))
|
||||
else:
|
||||
logger.info('%s is larger than the maxsize for this category, skipping. (Size: %i bytes)' % (title, size))
|
||||
|
||||
except Exception, e:
|
||||
logger.info(u"No results found. %s" % e)
|
||||
|
||||
if not len(d.entries):
|
||||
logger.info(u"No results found.")
|
||||
|
||||
else:
|
||||
for item in d.entries:
|
||||
try:
|
||||
url = item.link
|
||||
title = item.title
|
||||
size = int(item.links[1]['length'])
|
||||
if size < maxsize:
|
||||
resultlist.append((title, size, url))
|
||||
logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size)))
|
||||
else:
|
||||
logger.info('%s is larger than the maxsize for this category, skipping. (Size: %i bytes)' % (title, size))
|
||||
|
||||
except Exception, e:
|
||||
logger.error(u"An unknown error occured trying to parse the feed: %s" % e)
|
||||
|
||||
if headphones.NZBSORG:
|
||||
|
||||
|
||||
@@ -216,9 +216,18 @@ class WebInterface(object):
|
||||
page.append(templates._logobar)
|
||||
page.append(templates._nav)
|
||||
artist = mb.getArtist(artistid)
|
||||
if artist['artist_begindate']:
|
||||
begindate = artist['artist_begindate']
|
||||
else:
|
||||
begindate = ''
|
||||
if artist['artist_enddate']:
|
||||
enddate = artist['artist_enddate']
|
||||
else:
|
||||
enddate = ''
|
||||
page.append('''<div class="table"><p class="center">Artist Information:</p>''')
|
||||
page.append('''<p class="mediumtext">Artist Name: %s </br> ''' % artist['artist_name'])
|
||||
page.append('''Unique ID: %s </br></br>Albums:<br />''' % artist['artist_id'])
|
||||
page.append('''<p class="mediumtext">Artist Name: %s (%s)</br> ''' % (artist['artist_name'], artist['artist_type']))
|
||||
page.append('''<p class="mediumtext">Years Active: %s - %s <br /><br />''' % (begindate, enddate))
|
||||
page.append('''MusicBrainz Link: <a class="external" href="http://www.musicbrainz.org/artist/%s">http://www.musicbrainz.org/artist/%s</a></br></br><b>Albums:</b><br />''' % (artistid, artistid))
|
||||
for rg in artist['releasegroups']:
|
||||
page.append('''%s <br />''' % rg['title'])
|
||||
return page
|
||||
|
||||
Reference in New Issue
Block a user