Link seasoned account with plex #120

Closed
opened 2019-10-16 17:05:44 +00:00 by KevinMidboe · 0 comments
KevinMidboe commented 2019-10-16 17:05:44 +00:00 (Migrated from github.com)

Features:

  • Want a plex user to be able to see their:
    • watch history
    • recently added
    • contact info ??

Roadmap for implementation:

  • Send credentials for plex to server.
  • Authenticate with plex and get userId.
  • Link userId to the auth token.
  • Fail with any plex error
  • or return success

Challenges:

  • What happens to users if they are not shared with the library anymore? [0]
  • Need to fetch profile settings when visiting profile/activity pages.

Authenticating with plex javascript pseudocode:

  const url = new URL('https://plex.tv/api/v2/users/signin')
  url.searchParams.append('X-Plex-Client-Identifier', 'seasoned')
  url.searchParams.append('Content-Type', 'application/json')

  let formData = new FormData();
  formData.set('login', username)
  formData.set('password', password)
  formData.set('rememberMe', false)

  return axios({
      method: 'POST',
      url: url.href,
      headers: headers,
      data: formData
    })
    .catch(error => { console.error(`api error authentication plex: ${username}`); throw error })

Getting watch stats from tautulli api.

$ http://TAU_IP:8181/api/v2?apikey=API_KEY&cmd=get_user_watch_time_stats&user_id=1217266
{
    "response": {
        "data": [
            {
                "query_days": 1,
                "total_plays": 1,
                "total_time": 1478
            },
            {
                "query_days": 7,
                "total_plays": 6,
                "total_time": 9349
            },
            {
                "query_days": 30,
                "total_plays": 59,
                "total_time": 86872
            },
            {
                "query_days": 0,
                "total_plays": 786,
                "total_time": 1259781
            }
        ],
        "message": null,
        "result": "success"
    }
}

Tautulli is already a python api for plex. They find the database and read directly from the plex database. This solves a large issue with keeping my custom queries updated with changes to plex, this will be patched in the tautulli api we are using.

[0] https://github.com/Tautulli/Tautulli/blob/master/API.md#get_user_names

Features: - Want a plex user to be able to see their: - watch history - recently added - contact info ?? Roadmap for implementation: - Send credentials for plex to server. - Authenticate with plex and get userId. - Link userId to the auth token. - Fail with any plex error - or return success Challenges: - What happens to users if they are not shared with the library anymore? [0] - Need to fetch profile settings when visiting profile/activity pages. Authenticating with plex javascript pseudocode: ```javascript const url = new URL('https://plex.tv/api/v2/users/signin') url.searchParams.append('X-Plex-Client-Identifier', 'seasoned') url.searchParams.append('Content-Type', 'application/json') let formData = new FormData(); formData.set('login', username) formData.set('password', password) formData.set('rememberMe', false) return axios({ method: 'POST', url: url.href, headers: headers, data: formData }) .catch(error => { console.error(`api error authentication plex: ${username}`); throw error }) ``` Getting watch stats from tautulli api. ```bash $ http://TAU_IP:8181/api/v2?apikey=API_KEY&cmd=get_user_watch_time_stats&user_id=1217266 { "response": { "data": [ { "query_days": 1, "total_plays": 1, "total_time": 1478 }, { "query_days": 7, "total_plays": 6, "total_time": 9349 }, { "query_days": 30, "total_plays": 59, "total_time": 86872 }, { "query_days": 0, "total_plays": 786, "total_time": 1259781 } ], "message": null, "result": "success" } } ``` Tautulli is already a python api for plex. They find the database and read directly from the plex database. This solves a large issue with keeping my custom queries updated with changes to plex, this will be patched in the tautulli api we are using. [0] https://github.com/Tautulli/Tautulli/blob/master/API.md#get_user_names
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: KevinMidboe/seasonedShows#120
No description provided.