Direct paths: Don't download PMS sections twice
This commit is contained in:
parent
87b22f1588
commit
f9121d281c
2 changed files with 13 additions and 21 deletions
|
@ -423,10 +423,6 @@ class LibrarySync(Thread):
|
||||||
"""
|
"""
|
||||||
Compare the views to Plex
|
Compare the views to Plex
|
||||||
"""
|
"""
|
||||||
if state.DIRECT_PATHS is True and state.ENABLE_MUSIC is True:
|
|
||||||
# Will reboot Kodi is new library detected
|
|
||||||
music.excludefromscan_music_folders()
|
|
||||||
|
|
||||||
self.views = []
|
self.views = []
|
||||||
vnodes = self.vnodes
|
vnodes = self.vnodes
|
||||||
|
|
||||||
|
@ -437,6 +433,9 @@ class LibrarySync(Thread):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
LOG.error("Error download PMS views, abort maintain_views")
|
LOG.error("Error download PMS views, abort maintain_views")
|
||||||
return False
|
return False
|
||||||
|
if state.DIRECT_PATHS is True and state.ENABLE_MUSIC is True:
|
||||||
|
# Will reboot Kodi is new library detected
|
||||||
|
music.excludefromscan_music_folders(xml=sections)
|
||||||
|
|
||||||
self.nodes = {
|
self.nodes = {
|
||||||
v.PLEX_TYPE_MOVIE: [],
|
v.PLEX_TYPE_MOVIE: [],
|
||||||
|
|
|
@ -4,7 +4,6 @@ from re import compile as re_compile
|
||||||
from xml.etree.ElementTree import ParseError
|
from xml.etree.ElementTree import ParseError
|
||||||
|
|
||||||
from utils import XmlKodiSetting, reboot_kodi, language as lang
|
from utils import XmlKodiSetting, reboot_kodi, language as lang
|
||||||
from PlexFunctions import get_plex_sections
|
|
||||||
from PlexAPI import API
|
from PlexAPI import API
|
||||||
import variables as v
|
import variables as v
|
||||||
|
|
||||||
|
@ -15,21 +14,15 @@ REGEX_MUSICPATH = re_compile(r'''^\^(.+)\$$''')
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
|
||||||
def excludefromscan_music_folders():
|
def excludefromscan_music_folders(xml):
|
||||||
"""
|
"""
|
||||||
Gets a complete list of paths for music libraries from the PMS. Sets them
|
Gets a complete list of paths for music libraries from the PMS. Sets them
|
||||||
to be excluded in the advancedsettings.xml from being scanned by Kodi.
|
to be excluded in the advancedsettings.xml from being scanned by Kodi.
|
||||||
Existing keys will be replaced
|
Existing keys will be replaced
|
||||||
|
xml: etree XML PMS answer containing all library sections
|
||||||
|
|
||||||
Reboots Kodi if new library detected
|
Reboots Kodi if new library detected
|
||||||
"""
|
"""
|
||||||
xml = get_plex_sections()
|
|
||||||
try:
|
|
||||||
xml[0].attrib
|
|
||||||
except (TypeError, IndexError, AttributeError):
|
|
||||||
LOG.error('Could not get Plex sections')
|
|
||||||
return
|
|
||||||
# Build paths
|
|
||||||
paths = []
|
paths = []
|
||||||
reboot = False
|
reboot = False
|
||||||
api = API(item=None)
|
api = API(item=None)
|
||||||
|
@ -46,8 +39,8 @@ def excludefromscan_music_folders():
|
||||||
try:
|
try:
|
||||||
with XmlKodiSetting('advancedsettings.xml',
|
with XmlKodiSetting('advancedsettings.xml',
|
||||||
force_create=True,
|
force_create=True,
|
||||||
top_element='advancedsettings') as xml:
|
top_element='advancedsettings') as xml_file:
|
||||||
parent = xml.set_setting(['audio', 'excludefromscan'])
|
parent = xml_file.set_setting(['audio', 'excludefromscan'])
|
||||||
for path in paths:
|
for path in paths:
|
||||||
for element in parent:
|
for element in parent:
|
||||||
if element.text == path:
|
if element.text == path:
|
||||||
|
@ -55,14 +48,15 @@ def excludefromscan_music_folders():
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
LOG.info('New Plex music library detected: %s', path)
|
LOG.info('New Plex music library detected: %s', path)
|
||||||
xml.set_setting(['audio', 'excludefromscan', 'regexp'],
|
xml_file.set_setting(['audio', 'excludefromscan', 'regexp'],
|
||||||
value=path, append=True)
|
value=path,
|
||||||
|
append=True)
|
||||||
if paths:
|
if paths:
|
||||||
# We only need to reboot if we ADD new paths!
|
# We only need to reboot if we ADD new paths!
|
||||||
reboot = xml.write_xml
|
reboot = xml_file.write_xml
|
||||||
# Delete obsolete entries
|
# Delete obsolete entries
|
||||||
# Make sure we're not saving an empty audio-excludefromscan
|
# Make sure we're not saving an empty audio-excludefromscan
|
||||||
xml.write_xml = reboot
|
xml_file.write_xml = reboot
|
||||||
for element in parent:
|
for element in parent:
|
||||||
for path in paths:
|
for path in paths:
|
||||||
if element.text == path:
|
if element.text == path:
|
||||||
|
@ -71,10 +65,9 @@ def excludefromscan_music_folders():
|
||||||
LOG.info('Deleting music library from advancedsettings: %s',
|
LOG.info('Deleting music library from advancedsettings: %s',
|
||||||
element.text)
|
element.text)
|
||||||
parent.remove(element)
|
parent.remove(element)
|
||||||
xml.write_xml = True
|
xml_file.write_xml = True
|
||||||
except (ParseError, IOError):
|
except (ParseError, IOError):
|
||||||
LOG.error('Could not adjust advancedsettings.xml')
|
LOG.error('Could not adjust advancedsettings.xml')
|
||||||
reboot = False
|
|
||||||
if reboot is True:
|
if reboot is True:
|
||||||
# 'New Plex music library detected. Sorry, but we need to
|
# 'New Plex music library detected. Sorry, but we need to
|
||||||
# restart Kodi now due to the changes made.'
|
# restart Kodi now due to the changes made.'
|
||||||
|
|
Loading…
Add table
Reference in a new issue