diff --git a/data/css/style.css b/data/css/style.css index a621f1f2..15b4af99 100755 --- a/data/css/style.css +++ b/data/css/style.css @@ -178,9 +178,9 @@ div#albumheader { padding-top: 48px; height: 200px; } div#track_wrapper { margin-left: -50px; padding-top: 20px; font-size: 16px; width: 100%; } table#track_table th#number { text-align: right; min-width: 10px; } -table#track_table th#name { text-align: center; min-width: 300px; } +table#track_table th#name { text-align: center; min-width: 350px; } table#track_table th#duration { width: 175px; text-align: center; min-width: 100px; } -table#track_table th#location { text-align: center; width: 200px; } +table#track_table th#location { text-align: center; width: 250px; } table#track_table th#bitrate { text-align: center; min-width: 75px; } table#track_table td#number { vertical-align: middle; text-align: right; } diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 5f4aa2da..b392e559 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -194,7 +194,7 @@ Highest Quality including Lossless
Lossless Only
Preferred Bitrate: - kbps
+ kbps
Auto-Detect Preferred Bitrate diff --git a/data/interfaces/default/manage.html b/data/interfaces/default/manage.html index 8d283b97..cf5a476a 100644 --- a/data/interfaces/default/manage.html +++ b/data/interfaces/default/manage.html @@ -1,6 +1,7 @@ <%inherit file="base.html" /> <%! import headphones + from headphones.helpers import checked %> <%def name="headerIncludes()">
@@ -33,6 +34,9 @@ %endif +
+

Automatically add new artists

+

diff --git a/headphones/importer.py b/headphones/importer.py index c0cb0e60..893115c5 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -16,7 +16,7 @@ def is_exists(artistid): artistlist = myDB.select('SELECT ArtistID, ArtistName from artists WHERE ArtistID=?', [artistid]) if any(artistid in x for x in artistlist): - logger.debug(artistlist[0][1] + u" is already in the database. Updating 'have tracks', but not artist information") + logger.info(artistlist[0][1] + u" is already in the database. Updating 'have tracks', but not artist information") return True else: return False @@ -32,6 +32,7 @@ def artistlist_to_mbids(artistlist, forced=False): results = mb.findArtist(artist, limit=1) if not results: + logger.info('No results found for: %' % artist) continue try: @@ -297,6 +298,7 @@ def addReleaseById(rid): if match: newValueDict['Location'] = match['Location'] newValueDict['BitRate'] = match['BitRate'] + myDB.action('DELETE from have WHERE Location=?', [match['Location']]) myDB.upsert("tracks", newValueDict, controlValueDict) diff --git a/headphones/lastfm.py b/headphones/lastfm.py index 814a35e8..f46ea2f7 100644 --- a/headphones/lastfm.py +++ b/headphones/lastfm.py @@ -2,6 +2,7 @@ import urllib from xml.dom import minidom from collections import defaultdict import random +import time import headphones from headphones import db, logger @@ -19,7 +20,16 @@ def getSimilar(): for result in results[:12]: url = 'http://ws.audioscrobbler.com/2.0/?method=artist.getsimilar&mbid=%s&api_key=%s' % (result['ArtistID'], api_key) - data = urllib.urlopen(url).read() + + try: + data = urllib.urlopen(url).read() + except: + time.sleep(1) + continue + + len(data) < 200: + continue + d = minidom.parseString(data) node = d.documentElement artists = d.getElementsByTagName("artist") diff --git a/headphones/librarysync.py b/headphones/librarysync.py index 62b3affa..37cd10cb 100644 --- a/headphones/librarysync.py +++ b/headphones/librarysync.py @@ -158,7 +158,9 @@ def libraryScan(dir=None): for track in tracks: if not os.path.isfile(track['Location']): myDB.action('UPDATE tracks SET Location=? WHERE TrackID=?', [None, track['TrackID']]) - + + logger.info('Completed scanning of directory: %s. Updating track counts' % dir) + # Clean up the new artist list unique_artists = {}.fromkeys(new_artists).keys() current_artists = myDB.select('SELECT ArtistName, ArtistID from artists') @@ -170,10 +172,13 @@ def libraryScan(dir=None): havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE ArtistID like ? AND Location IS NOT NULL', [artist['ArtistID']])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ?', [artist['ArtistName']])) myDB.action('UPDATE artists SET HaveTracks=? WHERE ArtistID=?', [havetracks, artist['ArtistID']]) + logger.info('Found %i new artists' % len(artist_list)) + if headphones.ADD_ARTISTS: - logger.info('Found %i new artists to import.' % len(artist_list)) + logger.info('Importing %i new artists' % len(artist_list)) importer.artistlist_to_mbids(artist_list) else: + logger.info('To add these artists, go to Manage->Manage New Artists') headphones.NEW_ARTISTS = artist_list if headphones.DETECT_BITRATE: diff --git a/headphones/webserve.py b/headphones/webserve.py index 61f7f1ed..d5fe8006 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -236,7 +236,8 @@ class WebInterface(object): raise cherrypy.HTTPRedirect("home") importItunes.exposed = True - def musicScan(self, path, redirect=None): + def musicScan(self, path, redirect=None, autoadd=0): + headphones.ADD_ARTISTS = autoadd headphones.MUSIC_DIR = path headphones.config_write() try: