From 0ff1282c14aeb71d3760d6550277cc995b67003d Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 13 Jul 2009 12:29:32 +0200 Subject: [PATCH] use saveUrl --- criterion/cache.py | 7 +------ impawards/cache.py | 7 ------- karagarga/cache.py | 8 +------- movieposterdb/cache.py | 8 +------- 4 files changed, 3 insertions(+), 27 deletions(-) diff --git a/criterion/cache.py b/criterion/cache.py index 521bf8e..341be47 100644 --- a/criterion/cache.py +++ b/criterion/cache.py @@ -19,12 +19,7 @@ def getPoster(id, url=None): if not url: data = oxweb.criterion.getData(id) url = data['posterUrl'] - if not os.path.exists(dirname): - os.makedirs(dirname) - data = oxlib.net.getUrl(url) - f = open(filename, 'w') - f.write(data) - f.close() + oxlib.net.saveUrl(url, filename) return filename def archivePosters(init=False): diff --git a/impawards/cache.py b/impawards/cache.py index 05348f6..68213eb 100644 --- a/impawards/cache.py +++ b/impawards/cache.py @@ -17,13 +17,6 @@ def getPosterFilename(id, url): def getPoster(id, url): filename = getPosterFilename(id, url) - if not os.path.exists(filename): - if not os.path.exists(dirname): - os.makedirs(dirname) - data = oxlib.net.getUrl(url) - f = open(filename, 'w') - f.write(data) - f.close() return filename def archivePosters(init=False): diff --git a/karagarga/cache.py b/karagarga/cache.py index 9608786..0c41cc0 100644 --- a/karagarga/cache.py +++ b/karagarga/cache.py @@ -19,13 +19,7 @@ def getPosterFilename(id, url): def getPoster(id, url): filename = getPosterFilename(id, url) - if not os.path.exists(filename): - if not os.path.exists(dirname): - os.makedirs(dirname) - data = oxlib.net.getUrl(url) - f = open(filename, 'w') - f.write(data) - f.close() + oxlib.net.saveUrl(url, filename) return filename def archivePosters(init=False): diff --git a/movieposterdb/cache.py b/movieposterdb/cache.py index 631e70d..36d5711 100644 --- a/movieposterdb/cache.py +++ b/movieposterdb/cache.py @@ -20,13 +20,7 @@ def getPoster(id, url=''): url_hash = hashlib.sha1(url).hexdigest() filename = os.path.join(dirname, '%s.jpg' % url_hash) filename = os.path.normpath(filename) - if not os.path.exists(filename): - if not os.path.exists(dirname): - os.makedirs(dirname) - data = oxlib.net.getUrl(url) - f = open(filename, 'w') - f.write(data) - f.close() + oxlib.net.saveUrl(url, filename) return filename def archivePosters(init=False):