From eb1214f0c721c2a03677ae83f68e4b5c8d55c43b Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 14 Apr 2019 14:20:03 +0200 Subject: [PATCH 1/6] New setting to reloade Plex video nodes --- default.py | 4 +++ .../resource.language.en_gb/strings.po | 5 +++ resources/lib/library_sync/sections.py | 15 +++++++++ resources/lib/service_entry.py | 31 +++++++++++++++++++ resources/settings.xml | 2 ++ 5 files changed, 57 insertions(+) diff --git a/default.py b/default.py index b4483c4c..131c923a 100644 --- a/default.py +++ b/default.py @@ -138,6 +138,10 @@ class Main(): LOG.info('User requested to select Plex libraries') transfer.plex_command('select-libraries') + elif mode == 'refreshplaylist': + LOG.info('User requested to refresh Kodi playlists and nodes') + transfer.plex_command('refreshplaylist') + else: entrypoint.show_main_menu(content_type=params.get('content_type')) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index ba4650ea..69dc13e1 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -1102,6 +1102,11 @@ msgctxt "#39084" msgid "Enter PMS port" msgstr "" +# PKC settings - Appearance Tweaks +msgctxt "#39085" +msgid "Reload Kodi node files to apply all the settings below" +msgstr "" + msgctxt "#39200" msgid "Log-out Plex Home User " msgstr "" diff --git a/resources/lib/library_sync/sections.py b/resources/lib/library_sync/sections.py index b37a32f4..f08a32f3 100644 --- a/resources/lib/library_sync/sections.py +++ b/resources/lib/library_sync/sections.py @@ -644,7 +644,22 @@ def clear_window_vars(): """ Removes all references to sections stored in window vars 'Plex.nodes...' """ + LOG.info('Clearing all the Plex video node variables') number_of_nodes = int(utils.window('Plex.nodes.total') or 0) utils.window('Plex.nodes.total', clear=True) for index in range(number_of_nodes): _clear_window_vars(index) + + +def delete_videonode_files(): + """ + Removes all the PKC video node files under userdata/library/video that + start with 'Plex-' + """ + for root, dirs, _ in path_ops.walk(LIBRARY_PATH): + for directory in dirs: + if directory.startswith('Plex-'): + abs_path = path_ops.path.join(root, directory) + LOG.info('Removing video node directory %s', abs_path) + path_ops.rmtree(abs_path, ignore_errors=True) + break diff --git a/resources/lib/service_entry.py b/resources/lib/service_entry.py index fa929595..a1243e93 100644 --- a/resources/lib/service_entry.py +++ b/resources/lib/service_entry.py @@ -302,6 +302,35 @@ class Service(object): finally: app.APP.resume_threads() + def reset_playlists_and_nodes(self): + """ + Resets the Kodi playlists and nodes for all the PKC libraries by + deleting all of them first, then rewriting everything + """ + app.APP.suspend_threads() + from .library_sync import sections + try: + sections.clear_window_vars() + sections.delete_videonode_files() + # Get newest sections from the PMS + if not sections.sync_from_pms(self, pick_libraries=False): + LOG.warn('We could not successfully reset the playlists!') + # "Plex playlists/nodes refresh failed" + utils.dialog('notification', + utils.lang(29999), + utils.lang(39406), + icon='{plex}', + sound=False) + return + # "Plex playlists/nodes refreshed" + utils.dialog('notification', + utils.lang(29999), + utils.lang(39405), + icon='{plex}', + sound=False) + finally: + app.APP.resume_threads() + def _do_auth(self): LOG.info('Authenticating user') if app.ACCOUNT.plex_username and not app.ACCOUNT.force_login: # Found a user in the settings, try to authenticate @@ -449,6 +478,8 @@ class Service(object): app.SYNC.run_lib_scan = 'textures' elif plex_command == 'select-libraries': self.choose_plex_libraries() + elif plex_command == 'refreshplaylist': + self.reset_playlists_and_nodes() elif plex_command == 'RESET-PKC': utils.reset() elif plex_command == 'EXIT-PKC': diff --git a/resources/settings.xml b/resources/settings.xml index d1fc8f1e..b68c8bfe 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -157,6 +157,8 @@ --> + + From 5263f49c464a0459db67621258b847b335e013a1 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 14 Apr 2019 14:23:51 +0200 Subject: [PATCH 2/6] Remove obsolete setting: Extend Plex TV Series "On Deck" --- resources/language/resource.language.en_gb/strings.po | 5 ----- resources/settings.xml | 1 - 2 files changed, 6 deletions(-) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 69dc13e1..d6fa5d19 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -971,11 +971,6 @@ msgctxt "#39057" msgid "Customize Paths" msgstr "" -# PKC Settings - Appearance Tweaks -msgctxt "#39058" -msgid "Extend Plex TV Series \"On Deck\" view to all shows" -msgstr "" - # PKC Settings - Appearance Tweaks msgctxt "#39059" msgid "Recently Added: Append show title to episode" diff --git a/resources/settings.xml b/resources/settings.xml index b68c8bfe..ae18dcbc 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -162,7 +162,6 @@ - From 5cc67f41e1da0ee27f7806347935db1c9848d732 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 14 Apr 2019 14:41:14 +0200 Subject: [PATCH 3/6] Reenable setting: recently added: don't show watched episodes --- resources/lib/library_sync/nodes.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/resources/lib/library_sync/nodes.py b/resources/lib/library_sync/nodes.py index 0203e964..c90992f3 100644 --- a/resources/lib/library_sync/nodes.py +++ b/resources/lib/library_sync/nodes.py @@ -252,6 +252,13 @@ def node_recent(section, node_name): rule = etree.SubElement(xml, 'rule', attrib={'field': 'tag', 'operator': 'is'}) etree.SubElement(rule, 'value').text = section.name + if (section.section_type == v.PLEX_TYPE_SHOW and + utils.settings('TVShowWatched') == 'false'): + # Adds an additional rule if user deactivated the PKC setting + # "Recently Added: Also show already watched episodes" + rule = etree.SubElement(xml, 'rule', attrib={'field': 'playcount', + 'operator': 'is'}) + etree.SubElement(rule, 'value').text = '0' etree.SubElement(xml, 'label').text = node_name etree.SubElement(xml, 'icon').text = ICON_PATH etree.SubElement(xml, 'content').text = section.content From b22ae7aee49ba48a60c699dacd1160f75607ee82 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 14 Apr 2019 14:45:42 +0200 Subject: [PATCH 4/6] Don't show old setting "Number of PMS items to show in widgets" --- resources/settings.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/settings.xml b/resources/settings.xml index ae18dcbc..79212504 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -159,8 +159,7 @@ - - + From 15c4da46a985ebe5d6043bf362c9312a5ee109da Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 14 Apr 2019 14:49:44 +0200 Subject: [PATCH 5/6] Reenable setting: recently added: don't show watched movies --- resources/lib/library_sync/nodes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/resources/lib/library_sync/nodes.py b/resources/lib/library_sync/nodes.py index c90992f3..a30ac047 100644 --- a/resources/lib/library_sync/nodes.py +++ b/resources/lib/library_sync/nodes.py @@ -252,10 +252,14 @@ def node_recent(section, node_name): rule = etree.SubElement(xml, 'rule', attrib={'field': 'tag', 'operator': 'is'}) etree.SubElement(rule, 'value').text = section.name - if (section.section_type == v.PLEX_TYPE_SHOW and - utils.settings('TVShowWatched') == 'false'): + if ((section.section_type == v.PLEX_TYPE_SHOW and + utils.settings('TVShowWatched') == 'false') or + (section.section_type == v.PLEX_TYPE_MOVIE and + utils.settings('MovieShowWatched') == 'false')): # Adds an additional rule if user deactivated the PKC setting # "Recently Added: Also show already watched episodes" + # or + # "Recently Added: Also show already watched episodes" rule = etree.SubElement(xml, 'rule', attrib={'field': 'playcount', 'operator': 'is'}) etree.SubElement(rule, 'value').text = '0' From b6f2a23622f82d433c45ba541ad8d34ae4dab193 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 14 Apr 2019 14:50:43 +0200 Subject: [PATCH 6/6] Shorten string --- resources/language/resource.language.en_gb/strings.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index d6fa5d19..b4a82a8b 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -1008,7 +1008,7 @@ msgstr "" # PKC Settings - Appearance Tweaks msgctxt "#39066" -msgid "Recently Added: Also show already watched movies (Refresh Plex playlist/nodes!)" +msgid "Recently Added: Also show already watched movies" msgstr "" # PKC Settings - Connection