From 4797b1a3b78a9d54816d36e5a7e63bff43aaf34b Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Mon, 26 Sep 2016 22:20:44 -0700 Subject: [PATCH] Add new librarys to homepage automatically --- plexpy/pmsconnect.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index e06eee3e..3bd3a8f6 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -62,6 +62,7 @@ def refresh_libraries(): monitor_db = database.MonitorDatabase() library_keys = [] + new_keys = [] for section in library_sections: section_keys = {'server_id': server_id, @@ -77,13 +78,20 @@ def refresh_libraries(): 'child_count': section.get('child_count', None), } - monitor_db.upsert('library_sections', key_dict=section_keys, value_dict=section_values) + result = monitor_db.upsert('library_sections', key_dict=section_keys, value_dict=section_values) library_keys.append(section['section_id']) + if result == 'insert': + new_keys.append(section['section_id']) + if plexpy.CONFIG.HOME_LIBRARY_CARDS == ['first_run_wizard']: plexpy.CONFIG.__setattr__('HOME_LIBRARY_CARDS', library_keys) plexpy.CONFIG.write() + else: + new_keys = plexpy.CONFIG.HOME_LIBRARY_CARDS + new_keys + plexpy.CONFIG.__setattr__('HOME_LIBRARY_CARDS', new_keys) + plexpy.CONFIG.write() if plexpy.CONFIG.UPDATE_SECTION_IDS == 1 or plexpy.CONFIG.UPDATE_SECTION_IDS == -1: # Start library section_id update on it's own thread