From 79f3c826dc08fb390de6b161ce01fc0612b2a446 Mon Sep 17 00:00:00 2001 From: Remy Date: Sun, 17 Jul 2011 13:32:12 -0700 Subject: [PATCH] Bug Fixes: NZBs.org fixed, listindex error on import, illegal end of headers. New Feature: Shows the # of tracks in the Have bar. --- data/css/style.css | 6 ++++++ headphones/importer.py | 9 ++++++++- headphones/searcher.py | 30 ++++++++++++++++++++++-------- headphones/templates.py | 2 +- headphones/webserve.py | 12 ++++++------ 5 files changed, 43 insertions(+), 16 deletions(-) diff --git a/data/css/style.css b/data/css/style.css index 6cb1b6cc..2632ced6 100644 --- a/data/css/style.css +++ b/data/css/style.css @@ -90,6 +90,11 @@ h1{ font-size: 11px; margin-left: 45px; } +.smalltext3{ + font-size: 11px; + margin-left: 30px; + color: #867970; + } .mediumtext{ font-size: 16px; margin-left: 100px; @@ -139,6 +144,7 @@ a.externalred { div.progress-container { border: 1px solid #ccc; width: 100px; + height: 12px; margin: 2px 5px 2px 0; padding: 1px; float: left; diff --git a/headphones/importer.py b/headphones/importer.py index 4bba8f25..dbd4721f 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -102,7 +102,14 @@ def artistlist_to_mbids(artistlist): for artist in artistlist: results = mb.findArtist(artist, limit=1) - artistid = results[0]['id'] + + try: + artistid = results[0]['id'] + + except IndexError: + logger.info('MusicBrainz query turned up no matches for: %s' % artist) + continue + if artistid != various_artists_mbid and not is_exists(artistid): addArtisttoDB(artistid) diff --git a/headphones/searcher.py b/headphones/searcher.py index c3299283..d459dfcf 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -1,6 +1,7 @@ import urllib import string import lib.feedparser as feedparser +from xml.dom import minidom import os, re import headphones @@ -125,21 +126,34 @@ def searchNZB(albumid=None): searchURL = 'https://secure.nzbs.org/rss.php?' + urllib.urlencode(params) logger.info(u"Parsing results from "+searchURL) - d = feedparser.parse(searchURL) + d = minidom.parse(searchURL) + node = d.documentElement + items = d.getElementsByTagName("item") - for item in d.entries: - try: - url = item.link - title = item.title - size = int(item.report_size) + if len(items): + + for item in items: + + sizenode = item.getElementsByTagName("report:size")[0].childNodes + titlenode = item.getElementsByTagName("title")[0].childNodes + linknode = item.getElementsByTagName("link")[0].childNodes + + for node in sizenode: + size = int(node.data) + for node in titlenode: + title = node.data + for node in linknode: + url = node.data + 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) + else: + + logger.info(u"Nothing found.") if len(resultlist): diff --git a/headphones/templates.py b/headphones/templates.py index 574ab901..0c04e371 100644 --- a/headphones/templates.py +++ b/headphones/templates.py @@ -16,7 +16,7 @@ _shutdownheader = ''' - +
''' diff --git a/headphones/webserve.py b/headphones/webserve.py index 026a4a2e..46e39877 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -74,8 +74,8 @@ class WebInterface(object): (link) [delete] %s %s %s -
- ''' % (results[i][1], results[i][0], results[i][1], results[i][1], newStatus, newalbumName, releaseDate, percent)) +
%s/%s
+ ''' % (results[i][1], results[i][0], results[i][1], results[i][1], newStatus, newalbumName, releaseDate, percent, havetracks, totaltracks)) i = i+1 page.append('''
''') @@ -130,7 +130,7 @@ class WebInterface(object): (link) %s %s -
''' % (results[i][5], results[i][2], results[i][0], results[i][2], results[i][1], newStatus, percent)) +
%s/%s
''' % (results[i][5], results[i][2], results[i][0], results[i][2], results[i][1], newStatus, percent, havetracks, totaltracks)) i = i+1 page.append('''''') @@ -574,7 +574,7 @@ class WebInterface(object): def shutdown(self): logger.info(u"Headphones is shutting down...") threading.Timer(2, headphones.shutdown).start() - page = [templates._shutdownheader % 10] + page = [templates._shutdownheader % 15] page.append(templates._logobar) page.append(templates._nav) page.append('
Shutting down Headphones...
') @@ -586,7 +586,7 @@ class WebInterface(object): def restart(self): logger.info(u"Headphones is restarting...") threading.Timer(2, headphones.shutdown, [True]).start() - page = [templates._shutdownheader % 20] + page = [templates._shutdownheader % 30] page.append(templates._logobar) page.append(templates._nav) page.append('
Restarting Headphones...
') @@ -598,7 +598,7 @@ class WebInterface(object): def update(self): logger.info('Headphones is updating...') threading.Timer(2, headphones.shutdown, [True, True]).start() - page = [templates._shutdownheader % 60] + page = [templates._shutdownheader % 120] page.append(templates._logobar) page.append(templates._nav) page.append('
Updating Headphones...
')