From 6b00eb466eb5e261e207b37ecfcea551f6d49437 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Thu, 4 Feb 2016 03:41:39 -0600 Subject: [PATCH] Adjust sources.xml switch to adding only smb:// as suggested on forums --- resources/lib/utils.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 7431c4a2..8da3c9d9 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -312,20 +312,21 @@ def sourcesXML(): etree.SubElement(video, 'default', attrib={'pathversion': "1"}) # Add elements - for i in range(1, 3): - - for source in root.findall('.//path'): - if source.text == "smb://embydummy/dummypath%s/" % i: - # Already there, skip - break - else: - source = etree.SubElement(video, 'source') - etree.SubElement(source, 'name').text = "Emby" - etree.SubElement(source, 'path', attrib={'pathversion': "1"}).text = ( - - "smb://embydummy/dummypath%s/" % i - ) - etree.SubElement(source, 'allowsharing').text = "true" + count = 2 + for source in root.findall('.//path'): + if source.text == "smb://": + count -= 1 + + if count == 0: + # sources already set + break + else: + # Missing smb:// occurences, re-add. + for i in range(0, count): + source = etree.SubElement(video, 'source') + etree.SubElement(source, 'name').text = "Emby" + etree.SubElement(source, 'path', attrib={'pathversion': "1"}).text = "smb://" + etree.SubElement(source, 'allowsharing').text = "true" # Prettify and write to file try: indent(root)