Update the page parsing to the new Bing results-page format
authorIvan Frade <ivan.frade@nokia.com>
Fri, 11 Feb 2011 10:15:50 +0000 (12:15 +0200)
committerIvan Frade <ivan.frade@nokia.com>
Fri, 11 Feb 2011 10:15:50 +0000 (12:15 +0200)
Author: Nicolai Hess <nicolaihess@web.de>
http://talk.maemo.org/showpost.php?p=915354&postcount=46

src/album_art_thread.py

index 72dbc7a..13d3a06 100755 (executable)
@@ -168,7 +168,7 @@ class MussorgskyAlbumArt:
 
         good_artist = self.__clean_string_for_search (artist)
         good_album = self.__clean_string_for_search (album)
 
         good_artist = self.__clean_string_for_search (artist)
         good_album = self.__clean_string_for_search (album)
-
+        
         if (good_album and good_artist):
             full_try = BASE_MSN + good_album + "+" + good_artist + MSN_MEDIUM + MSN_SQUARE
             print "Searching (album + artist): %s" % (full_try)
         if (good_album and good_artist):
             full_try = BASE_MSN + good_album + "+" + good_artist + MSN_MEDIUM + MSN_SQUARE
             print "Searching (album + artist): %s" % (full_try)
@@ -203,7 +203,6 @@ class MussorgskyAlbumArt:
     
 
     def __get_url_from_msn_results_page (self, page):
     
 
     def __get_url_from_msn_results_page (self, page):
-
         if (not page):
             return
 
         if (not page):
             return
 
@@ -213,11 +212,11 @@ class MussorgskyAlbumArt:
         # 500 is just a safe limit
         for i in range (0, 500):
             # Iterate until find a jpeg
         # 500 is just a safe limit
         for i in range (0, 500):
             # Iterate until find a jpeg
-            start = page.find ("furl=", starting_at)
+            start = page.find ("imgurl:&quot;", starting_at)
             if (start == -1):
                 yield None
             if (start == -1):
                 yield None
-            end = page.find ("\"", start + len ("furl="))
-            current_option = page [start + len ("furl="): end].replace ("amp;", "")
+            end = page.find ("&", start + len ("imgurl:&quot;"))
+            current_option = page [start + len ("imgurl:&quot;"): end].replace ("amp;", "")
             if (current_option.lower().endswith (".jpg") or
                 current_option.lower().endswith (".jpeg")):
                 yield current_option
             if (current_option.lower().endswith (".jpg") or
                 current_option.lower().endswith (".jpeg")):
                 yield current_option