aboutsummaryrefslogtreecommitdiff
path: root/dev/seattle
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2020-06-06 10:13:48 -0600
committerMelody Horn <melody@boringcactus.com>2020-06-06 10:13:48 -0600
commit6333db9a6c994503f47a889399ed4d9c5cfa4993 (patch)
tree2e5c7077214a374226724463f52f7a5962ecfcc9 /dev/seattle
parentfd1b7e50bec5c28a9f6dcef7a147dd79b891c20c (diff)
downloadpig.observer-6333db9a6c994503f47a889399ed4d9c5cfa4993.tar.gz
pig.observer-6333db9a6c994503f47a889399ed4d9c5cfa4993.zip
add Seattle script
Diffstat (limited to 'dev/seattle')
-rw-r--r--dev/seattle/convert.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/dev/seattle/convert.py b/dev/seattle/convert.py
new file mode 100644
index 0000000..f7cbcd6
--- /dev/null
+++ b/dev/seattle/convert.py
@@ -0,0 +1,28 @@
+import requests
+import json
+from pprint import pprint
+
+r = requests.get('https://web6.seattle.gov/Travelers/api/Map/Data?zoomId=14&type=2')
+points = r.json()['Features']
+
+sources = []
+for point in points:
+ coord = point['PointCoordinate']
+ cams = []
+ for cam in point['Cameras']:
+ cam_id = cam['Id']
+ name = cam['Description']
+ result = {'id': cam_id, 'name': name}
+ if cam['Type'] == 'sdot':
+ stream = cam['ImageUrl'].replace('.jpg', '.stream')
+ stream_url = "https://58cc2dce193dd.streamlock.net:443/live/{stream}/playlist.m3u8".format(stream=stream)
+ result['stream'] = stream_url
+ elif cam['Type'] == 'wsdot':
+ url = 'https://images.wsdot.wa.gov/nw/' + cam['ImageUrl']
+ result['url'] = url
+ else:
+ raise ValueError('Weird camera type: ' + cam['Type'])
+ cams.append(result)
+ sources.append({'coord': coord, 'cams': cams})
+with open('sources.json', 'w') as f:
+ json.dump(sources, f)