Update of /cvsroot/freevo/freevo/src/audio/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv20684

Modified Files:
        coversearch.py 
Removed Files:
        amazon-example.py 
Log Message:
Tried to make the Amazon search more intelligent.

Problem:        
    If a cover is not available, Amazon returns an 807b GIF file instead
    of saying so

Solution:
    What we do now is check the content length of the file
    before downloading and remove those entries from the list.

I've also removed the example, since the plugin itself works better.
        


Index: coversearch.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/audio/plugins/coversearch.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** coversearch.py      10 Jun 2003 13:13:55 -0000      1.2
--- coversearch.py      12 Jun 2003 16:47:04 -0000      1.3
***************
*** 14,17 ****
--- 14,30 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.3  2003/06/12 16:47:04  outlyer
+ # Tried to make the Amazon search more intelligent.
+ #
+ # Problem:
+ #     If a cover is not available, Amazon returns an 807b GIF file instead
+ #     of saying so
+ #
+ # Solution:
+ #     What we do now is check the content length of the file
+ #     before downloading and remove those entries from the list.
+ #
+ # I've also removed the example, since the plugin itself works better.
+ #
  # Revision 1.2  2003/06/10 13:13:55  outlyer
  # Initial revision is complete, current main problem is that it only
***************
*** 72,75 ****
--- 85,90 ----
  import plugin
  import re
+ import urllib2
+ import time
  
  from gui.PopupBox import PopupBox
***************
*** 100,111 ****
          cover = amazon.searchByKeyword('%s %s' % (artist,album) , 
product_line="music")
          items = []
          for i in range(len(cover)):
!             items += [ menu.MenuItem('%s' % cover[i].ProductName,
                                       self.cover_create, cover[i].ImageUrlLarge) ]
!         moviemenu = menu.Menu('Cover Results', items)
! 
!         box.destroy()
!         menuw.pushmenu(moviemenu)
!         return
  
  
--- 115,141 ----
          cover = amazon.searchByKeyword('%s %s' % (artist,album) , 
product_line="music")
          items = []
+         
+         # Check if they're valid before presenting the list to the user
+         # Grrr I wish Amazon wouldn't return an empty gif (807b)
+ 
          for i in range(len(cover)):
!             m = urllib2.urlopen(cover[i].ImageUrlLarge)
!             if not (m.info()['Content-Length'] == '807'):
!                 items += [ menu.MenuItem('%s' % cover[i].ProductName,
                                       self.cover_create, cover[i].ImageUrlLarge) ]
!             else:
!                 print "Image Placeholder for '%s - %s' skipped" % ( artist,album)
!        
!             box.destroy()
!         if items: 
!             moviemenu = menu.Menu('Cover Results', items)
!             menuw.pushmenu(moviemenu)
!             return
!         else:
!             box = PopupBox(text='No covers available from Amazon')
!             box.show()
!             time.sleep(2)
!             box.destroy()
!             return
  
  
***************
*** 116,120 ****
          import amazon
          import directory
-         import urllib2 
          # image Image, cStringIO  # Required if you want to convert the file into 
something, Amazon
                                   # only has JPEGs so it's a wasted step.
--- 146,149 ----

--- amazon-example.py DELETED ---




-------------------------------------------------------
This SF.NET email is sponsored by: eBay
Great deals on office technology -- on eBay now! Click here:
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to