? plugins/artdisplay/artdisplay/Makefile
? plugins/artdisplay/artdisplay/Makefile.in
Index: plugins/artdisplay/artdisplay/AmazonCoverArtSearch.py
===================================================================
RCS file: /cvs/gnome/rhythmbox/plugins/artdisplay/artdisplay/AmazonCoverArtSearch.py,v
retrieving revision 1.1
diff -p -u -r1.1 AmazonCoverArtSearch.py
--- plugins/artdisplay/artdisplay/AmazonCoverArtSearch.py	9 May 2006 12:32:19 -0000	1.1
+++ plugins/artdisplay/artdisplay/AmazonCoverArtSearch.py	11 May 2006 17:44:02 -0000
@@ -32,7 +32,7 @@ ASSOCIATE = "webservices-20"
 class Bag: pass
 
 class AmazonCoverArtSearch (object):
-	def __init__(self, loader):
+	def __init__ (self, loader):
 		self.searching = False
 		self.cancel = False
 		self.loader = loader
@@ -71,7 +71,8 @@ class AmazonCoverArtSearch (object):
 		# Tidy up
 
 		# Replace quote characters
-		for char in ["\"", "'"]:
+		# don't replace single quote: could be important punctuation
+		for char in ["\""]:
 			st_artist = st_artist.replace (char, '')
 			st_album = st_album.replace (char, '')
 
@@ -112,9 +113,10 @@ class AmazonCoverArtSearch (object):
 		else:
 			if st_album != st_artist:
 				self.keywords.append ("%s %s" % (st_artist, st_album))
-				if st_album_no_vol != st_artist:
+				if st_album_no_vol != st_album:
 					self.keywords.append ("%s %s" % (st_artist, st_album_no_vol))
-				self.keywords.append ("%s" % (st_album))
+				if (st_album != "Unknown"):
+					self.keywords.append ("Various %s" % (st_album))
 			self.keywords.append ("%s" % (st_artist))
 
 		# Initiate asynchronous search
@@ -139,14 +141,14 @@ class AmazonCoverArtSearch (object):
 		if len(self.keywords)==0:
 			keyword = None
 		else:
-			keyword = self.keywords.pop(0)
+			keyword = self.keywords.pop (0)
 
 		if keyword is None:
 			# No keywords left to search -> no results
 			self.on_search_completed (None)
 		else:
 			# Retrieve search for keyword
-			url = self.__build_url (keyword.strip())
+			url = self.__build_url (keyword.strip ())
 			self.loader.get_url (url, self.on_search_response)
 
 	def __unmarshal (self, element):
@@ -158,9 +160,9 @@ class AmazonCoverArtSearch (object):
 			for child in childElements:
 				key = child.tagName
 				if hasattr (rc, key):
-					if type (getattr (rc, key)) <> type([]):
-						setattr (rc, key, [getattr(rc, key)])
-					setattr (rc, key, getattr (rc, key) + [self.__unmarshal(child)])
+					if type (getattr (rc, key)) <> type ([]):
+						setattr (rc, key, [getattr (rc, key)])
+					setattr (rc, key, getattr (rc, key) + [self.__unmarshal (child)])
 				elif isinstance(child, minidom.Element) and (child.tagName == 'Details'):
 					setattr (rc,key,[self.__unmarshal(child)])
 				else:
@@ -207,8 +209,9 @@ class AmazonCoverArtSearch (object):
 		s = s.strip ()
 
 		# TODO: Convert accented to unaccented (fixes matching Salomé vs Salome)
-		s = s.replace (" - "," ")	
-		s = s.replace (": "," ")
+		s = s.replace (" - ", " ")	
+		s = s.replace (": ", " ")
+		s = s.replace (" & ", " and ")
 
 		return s
 
@@ -216,38 +219,43 @@ class AmazonCoverArtSearch (object):
 		# Default to "no match", our results must match our criteria
 		best_match = None
 
-		if self.search_album!="Unknown":
-			album_check = self.__tidy_up_string(self.search_album)
-			for item in search_results:
-				# Check for album name in ProductName
-				product_name = self.__tidy_up_string(item.ProductName)
-				if product_name == album_check:
-					# Found exact album, can not get better than that
-					best_match = item
-					break
-				# If we already found a best_match, just keep checking for exact one
-				elif (best_match is None) and (product_name.find (album_check) != -1):
-					best_match = item
-
-		# If we still have no definite hit, use first result where artist matches
-		if (self.search_artist!="Unknown"):
-			artist_check = self.__tidy_up_string(self.search_artist)
-			if best_match is None:
-				# Check if artist appears in the Artists list
-				hit = False
+		try:
+			if self.search_album != "Unknown":
+				album_check = self.__tidy_up_string (self.search_album)
 				for item in search_results:
-					if type(item.Artists.Artist) <> type([]):
-						artists = [item.Artists.Artist]
-					else:
-						artists = item.Artists.Artist
-
-					for artist in artists:
-						artist = self.__tidy_up_string(artist)
-						if artist.find(artist_check) != -1:
-							best_match = item
-							hit = True						
-							break
-					if hit:
+					# Check for album name in ProductName
+					product_name = self.__tidy_up_string (item.ProductName)
+
+					if product_name == album_check:
+						# Found exact album, can not get better than that
+						best_match = item
 						break
- 
-		return best_match
+					# If we already found a best_match, just keep checking for exact one
+					elif (best_match is None) and (product_name.find (album_check) != -1):
+						best_match = item
+
+			# If we still have no definite hit, use first result where artist matches
+			if (self.search_album == "Unknown" and self.search_artist != "Unknown"):
+				artist_check = self.__tidy_up_string (self.search_artist)
+				if best_match is None:
+					# Check if artist appears in the Artists list
+					hit = False
+					for item in search_results:
+						if type (item.Artists.Artist) <> type ([]):
+							artists = [item.Artists.Artist]
+						else:
+							artists = item.Artists.Artist
+
+						for artist in artists:
+							artist = self.__tidy_up_string (artist)
+							if artist.find (artist_check) != -1:
+								best_match = item
+								hit = True						
+								break
+						if hit:
+							break
+
+			return best_match
+
+		except TypeError:
+			return None
Index: plugins/artdisplay/artdisplay/CoverArtDatabase.py
===================================================================
RCS file: /cvs/gnome/rhythmbox/plugins/artdisplay/artdisplay/CoverArtDatabase.py,v
retrieving revision 1.1
diff -p -u -r1.1 CoverArtDatabase.py
--- plugins/artdisplay/artdisplay/CoverArtDatabase.py	9 May 2006 12:32:19 -0000	1.1
+++ plugins/artdisplay/artdisplay/CoverArtDatabase.py	11 May 2006 17:44:02 -0000
@@ -26,7 +26,7 @@ from Loader import Loader
 ART_FOLDER = '~/.gnome2/rhythmbox/covers'
 
 class CoverArtDatabase (object):
-	def __init__(self):
+	def __init__ (self):
 		self.loader = Loader()
 
 	def create_search (self):
@@ -62,7 +62,8 @@ class CoverArtDatabase (object):
 			return
 
 		# replace quote characters
-		for char in ["\"", "'"]:
+		# don't replace single quote: could be important punctuation
+		for char in ["\""]:
 			st_artist = st_artist.replace (char, '')
 			st_album = st_album.replace (char, '')
 
@@ -89,24 +90,28 @@ class CoverArtDatabase (object):
 		# Get best match from results
 		best_match = search_engine.get_best_match (results)
 
+		if best_match is None:
+			callback (entry, None)
+			return
+
 		# Attempt to download image for best match
-		pic_url = str(best_match.ImageUrlLarge)
+		pic_url = str (best_match.ImageUrlLarge)
 		self.loader.get_url (pic_url, self.on_image_data_received, search_engine, "large", callback, best_match)
 
 	def on_image_data_received (self, image_data, search_engine, image_version, callback, best_match):
 		if image_data is None:
-			search_engine.search_next()
+			search_engine.search_next ()
 			return
 
-		if len(image_data) < 1000:
-			if image_version == "large":
+		if len (image_data) < 1000:
+			if image_version == "large" and best_match is not None:
 				# Fallback and try to load medium one
-				best_match = search_engine.get_best_match (best_match)
-				pic_url = str(best_match.ImageUrlMedium)
-				self.loader.get_url (pic_url, self.on_image_data_received, search_engine, "medium", callback)
+				pic_url = str (best_match.ImageUrlMedium)
+				self.loader.get_url (pic_url, self.on_image_data_received, search_engine, "medium", callback, best_match)
 				return
 
-			blist_location = self.build_art_cache_filename(search_engine.st_album, search_engine.st_artist, "rb-blist")
+			# only write the blist if not trying a fallback size
+			blist_location = self.build_art_cache_filename (search_engine.st_album, search_engine.st_artist, "rb-blist")
 			f = file (blist_location, 'w')
 			f.close ()
 			search_engine.search_next()
Index: plugins/artdisplay/artdisplay/Loader.py
===================================================================
RCS file: /cvs/gnome/rhythmbox/plugins/artdisplay/artdisplay/Loader.py,v
retrieving revision 1.1
diff -p -u -r1.1 Loader.py
--- plugins/artdisplay/artdisplay/Loader.py	9 May 2006 12:32:19 -0000	1.1
+++ plugins/artdisplay/artdisplay/Loader.py	11 May 2006 17:44:02 -0000
@@ -26,11 +26,11 @@ except:
 	use_gnomevfs = False
 
 
-class GnomeVFSAsyncSrc(object):  
-	def __init__(self):
+class GnomeVFSAsyncSrc (object):  
+	def __init__ (self):
 	    	self.chunk = 4096
 
-	def read_cb(self, handle, buffer, exc_type, bytes_requested, (data, callback, args)):
+	def read_cb (self, handle, buffer, exc_type, bytes_requested, (data, callback, args)):
 		if exc_type:
 			if issubclass (exc_type, gnomevfs.EOFError):
 				gobject.idle_add (callback, data, *args)
@@ -43,19 +43,19 @@ class GnomeVFSAsyncSrc(object):  
 		data += buffer
 		handle.read (self.chunk, self.read_cb, (data, callback, args))
 
-	def open_cb(self, handle, exc_type, (data, callback, args)):
+	def open_cb (self, handle, exc_type, (data, callback, args)):
 		if exc_type:
 			gobject.idle_add (callback, None, *args)
 			return
 
 		handle.read (self.chunk, self.read_cb, (data, callback, args))
     
-	def get_url(self, url, callback, *args):
-		gnomevfs.async.open(url, self.open_cb, data=("", callback, args))
+	def get_url (self, url, callback, *args):
+		gnomevfs.async.open (url, self.open_cb, data=("", callback, args))
 
 
-class URLLibSrc(object):
-    def get_url(self, url, callback, *args):
+class URLLibSrc (object):
+    def get_url (self, url, callback, *args):
 			try:
 				sock = urllib.urlopen (url)
 				data = sock.read ()
@@ -66,8 +66,8 @@ class URLLibSrc(object):
 				raise
 
 
-def Loader():
+def Loader ():
 	if use_gnomevfs:
-		return GnomeVFSAsyncSrc()
+		return GnomeVFSAsyncSrc ()
 	else:
-		return URLLibSrc()
+		return URLLibSrc ()
