From f21ff06227853c0f2ef3a8053f881e8e318b1210 Mon Sep 17 00:00:00 2001 From: Remy Date: Thu, 14 Jul 2011 15:44:02 -0700 Subject: [PATCH] Bug Fixes: 503 Error on import, fixed sorting --- headphones/itunesimport.py | 7 ++++++- headphones/webserve.py | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/headphones/itunesimport.py b/headphones/itunesimport.py index f36e0dd6..80d018c6 100644 --- a/headphones/itunesimport.py +++ b/headphones/itunesimport.py @@ -99,11 +99,16 @@ def importartist(artistlist): if any(artistid in x for x in artistlist): logger.info(result.artist.name + u" is already in the database, skipping") else: - c.execute('INSERT INTO artists VALUES( ?, ?, ?, CURRENT_DATE, ?)', (artistid, artist.name, artist.sortName, 'Active')) + if artist.name.startswith('The '): + sortname = artist.name[4:] + else: + sortname = artist.name + c.execute('INSERT INTO artists VALUES( ?, ?, ?, CURRENT_DATE, ?)', (artistid, artist.name, sortname, 'Active')) for rg in artist.getReleaseGroups(): rgid = u.extractUuid(rg.id) releaseid = getReleaseGroup(rgid) + time.sleep(1) inc = ws.ReleaseIncludes(artist=True, releaseEvents= True, tracks= True, releaseGroup=True) results = ws.Query().getReleaseById(releaseid, inc) diff --git a/headphones/webserve.py b/headphones/webserve.py index 20c6f76b..19a21ced 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -259,7 +259,11 @@ class WebInterface(object): else: logger.info(u"Adding " + artist.name + " to the database.") - c.execute('INSERT INTO artists VALUES( ?, ?, ?, CURRENT_DATE, ?)', (artistid, artist.name, artist.sortName, 'Active')) + if artist.name.startswith('The '): + sortname = artist.name[4:] + else: + sortname = artist.name + c.execute('INSERT INTO artists VALUES( ?, ?, ?, CURRENT_DATE, ?)', (artistid, artist.name, sortname, 'Active')) for rg in artist.getReleaseGroups(): rgid = u.extractUuid(rg.id)