mvantassel / plexpy2influx

Pipe select PlexPy metrics to InfluxDB so it can be graphed in Grafana
MIT License
7 stars 5 forks source link

Request - GeoLite2 User Data #17

Closed jedimstr closed 6 years ago

jedimstr commented 6 years ago

Plexpy offers GeoLite2 location data for each user/session. It would be great to get the same data shown in User/Last Known IP/Location Details (in Popup) if available via the plexpy API. This would allow us to map sessions/users on the Grafana Worldmap Plugin.

mvantassel commented 6 years ago

Hey @jedimstr, I'll look into this and see if it's available in the response or if it's an external request. I do know the IP address is there but not sure about geo data.

I think this would be a good opt-in feature for those that want to track this data. I like the idea of feeding the worldmap plugin too. I would only see one dot but could be great for others ;)

mvantassel commented 6 years ago

Looks like this is not possible without making a secondary call to get the geo data. See the example output for a movie here:

{
  "transcode_width": "1920",
  "user_thumb": "avatarurl",
  "labels": [],
  "height": "808",
  "parent_rating_key": "",
  "audio_codec": "aac",
  "parent_title": "",
  "rating_key": "59985",
  "transcode_video_codec": "h264",
  "transcode_audio_codec": "aac",
  "user_id": 123,
  "thumb": "thumbnailurl",
  "title": "File Title",
  "throttled": "0",
  "platform": "iOS",
  "transcode_height": "808",
  "transcode_container": "mpegts",
  "media_type": "movie",
  "video_resolution": "1080p",
  "grandparent_rating_key": "",
  "audio_channels": "2",
  "full_title": "File Title",
  "ip_address": "192.168.0.0",
  "transcode_audio_channels": "2",
  "transcode_speed": "2.3",
  "transcode_protocol": "hls",
  "progress_percent": "0",
  "bif_thumb": "",
  "grandparent_title": "",
  "parent_media_index": "",
  "machine_id": "machine id",
  "art": "artwork",
  "player": "iPhone",
  "year": "2017",
  "duration": "5418422",
  "session_key": "404",
  "transcode_key": "/transcode/sessions/transcode_key",
  "container": "mpegts",
  "indexes": 0,
  "video_decision": "copy",
  "state": "playing",
  "audio_decision": "transcode",
  "view_offset": "4980",
  "section_id": "4",
  "aspect_ratio": "",
  "user": "username",
  "transcode_decision": "transcode",
  "bitrate": "10847",
  "video_framerate": "24p",
  "media_index": "",
  "content_rating": "",
  "friendly_name": "friendly name",
  "parent_thumb": "",
  "video_codec": "h264",
  "grandparent_thumb": "",
  "transcode_progress": 1,
  "width": "1920"
}
jedimstr commented 6 years ago

That's disappointing... I was hoping some more data was available in the api.

Looks like this guy does something similar via python scripts and a secondary request to http://freegeoip.net.

https://www.reddit.com/r/homelab/comments/7wiupp/my_plex_bandwidthuserutilizationlocation_etc/

https://github.com/DirtyCajunRice/grafana-scripts/blob/master/tautulli.py