From d1fdf5d25f9eb1b0e99bbad6f17739836ff5aaed Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 3 Jan 2021 17:17:17 +0100 Subject: [PATCH 1/6] Fix PKC using main user's token if PMS address changes --- resources/lib/initialsetup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/lib/initialsetup.py b/resources/lib/initialsetup.py index b8536dec..612e0dd9 100644 --- a/resources/lib/initialsetup.py +++ b/resources/lib/initialsetup.py @@ -435,7 +435,6 @@ class InitialSetup(object): utils.settings('plex_servername', server['name']) utils.settings('plex_serverowned', 'true' if server['owned'] else 'false') - utils.settings('accessToken', server['token']) # Careful to distinguish local from remote PMS if server['local']: scheme = server['scheme'] From a648d8941a6a45af243f30260da6d9f7340ef5f6 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 3 Jan 2021 17:17:47 +0100 Subject: [PATCH 2/6] 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 3a8ffb7f..93c7f9b5 100644 --- a/resources/lib/app/account.py +++ b/resources/lib/app/account.py @@ -15,6 +15,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 612e0dd9..10d5fd97 100644 --- a/resources/lib/initialsetup.py +++ b/resources/lib/initialsetup.py @@ -287,7 +287,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 dac7e2b0..2d49441b 100644 --- a/resources/lib/plex_functions.py +++ b/resources/lib/plex_functions.py @@ -164,7 +164,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 c6712b4f..a3d0ca69 100644 --- a/resources/lib/plex_tv.py +++ b/resources/lib/plex_tv.py @@ -101,15 +101,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 888e9667..2c605a86 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 """ From 7cf8cb59f13b5993ca5791fee78ccfb5c060638c Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 9 Jan 2021 17:00:18 +0100 Subject: [PATCH 3/6] Improve logic when writing credentials to settings file --- resources/lib/plex_tv.py | 30 +++++------------------------- resources/lib/service_entry.py | 3 +++ 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/resources/lib/plex_tv.py b/resources/lib/plex_tv.py index a3d0ca69..1a6c76a5 100644 --- a/resources/lib/plex_tv.py +++ b/resources/lib/plex_tv.py @@ -35,18 +35,6 @@ class HomeUser(utils.AttributeDict): return self.restricted == '1' -def homeuser_to_settings(user): - """ - Writes one HomeUser to the Kodi settings file - """ - utils.settings('myplexlogin', 'true') - utils.settings('plexLogin', user.title) - utils.settings('plexToken', user.authToken) - utils.settings('plexid', user.id) - utils.settings('plexAvatar', user.thumb) - utils.settings('plex_status', value=utils.lang(39227)) - - def switch_home_user(userid, pin, token, machine_identifier): """ Retrieves Plex home token for a Plex home user. Returns None if this fails @@ -59,8 +47,6 @@ def switch_home_user(userid, pin, token, machine_identifier): Output: usertoken Might be empty strings if no token found for the machine_identifier that was chosen - - utils.settings('userid') and utils.settings('username') with new plex token """ LOG.info('Switching to user %s', userid) url = 'https://plex.tv/api/home/users/%s/switch' % userid @@ -79,16 +65,6 @@ def switch_home_user(userid, pin, token, machine_identifier): username = xml.get('title', '') token = xml.get('authenticationToken', '') - # Write to settings file - utils.settings('username', username) - utils.settings('accessToken', token) - utils.settings('userid', xml.get('id', '')) - utils.settings('plex_restricteduser', - 'true' if xml.get('restricted', '0') == '1' - else 'false') - app.CONN.restricted_user = True if \ - xml.get('restricted', '0') == '1' else False - # Get final token to the PMS we've chosen url = 'https://plex.tv/api/resources?includeHttps=1' xml = DU().downloadUrl(url, @@ -231,7 +207,11 @@ def sign_in_with_pin(): if xml is None: return user = HomeUser(xml.attrib) - homeuser_to_settings(user) + utils.settings('myplexlogin', 'true') + utils.settings('plex_status', value=utils.lang(39227)) + utils.settings('plexLogin', user.title) + utils.settings('plexid', user.id) + utils.settings('plexToken', user.authToken) return user diff --git a/resources/lib/service_entry.py b/resources/lib/service_entry.py index dc732ff1..8c4d9e27 100644 --- a/resources/lib/service_entry.py +++ b/resources/lib/service_entry.py @@ -416,8 +416,11 @@ class Service(object): utils.settings('username', value=username) utils.settings('userid', value=user_id) utils.settings('accessToken', value=token) + utils.settings('plex_restricteduser', + 'true' if user.isManaged else 'false') app.ACCOUNT.load() app.ACCOUNT.set_authenticated() + app.CONN.restricted_user = user.isManaged return True def ServiceEntryPoint(self): From 5014a0fafaeffd5e9c5d5b6a1e45959531dc0f51 Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 9 Jan 2021 17:14:56 +0100 Subject: [PATCH 4/6] Beta version bump 2.12.7 --- addon.xml | 8 ++++++-- changelog.txt | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/addon.xml b/addon.xml index bea96a8a..97bbfbb8 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + @@ -83,7 +83,11 @@ Natūralioji „Plex“ integracija į „Kodi“ Prijunkite „Kodi“ prie „Plex Medija Serverio“. Šiame papildinyje daroma prielaida, kad valdote visus savo vaizdo įrašus naudodami „Plex“ (ir nė vieno su „Kodi“). Galite prarasti jau saugomus „Kodi“ vaizdo įrašų ir muzikos duomenų bazių duomenis (kadangi šis papildinys juos tiesiogiai pakeičia). Naudokite savo pačių rizika! Naudokite savo pačių rizika - version 2.12.6: + version 2.12.7 (beta only): +- Fix PKC suddenly using main Plex user's credentials, e.g. when the PMS address changed +- Fix missing Kodi tags for movie collections/sets + +version 2.12.6: - Fix rare KeyError when using PKC widgets - Fix suspension of artwork caching and PKC becoming unresponsive - Update translations diff --git a/changelog.txt b/changelog.txt index a4500090..2303fa62 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +version 2.12.7 (beta only): +- Fix PKC suddenly using main Plex user's credentials, e.g. when the PMS address changed +- Fix missing Kodi tags for movie collections/sets + version 2.12.6: - Fix rare KeyError when using PKC widgets - Fix suspension of artwork caching and PKC becoming unresponsive From aac16f38b3676d23684917ed933342ef072d8c35 Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 9 Jan 2021 17:09:10 +0100 Subject: [PATCH 5/6] Fix missing Kodi tags for movie collections/sets --- resources/lib/itemtypes/movies.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/lib/itemtypes/movies.py b/resources/lib/itemtypes/movies.py index 915d9497..d9bc18e5 100644 --- a/resources/lib/itemtypes/movies.py +++ b/resources/lib/itemtypes/movies.py @@ -195,9 +195,10 @@ class Movie(ItemBase): return True def _process_collections(self, api, tags, kodi_id, section_id, children): + for _, set_name in api.collections(): + tags.append(set_name) for plex_set_id, set_name in api.collections(): set_api = None - tags.append(set_name) # Add any sets from Plex collection tags kodi_set_id = self.kodidb.create_collection(set_name) self.kodidb.assign_collection(kodi_set_id, kodi_id) From 86dab2ab66c8cb6b7ef6e3ee08162a518e7dba9b Mon Sep 17 00:00:00 2001 From: croneter Date: Mon, 11 Jan 2021 16:21:37 +0100 Subject: [PATCH 6/6] Beta and stable version bump 2.12.8 --- addon.xml | 7 +++++-- changelog.txt | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/addon.xml b/addon.xml index 97bbfbb8..d3bf488d 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + @@ -83,7 +83,10 @@ Natūralioji „Plex“ integracija į „Kodi“ Prijunkite „Kodi“ prie „Plex Medija Serverio“. Šiame papildinyje daroma prielaida, kad valdote visus savo vaizdo įrašus naudodami „Plex“ (ir nė vieno su „Kodi“). Galite prarasti jau saugomus „Kodi“ vaizdo įrašų ir muzikos duomenų bazių duomenis (kadangi šis papildinys juos tiesiogiai pakeičia). Naudokite savo pačių rizika! Naudokite savo pačių rizika - version 2.12.7 (beta only): + version 2.12.8: +- version 2.12.7 for everyone + +version 2.12.7 (beta only): - Fix PKC suddenly using main Plex user's credentials, e.g. when the PMS address changed - Fix missing Kodi tags for movie collections/sets diff --git a/changelog.txt b/changelog.txt index 2303fa62..74cf417e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +version 2.12.8: +- version 2.12.7 for everyone + version 2.12.7 (beta only): - Fix PKC suddenly using main Plex user's credentials, e.g. when the PMS address changed - Fix missing Kodi tags for movie collections/sets