def cache_recent_image(label, type, id, image): file_dir = os.path.join(DATA_DIR, 'cache', 'xbmc', label, 'recent_%s' % type) create_dir(file_dir) file_path = os.path.join(file_dir, '%s.jpg' % id) if not os.path.exists(file_path): image_path = maraschino_path() + xbmc_image(image, label) Thread(target=download_image, args=(image_path, file_path)).start() THREADS.append(len(THREADS) + 1) return xbmc_image(image, label)
def cache_image(image, type): if type == 'shows': dir = '%s/cache/trakt/shows' % DATA_DIR else: dir = '%s/cache/trakt/movies' % DATA_DIR image = small_poster(image) x = image.rfind('/') filename = image[x:] file_path = "%s%s" % (dir, filename) if not os.path.exists(file_path): Thread(target=download_image, args=(image, file_path)).start() THREADS.append(len(THREADS) + 1) return '%s/cache/trakt/%s/%s' % (WEBROOT, type, filename[1:])