diff options
author | Melody Horn <melody@boringcactus.com> | 2020-06-03 15:08:20 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2020-06-03 15:08:20 -0600 |
commit | 558a6836ebe9b9e348ac67bdde244cb0c2eff81f (patch) | |
tree | c765d3ed60da1d7a515be55d67a4dd81f1f5daa6 /dev/nyc/convert.py | |
parent | 7a6d8d19b5c2951cbf713f59b558fb4847a65bfc (diff) | |
download | pig.observer-558a6836ebe9b9e348ac67bdde244cb0c2eff81f.tar.gz pig.observer-558a6836ebe9b9e348ac67bdde244cb0c2eff81f.zip |
add new york city
Diffstat (limited to 'dev/nyc/convert.py')
-rw-r--r-- | dev/nyc/convert.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/dev/nyc/convert.py b/dev/nyc/convert.py new file mode 100644 index 0000000..4b00bfa --- /dev/null +++ b/dev/nyc/convert.py @@ -0,0 +1,24 @@ +import json +from pprint import pprint +import requests +import re + +with open('cameras.json', 'r') as f: + raw_data = json.load(f) +data = raw_data['markers'] + +sources = [] +for camera in data: + result = dict() + result['id'] = camera['id'] + result['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) +with open('sources.json', 'w') as f: + json.dump({'NYC': sources}, f) |