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
51
API.md
51
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.
|
||||||
|
|
||||||
|
@ -555,16 +584,16 @@ Optional parameters:
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
json:
|
json:
|
||||||
{"child_count": null,
|
{"child_count": null,
|
||||||
"count": 887,
|
"count": 887,
|
||||||
"do_notify": 1,
|
"do_notify": 1,
|
||||||
"do_notify_created": 1,
|
"do_notify_created": 1,
|
||||||
"keep_history": 1,
|
"keep_history": 1,
|
||||||
"library_art": "/:/resources/movie-fanart.jpg",
|
"library_art": "/:/resources/movie-fanart.jpg",
|
||||||
"library_thumb": "/:/resources/movie.png",
|
"library_thumb": "/:/resources/movie.png",
|
||||||
"parent_count": null,
|
"parent_count": null,
|
||||||
"section_id": 1,
|
"section_id": 1,
|
||||||
"section_name": "Movies",
|
"section_name": "Movies",
|
||||||
"section_type": "movie"
|
"section_type": "movie"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -1419,7 +1448,7 @@ Returns:
|
||||||
"is_home_user": 1,
|
"is_home_user": 1,
|
||||||
"is_restricted": 0,
|
"is_restricted": 0,
|
||||||
"keep_history": 1,
|
"keep_history": 1,
|
||||||
"shared_libraries": ["10", "1", "4", "5", "15", "20", "2"],
|
"shared_libraries": ["10", "1", "4", "5", "15", "20", "2"],
|
||||||
"user_id": 133788,
|
"user_id": 133788,
|
||||||
"user_thumb": "https://plex.tv/users/k10w42309cynaopq/avatar",
|
"user_thumb": "https://plex.tv/users/k10w42309cynaopq/avatar",
|
||||||
"username": "LordCommanderSnow"
|
"username": "LordCommanderSnow"
|
||||||
|
|
|
@ -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