PIL as mandatory dependency, libxml optional
[mussorgsky] / src / album_art.py
index 1933d72..007c929 100755 (executable)
@@ -1,16 +1,21 @@
 #!/usr/bin/env python2.5
 import urllib2, urllib
 #!/usr/bin/env python2.5
 import urllib2, urllib
-import libxml2
 import os
 from album_art_spec import getCoverArtFileName, getCoverArtThumbFileName, get_thumb_filename_for_path
 import dbus, time
 import string
 
 try:
 import os
 from album_art_spec import getCoverArtFileName, getCoverArtThumbFileName, get_thumb_filename_for_path
 import dbus, time
 import string
 
 try:
+    import libxml2
+    libxml_available = True
+except ImportError:
+    libxml_available = False
+
+try:
     import PIL
     import Image
     pil_available = True
     import PIL
     import Image
     pil_available = True
-except ImportException:
+except ImportError:
     pil_available = False
     
 
     pil_available = False
     
 
@@ -70,10 +75,14 @@ class MussorgskyAlbumArt:
                 print "Failed doing thumbnail. Probably album art is not an image!"
                 os.remove (filename)
                 return (None, None)
                 print "Failed doing thumbnail. Probably album art is not an image!"
                 os.remove (filename)
                 return (None, None)
-
+            
         return (filename, thumbnail)
 
     def __last_fm (self, artist, album):
         return (filename, thumbnail)
 
     def __last_fm (self, artist, album):
+
+        if (not libxml_available):
+            return None
+        
         if (not album or len (album) < 1):
             return None
         
         if (not album or len (album) < 1):
             return None