Fix extract for linux systems. Add more stream info

This commit is contained in:
samwiseg0 2018-08-06 12:44:47 -04:00
parent b098ffe5d2
commit 95d4bf200c

View file

@ -25,12 +25,15 @@ def GeoLite2db(ipaddress):
if not os.path.isfile('GeoLite2-City.mmdb'): if not os.path.isfile('GeoLite2-City.mmdb'):
urllib.request.urlretrieve('http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz', 'GeoLite2-City.tar.gz') urllib.request.urlretrieve('http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz', 'GeoLite2-City.tar.gz')
tar = tarfile.open('GeoLite2-City.tar.gz', "r:gz") tar = tarfile.open('GeoLite2-City.tar.gz', "r:gz")
tar.extractall() for files in tar.getmembers():
tar.close() if dbfile in files.name:
tempfolder = next(d for d in os.listdir(os.getcwd()) if 'GeoLite2' in d) files.name = os.path.basename(files.name)
tempfullpath = os.path.join(tempfolder, dbfile) tar.extract(files, '{}/'.format(os.path.dirname(os.path.realpath(__file__))))
os.rename(tempfullpath, dbfile)
shutil.rmtree(tempfolder) reader = geoip2.database.Reader(dbfile)
geodata = reader.city(ipaddress)
return geodata
reader = geoip2.database.Reader(dbfile) reader = geoip2.database.Reader(dbfile)
geodata = reader.city(ipaddress) geodata = reader.city(ipaddress)
@ -46,7 +49,10 @@ influx_payload = [
}, },
"time": current_time, "time": current_time,
"fields": { "fields": {
"current_streams": int(activity['stream_count']) "current_streams": int(activity['stream_count']),
"transcode_streams": int(activity['stream_count_transcode']),
"direct_play_streams": int(activity['stream_count_direct_play']),
"direct_streams": int(activity['stream_count_direct_stream'])
} }
} }
] ]