projects
/
mussorgsky
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bfdae38
)
Handle no_results page in image online search
author
Ivan Frade
<ivan.frade@gmail.com>
Fri, 21 Aug 2009 15:00:45 +0000
(18:00 +0300)
committer
Ivan Frade
<ivan.frade@gmail.com>
Fri, 21 Aug 2009 15:00:45 +0000
(18:00 +0300)
src/album_art.py
patch
|
blob
|
history
diff --git
a/src/album_art.py
b/src/album_art.py
index
912aa06
..
72cf1db
100755
(executable)
--- a/
src/album_art.py
+++ b/
src/album_art.py
@@
-102,6
+102,10
@@
class MussorgskyAlbumArt:
results_page = self.__msn_images (artist, album)
valid_images = []
for image_url in self.__get_url_from_msn_results_page (results_page):
results_page = self.__msn_images (artist, album)
valid_images = []
for image_url in self.__get_url_from_msn_results_page (results_page):
+ if (not image_url):
+ # Some searches doesn't return anything at all!
+ break
+
image = self.__get_url (image_url)
if (image):
image_path = os.path.join (CACHE_LOCATION, "alternative-" + str(len(valid_images)))
image = self.__get_url (image_url)
if (image):
image_path = os.path.join (CACHE_LOCATION, "alternative-" + str(len(valid_images)))
@@
-112,16
+116,17
@@
class MussorgskyAlbumArt:
return valid_images
def save_alternative (self, artist, album, path):
return valid_images
def save_alternative (self, artist, album, path):
- if (not os.path.exists (path)):
+ if not os.path.exists (path):
print "**** CRITICAL **** image in path", path, "doesn't exist!"
print "**** CRITICAL **** image in path", path, "doesn't exist!"
-
+ return (None, None)
+
filename = getCoverArtFileName (album)
thumbnail = getCoverArtThumbFileName (album)
os.rename (path, filename)
if (not self.__request_thumbnail (filename)):
print "Something wrong creating the thumbnail!"
filename = getCoverArtFileName (album)
thumbnail = getCoverArtThumbFileName (album)
os.rename (path, filename)
if (not self.__request_thumbnail (filename)):
print "Something wrong creating the thumbnail!"
-
+ return (filename, thumbnail)
def __last_fm (self, artist, album):
def __last_fm (self, artist, album):
@@
-157,7
+162,8
@@
class MussorgskyAlbumArt:
full_try = BASE_MSN + good_album + "+" + good_artist + MSN_MEDIUM + MSN_SQUARE
print "Searching (album + artist): %s" % (full_try)
result = self.__get_url (full_try)
full_try = BASE_MSN + good_album + "+" + good_artist + MSN_MEDIUM + MSN_SQUARE
print "Searching (album + artist): %s" % (full_try)
result = self.__get_url (full_try)
- return result
+ if (result.find ("no_results") == -1):
+ return result
if (album):
if (album.lower ().find ("greatest hit") != -1):
if (album):
if (album.lower ().find ("greatest hit") != -1):
@@
-167,13
+173,15
@@
class MussorgskyAlbumArt:
album_try = BASE_MSN + good_album + MSN_MEDIUM + MSN_SQUARE
print "Searching (album): %s" % (album_try)
result = self.__get_url (album_try)
album_try = BASE_MSN + good_album + MSN_MEDIUM + MSN_SQUARE
print "Searching (album): %s" % (album_try)
result = self.__get_url (album_try)
- return result
+ if (result.find ("no_results") == -1):
+ return result
if (artist):
artist_try = BASE_MSN + good_artist + "+CD+music" + MSN_SMALL + MSN_SQUARE + MSN_PHOTO
print "Searching (artist CD): %s" % (artist_try)
result = self.__get_url (artist_try)
if (artist):
artist_try = BASE_MSN + good_artist + "+CD+music" + MSN_SMALL + MSN_SQUARE + MSN_PHOTO
print "Searching (artist CD): %s" % (artist_try)
result = self.__get_url (artist_try)
- return result
+ if (result.find ("no_results") == -1):
+ return result
return None
return None