From: Adam C. <ad...@dv...> - 2011-08-25 21:31:56
|
Author: adam Date: Thu Aug 25 17:41:33 2011 New Revision: 11868 Log: Add support for images from http:// and https:// urls. Modified: branches/rel-1/freevo/src/skins/osd/skin.py Modified: branches/rel-1/freevo/src/skins/osd/skin.py ============================================================================== --- branches/rel-1/freevo/src/skins/osd/skin.py (original) +++ branches/rel-1/freevo/src/skins/osd/skin.py Thu Aug 25 17:41:33 2011 @@ -40,7 +40,7 @@ from time import strftime from kaa import imlib2 -from util import vfs, objectcache +from util import vfs, objectcache, webcache widget_styles = {} definitions = {} @@ -638,7 +638,12 @@ # Finally load the image and scale it as required. if not image: - image = imlib2.open(filename) + if filename.startswith('http://') or filename.startswith('https://'): + fp = webcache.get_default_cache().get(filename) + image = imlib2.open_from_memory(fp.read()) + fp.close() + else: + image = imlib2.open(filename) w = image.width h = image.height src_size = (image.width, image.height) @@ -690,6 +695,10 @@ def find_image(filename): _debug_('Looking for %s (icontheme %s)' % (filename, icontheme), 2) + + if filename.startswith('http://') or filename.startswith('https://'): + return filename + if icontheme: dirs = [os.path.join(config.IMAGE_DIR, 'osd', icontheme), os.path.join(config.ICON_DIR, 'osd', icontheme)] |