Fix extract for linux systems. Add more stream info
This commit is contained in:
parent
b098ffe5d2
commit
95d4bf200c
1 changed files with 13 additions and 7 deletions
20
tautulli.py
20
tautulli.py
|
@ -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'])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue