ROW location enhancements. Cleanup SD quality string

This commit is contained in:
samwiseg0 2018-08-09 21:26:30 -04:00
parent a649136e8d
commit e95c5952c9

View file

@ -60,22 +60,39 @@ for session in sessions.keys():
else: else:
geodata = GeoLite2db(requests.get('http://ip.42.pl/raw').text) geodata = GeoLite2db(requests.get('http://ip.42.pl/raw').text)
latitude = geodata.location.latitude
# Get the latitude of each session. If we cant find it then...
if not geodata.location.latitude:
latitude = 37.234332396
else:
latitude = geodata.location.latitude
# Get the longitude of each session. If we cant find it then...
if not geodata.location.longitude:
longitude = -115.80666344
else:
longitude = geodata.location.longitude
decision = sessions[session]['transcode_decision'] decision = sessions[session]['transcode_decision']
if decision == 'copy': if decision == 'copy':
decision = 'direct stream' decision = 'direct stream'
video_resolution = sessions[session]['video_resolution'] quality = sessions[session]['video_resolution']
# If the video resolution is empty. Asssume it's an audio stream # If the video resolution is empty. Asssume it's an audio stream
if not video_resolution: if not quality:
video_resolution = sessions[session]['container'] quality = sessions[session]['container']
elif video_resolution == '4k': elif quality == 'sd':
video_resolution = sessions[session]['video_resolution'] quality = sessions[session]['video_resolution'].upper()
elif quality == '4k':
quality = sessions[session]['video_resolution']
else: else:
video_resolution = '{}p'.format(sessions[session]['video_resolution']) quality = '{}p'.format(sessions[session]['video_resolution'])
influx_payload.append( influx_payload.append(
{ {
@ -83,13 +100,16 @@ for session in sessions.keys():
"tags": { "tags": {
"type": "Session", "type": "Session",
"region_code": geodata.subdivisions.most_specific.iso_code, "region_code": geodata.subdivisions.most_specific.iso_code,
"latitude": latitude,
"longitude": longitude,
"location": '{} - {}'.format(geodata.subdivisions.most_specific.name, geodata.city.name),
"session_key": sessions[session]['session_key'] "session_key": sessions[session]['session_key']
}, },
"time": current_time, "time": current_time,
"fields": { "fields": {
"name": sessions[session]['friendly_name'], "name": sessions[session]['friendly_name'],
"title": sessions[session]['full_title'], "title": sessions[session]['full_title'],
"quality": video_resolution, "quality": quality,
"video_decision": sessions[session]['stream_video_decision'], "video_decision": sessions[session]['stream_video_decision'],
"transcode_decision": decision, "transcode_decision": decision,
"platform": sessions[session]['platform'], "platform": sessions[session]['platform'],