diff options
Diffstat (limited to 'dev/nyc')
-rw-r--r-- | dev/nyc/convert.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/dev/nyc/convert.py b/dev/nyc/convert.py index 4b00bfa..2f21861 100644 --- a/dev/nyc/convert.py +++ b/dev/nyc/convert.py @@ -9,16 +9,17 @@ data = raw_data['markers'] sources = [] for camera in data: - result = dict() - result['id'] = camera['id'] - result['name'] = camera['content'] + coord = [float(camera['latitude']), float(camera['longitude'])] + cam = dict() + cam['id'] = camera['id'] + cam['name'] = camera['content'] fetched = requests.get('https://nyctmc.org/google_popup.php', params={'cid': camera['id']}) match = re.search('http://207.251.86.238/cctv\\d+.jpg', fetched.text) if match is None: pprint(camera) continue url = match.group() - result['url'] = url - sources.append(result) + cam['url'] = url + sources.append({'coord': coord, 'cams': [cam]}) with open('sources.json', 'w') as f: json.dump({'NYC': sources}, f) |