Merge branch 'develop' of https://github.com/rembo10/headphones into develop

Conflicts:
	headphones/searcher.py
This commit is contained in:
sbuser
2011-08-08 16:17:59 -05:00
4 changed files with 48 additions and 4 deletions

View File

@@ -215,7 +215,7 @@ def addArtisttoDB(artistid, extrasonly=False):
myDB.upsert("albums", newValueDict, controlValueDict)
lastfm.getAlbumDescription(rg['id'], release_dict['releaselist'])
lastfm.getAlbumDescription(rg['id'], artist['artist_name'], rg['title'])
# I changed the albumid from releaseid -> rgid, so might need to delete albums that have a releaseid
for release in release_dict['releaselist']:

View File

@@ -91,7 +91,52 @@ def getArtists():
for artistid in artistlist:
importer.addArtisttoDB(artistid)
def getAlbumDescription(rgid, releaselist):
def getAlbumDescription(rgid, artist, album):
myDB = db.DBConnection()
result = myDB.select('SELECT Summary from descriptions WHERE ReleaseGroupID=?', [rgid])
if result:
return
params = { "method": 'album.getInfo',
"api_key": api_key,
"artist": artist.encode('utf-8'),
"album": album.encode('utf-8')
}
searchURL = 'http://ws.audioscrobbler.com/2.0/?' + urllib.urlencode(params)
data = urllib.urlopen(searchURL).read()
if data == '<?xml version="1.0" encoding="utf-8"?><lfm status="failed"><error code="6">Album not found</error></lfm>':
return
try:
d = minidom.parseString(data)
albuminfo = d.getElementsByTagName("album")
for item in albuminfo:
summarynode = item.getElementsByTagName("summary")[0].childNodes
contentnode = item.getElementsByTagName("content")[0].childNodes
for node in summarynode:
summary = node.data
for node in contentnode:
content = node.data
controlValueDict = {'ReleaseGroupID': rgid}
newValueDict = {'Summary': summary,
'Content': content}
myDB.upsert("descriptions", newValueDict, controlValueDict)
except:
return
def getAlbumDescriptionOld(rgid, releaselist):
"""
This was a dumb way to do it - going to just use artist & album name but keeping this here
because I may use it to fetch and cache album art
"""
myDB = db.DBConnection()
result = myDB.select('SELECT Summary from descriptions WHERE ReleaseGroupID=?', [rgid])

View File

@@ -306,7 +306,7 @@ def getReleaseGroup(rgid):
releaselist.append(release_dict)
average_tracks = sum(x['trackscount'] for x in releaselist) / len(releaselist)
average_tracks = sum(x['trackscount'] for x in releaselist) / float(len(releaselist))
for item in releaselist:
item['trackscount_delta'] = abs(average_tracks - item['trackscount'])

View File

@@ -398,7 +398,6 @@ def searchNZB(albumid=None, new=False):
else:
bestqual = nzblist[0]
logger.info(u'Found best result: <a href="%s">%s</a> - %s' % (bestqual[2], bestqual[0], helpers.bytes_to_mb(bestqual[1])))
logger.info(u"Pre-processing result")
(data, bestqual) = preprocess(nzblist)