From 8d34e66764beb4a441f06353e5366cd62e85dc99 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 3 Jan 2021 17:17:47 +0100 Subject: [PATCH] Improve some code --- resources/lib/app/account.py | 2 ++ resources/lib/initialsetup.py | 1 - resources/lib/plex_functions.py | 2 +- resources/lib/plex_tv.py | 5 ++--- resources/lib/windows/direct_path_sources.py | 1 - 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/resources/lib/app/account.py b/resources/lib/app/account.py index 9ed28d68..043a8d51 100644 --- a/resources/lib/app/account.py +++ b/resources/lib/app/account.py @@ -14,6 +14,8 @@ class Account(object): self.plex_username = None self.plex_user_id = None self.plex_token = None + # Personal access token per specific user and PMS + # As a rule of thumb, always use this token! self.pms_token = None self.avatar = None self.myplexlogin = None diff --git a/resources/lib/initialsetup.py b/resources/lib/initialsetup.py index 47c5cf70..5b2fc4ae 100644 --- a/resources/lib/initialsetup.py +++ b/resources/lib/initialsetup.py @@ -280,7 +280,6 @@ class InitialSetup(object): } or None if unsuccessful """ - server = None # If no server is set, let user choose one if not app.CONN.server or not app.CONN.machine_identifier: showDialog = True diff --git a/resources/lib/plex_functions.py b/resources/lib/plex_functions.py index fbeeb8b7..6622b163 100644 --- a/resources/lib/plex_functions.py +++ b/resources/lib/plex_functions.py @@ -157,7 +157,7 @@ def check_connection(url, token=None, verifySSL=None): def discover_pms(token=None): """ Optional parameter: - token token for plex.tv + token token for plex.tv - WARNING: for the main Plex user only! Returns a list of available PMS to connect to, one entry is the dict: { diff --git a/resources/lib/plex_tv.py b/resources/lib/plex_tv.py index ac9fb2a3..35be2be1 100644 --- a/resources/lib/plex_tv.py +++ b/resources/lib/plex_tv.py @@ -76,15 +76,14 @@ def switch_home_user(userid, pin, token, machine_identifier): # Set to empty iterable list for loop xml = [] - found = 0 LOG.debug('Our machine_identifier is %s', machine_identifier) for device in xml: identifier = device.attrib.get('clientIdentifier') LOG.debug('Found the Plex clientIdentifier: %s', identifier) if identifier == machine_identifier: - found += 1 token = device.attrib.get('accessToken') - if found == 0: + break + else: LOG.info('No tokens found for your server! Using empty string') token = '' LOG.info('Plex.tv switch HomeUser change successfull for user %s', diff --git a/resources/lib/windows/direct_path_sources.py b/resources/lib/windows/direct_path_sources.py index 92452334..5bcfe985 100644 --- a/resources/lib/windows/direct_path_sources.py +++ b/resources/lib/windows/direct_path_sources.py @@ -1,7 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """ -:module: plexkodiconnect.userselect :synopsis: Prompts the user to add network paths and username passwords for e.g. smb paths """