Template changes, bug fixed, lastfm exception fix

This commit is contained in:
Remy
2011-08-16 19:09:42 -07:00
parent 91576e3f63
commit fec2fbd926
7 changed files with 30 additions and 8 deletions

View File

@@ -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; }

View File

@@ -194,7 +194,7 @@
<input type="radio" name="preferred_quality" value="1" ${config['pref_qual_1']} /> Highest Quality including Lossless<br>
<input type="radio" name="preferred_quality" value="3" ${config['pref_qual_3']} /> Lossless Only<br>
<input type="radio" name="preferred_quality" value="2" ${config['pref_qual_2']} /> Preferred Bitrate:
<input type="text" name="preferred_bitrate" value="${config['pref_bitrate']}" size="5" maxlength="5" />kbps <br>
<input type="text" name="preferred_bitrate" value="${config['pref_bitrate']}" size="3" maxlength="5" />kbps <br>
<i class="smalltext2"><input type="checkbox" name="detect_bitrate" value="1" ${config['detect_bitrate']} />Auto-Detect Preferred Bitrate </i>
</td>
<td>

View File

@@ -1,6 +1,7 @@
<%inherit file="base.html" />
<%!
import headphones
from headphones.helpers import checked
%>
<%def name="headerIncludes()">
<div id="subhead_container">
@@ -33,6 +34,9 @@
<input type="text" value="Enter a Music Directory to scan" onfocus="if
(this.value==this.defaultValue) this.value='';" name="path" size="70" />
%endif
<br>
<h3><input type="checkbox" name="autoadd" value="1" ${checked(headphones.ADD_ARTISTS)}>Automatically add new artists</h3>
<br><br>
<input type="submit" /></form>
</div>

View File

@@ -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)

View File

@@ -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")

View File

@@ -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:

View File

@@ -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: