diff options
| author | Yuval Adam <yuval@y3xz.com> | 2015-12-31 22:45:11 +0200 |
|---|---|---|
| committer | Yuval Adam <yuval@y3xz.com> | 2015-12-31 22:47:01 +0200 |
| commit | 9bc622faf49397aac757f3e94f183325bdc1acfe (patch) | |
| tree | 695c7768550f2a668c8b998e5f243a7f9f11b517 | |
| parent | fa22e4f665741a62848a75b5fab7943398d28d3a (diff) | |
Fetch all latest images with caching
| -rw-r--r-- | geshem.py | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -17,9 +17,14 @@ redis = redis.from_url(environ.get('REDIS_URL', 'redis://localhost')) def fetch_latest_images(local=False): maps_json = requests.get(MAPS_JSON).json() for r in ['images140', 'images280']: - imgs = sorted(maps_json[r].items(), key=lambda x: x[0], reverse=True)[:1] # only take latest + imgs = sorted(maps_json[r].items(), key=lambda x: x[0], reverse=True) res = r[-3:] for ts, url in imgs: + if not local: + if redis.get('processed:{}'.format(ts)): + continue + else: + redis.set('processed:{}'.format(ts)) dt = datetime.strptime(ts, '%Y:%m:%d:%H:%M').strftime('%Y%m%d_%H%M%S') image = requests.get('http://' + url) if not local: |
