Added workaround to avoid geting the "this photo is currently unavailable" image...
authorThomas Schmidt <tschmidt@debian.org>
Fri, 16 Oct 2009 18:28:45 +0000 (20:28 +0200)
committerThomas Schmidt <tschmidt@debian.org>
Fri, 16 Oct 2009 18:28:45 +0000 (20:28 +0200)
canola-flickr/flickr/model.py
debian/changelog

index e7eda04..2be7eb0 100644 (file)
@@ -121,8 +121,18 @@ class ImageModel(ImageLocalModel):
 
         if photopath:
             path = photopath
+            log.debug("found image in local cache! (%s)" % path)
             try:
                 width, height = Image.open(path).size
+
+                # TODO: find a clever way to avoid the "this photo is
+                #       currently unavailable image", the code below is
+                #       just a workaround
+                if ((width == 500) and (height == 375) and (os.stat(path).st_size == 2737)):
+                    log.debug("deleting %s, seems to be the \"this photo is currently unavailable image\"" % path)
+                    os.unlink(path)
+                    # TODO: this might lead to an endless loop
+                    return self.get_photo()
             except IOError:
                 # try to re-download file!!!
                 log.debug("Error opening image file %s, deleting this one!!!" % path)
@@ -147,6 +157,7 @@ class ImageModel(ImageLocalModel):
                 url_thumbnail   = "%s_t.jpg" % url_prefix
 
                 for url in [ url_large, url_medium, url_small, url_thumbnail ]:
+                    log.debug("trying to download %s" % url)
                     path = download_manager.download_image(url)
 
                     # abort downloading is self.no_download is True, delete downloaded image, because
@@ -157,7 +168,15 @@ class ImageModel(ImageLocalModel):
                             return None
 
                     if not path == None:
-                        break
+                        width, height = Image.open(path).size
+                        # TODO: find a clever way to avoid the "this photo is
+                        #       currently unavailable image", the code below is
+                        #       just a workaround
+                        if ((width == 500) and (height == 375) and (os.stat(path).st_size == 2737)):
+                            log.debug("deleting %s, seems to be the \"this photo is currently unavailable image\"" % path)
+                            os.unlink(path)
+                            continue
+                        else: break
                 else:
                     log.error("could not get valid url for photo: %s" % photo)
                     return None
index 95b8090..45f1419 100644 (file)
@@ -3,8 +3,10 @@ canola-flickr-plugin (0.1.3-1) UNRELEASED; urgency=low
   * Fixed plugin for canola2-rc4
   * Depend on canola2 >= 2.0.0~rc4
   * Fixed slideshow mode
+  * Added workaround to avoid geting the "this photo is currently unavailable"
+    image by detecting it by resolution and filesize
 
- -- Thomas Schmidt <tschmidt@debian.org>  Fri, 16 Oct 2009 11:15:37 +0200
+ -- Thomas Schmidt <tschmidt@debian.org>  Fri, 16 Oct 2009 20:27:00 +0200
 
 canola-flickr-plugin (0.1.2+beta11-1) diablo; urgency=low