mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 07:46:07 -07:00
Add geoip lookup to API
This commit is contained in:
parent
2f5526388a
commit
906e4055d8
2 changed files with 64 additions and 11 deletions
29
API.md
29
API.md
|
@ -169,6 +169,10 @@ Return the api docs formatted with markdown.
|
||||||
Download the PlexPy log file.
|
Download the PlexPy log file.
|
||||||
|
|
||||||
|
|
||||||
|
### download_plex_log
|
||||||
|
Download the Plex log file.
|
||||||
|
|
||||||
|
|
||||||
### edit_library
|
### edit_library
|
||||||
Update a library section on PlexPy.
|
Update a library section on PlexPy.
|
||||||
|
|
||||||
|
@ -318,6 +322,31 @@ Returns:
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### get_geoip_lookup
|
||||||
|
Get the geolocation info for an IP address. The GeoLite2 database must be installed.
|
||||||
|
|
||||||
|
```
|
||||||
|
Required parameters:
|
||||||
|
ip_address
|
||||||
|
|
||||||
|
Optional parameters:
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
json:
|
||||||
|
{"country": "United States",
|
||||||
|
"region": "California",
|
||||||
|
"city": "Mountain View",
|
||||||
|
"timezone": "America/Los_Angeles",
|
||||||
|
"latitude": 37.386,
|
||||||
|
"longitude": -122.0838
|
||||||
|
}
|
||||||
|
json:
|
||||||
|
{"error": "The address 127.0.0.1 is not in the database."
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### get_history
|
### get_history
|
||||||
Get the PlexPy history.
|
Get the PlexPy history.
|
||||||
|
|
||||||
|
|
|
@ -4265,7 +4265,31 @@ class WebInterface(object):
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@cherrypy.tools.json_out()
|
@cherrypy.tools.json_out()
|
||||||
@requireAuth()
|
@requireAuth()
|
||||||
|
@addtoapi()
|
||||||
def get_geoip_lookup(self, ip_address='', **kwargs):
|
def get_geoip_lookup(self, ip_address='', **kwargs):
|
||||||
|
""" Get the geolocation info for an IP address. The GeoLite2 database must be installed.
|
||||||
|
|
||||||
|
```
|
||||||
|
Required parameters:
|
||||||
|
ip_address
|
||||||
|
|
||||||
|
Optional parameters:
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
json:
|
||||||
|
{"country": "United States",
|
||||||
|
"region": "California",
|
||||||
|
"city": "Mountain View",
|
||||||
|
"timezone": "America/Los_Angeles",
|
||||||
|
"latitude": 37.386,
|
||||||
|
"longitude": -122.0838
|
||||||
|
}
|
||||||
|
json:
|
||||||
|
{"error": "The address 127.0.0.1 is not in the database."
|
||||||
|
}
|
||||||
|
```
|
||||||
|
"""
|
||||||
geo_info = helpers.geoip_lookup(ip_address)
|
geo_info = helpers.geoip_lookup(ip_address)
|
||||||
if isinstance(geo_info, basestring):
|
if isinstance(geo_info, basestring):
|
||||||
return {'error': geo_info}
|
return {'error': geo_info}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue