Add more Travel IQ dot cam states

This commit is contained in:
Chandler Swift 2024-02-03 03:01:05 -06:00
parent c125525413
commit 8f5803b5bc
Signed by: chandlerswift
GPG key ID: A851D929D52FB93F
2 changed files with 76 additions and 68 deletions

View file

@ -5,10 +5,15 @@ import json
states = {
"Alaska": "https://511.alaska.gov/",
"Arizona": "https://az511.com/",
"Connecticut": "https://ctroads.org/",
"Georgia": "https://511ga.org/",
"Idaho": "https://511.idaho.gov/",
"Louisiana": "https://www.511la.org/",
"Nevada": "https://www.nvroads.com/",
"NewEngland": "https://newengland511.org/",
"NewYork": "https://www.511ny.org/",
"Utah": "https://www.udottraffic.utah.gov/",
"Wisconsin": "https://511wi.gov/"
}
@ -54,18 +59,23 @@ for state, baseURL in states.items():
available_cameras = 999_999 # lots
while len(cameras) < available_cameras:
res = requests.get(f"{baseURL}/List/GetData/Cameras", {
"query": json.dumps(query),
"lang": "en",
})
if state == "Connecticut":
# gotta be a special snowflake I guess?
res = requests.post(f"{baseURL}/List/GetData/Cameras", json={"draw":1,"columns":[{"data":"sortId","name":"sortId","searchable":True,"orderable":True,"search":{"value":"","regex":False}},{"data":"cityName","name":"cityName","searchable":True,"orderable":True,"search":{"value":"","regex":False}},{"data":"roadway","name":"roadway","searchable":True,"orderable":True,"search":{"value":"","regex":False}},{"data":"sortIdDisplay","name":"sortIdDisplay","searchable":True,"orderable":True,"search":{"value":"","regex":False}},{"data":"description1","name":"description1","searchable":False,"orderable":True,"search":{"value":"","regex":False}},{"data":"direction","name":"direction","searchable":False,"orderable":False,"search":{"value":"","regex":False}},{"data":6,"name":"","searchable":False,"orderable":False,"search":{"value":"","regex":False}}],"order":[{"column":0,"dir":"asc"},{"column":1,"dir":"asc"}],"start":0,"length":10,"search":{"value":"","regex":False}})
else:
res = requests.get(f"{baseURL}/List/GetData/Cameras", {
"query": json.dumps(query),
"lang": "en",
})
res.raise_for_status()
res = res.json()
available_cameras = res['recordsTotal']
for c in res['data']:
if isinstance(c['videoUrl'], list): # LA returns multiple (identical?) streams
if 'videoUrl' in c and isinstance(c['videoUrl'], list): # LA returns multiple (identical?) streams
src = c['videoUrl'][0]
video_camera_count += 1
elif c['videoUrl']:
elif 'videoUrl' in c and c['videoUrl'] and c['videoUrl'] != '0':
# Yeah, Idaho has a single camera where videoURL = '0'. Nice.
src = c['videoUrl']
video_camera_count += 1
else:
@ -81,7 +91,7 @@ for state, baseURL in states.items():
"properties": {
'name': c['displayName'],
'views': [{
'hasVideo': bool(c['videoUrl']),
'hasVideo': 'videoUrl' in c and bool(c['videoUrl']),
'src': src,
}],
},