def getThumbnailFromCache(link): cachePath = getPyShareHomeDirectory() + 'cache/' filename = cachePath + md5(link).hexdigest() if os.path.exists(filename): pixbuf = gtk.gdk.pixbuf_new_from_file(filename) else: pixbuf = None return pixbuf
def saveThumbnail(pixbuf, file, link): cachePath = getPyShareHomeDirectory() + 'cache/' if not os.path.exists(cachePath): os.makedirs(cachePath) filename = cachePath + md5(link).hexdigest() splittedFileName = file.split('.') ext = None if len(splittedFileName) > 1: ext = splittedFileName[-1].lower() if(ext=="jpg" or ext=="gif" or (not ext)): pixbuf.save(filename, "jpeg") else: pixbuf.save(filename, ext)
def removeFromCache(link): cachePath = getPyShareHomeDirectory() + 'cache/' filename = cachePath + md5(link).hexdigest() if os.path.exists(filename): os.remove(filename)