Fix Kodi library being empty for PKC direct paths if Masterlock has been activated
This commit is contained in:
parent
72b6a3fb7c
commit
bb782a5deb
2 changed files with 50 additions and 40 deletions
|
@ -5,7 +5,6 @@ from logging import getLogger
|
||||||
from xbmc import executebuiltin
|
from xbmc import executebuiltin
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
import xml.etree.ElementTree as etree
|
|
||||||
from . import path_ops
|
from . import path_ops
|
||||||
from . import migration
|
from . import migration
|
||||||
from .downloadutils import DownloadUtils as DU, exceptions
|
from .downloadutils import DownloadUtils as DU, exceptions
|
||||||
|
@ -14,6 +13,7 @@ from . import plex_tv
|
||||||
from . import json_rpc as js
|
from . import json_rpc as js
|
||||||
from . import app
|
from . import app
|
||||||
from . import variables as v
|
from . import variables as v
|
||||||
|
from . import sources
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
@ -454,31 +454,6 @@ class InitialSetup(object):
|
||||||
server['machineIdentifier'], server['ip'], server['port'],
|
server['machineIdentifier'], server['ip'], server['port'],
|
||||||
server['scheme'])
|
server['scheme'])
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _add_sources(root, extension):
|
|
||||||
changed = False
|
|
||||||
count = 2
|
|
||||||
for source in root.findall('.//path'):
|
|
||||||
if source.text == extension:
|
|
||||||
count -= 1
|
|
||||||
if count == 0:
|
|
||||||
# sources already set
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
# Missing smb:// occurences, re-add.
|
|
||||||
changed = True
|
|
||||||
for _ in range(0, count):
|
|
||||||
source = etree.SubElement(root, 'source')
|
|
||||||
etree.SubElement(
|
|
||||||
source,
|
|
||||||
'name').text = "PlexKodiConnect Masterlock Hack"
|
|
||||||
etree.SubElement(
|
|
||||||
source,
|
|
||||||
'path',
|
|
||||||
{'pathversion': "1"}).text = extension
|
|
||||||
etree.SubElement(source, 'allowsharing').text = "true"
|
|
||||||
return changed
|
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""
|
"""
|
||||||
Initial setup. Run once upon startup.
|
Initial setup. Run once upon startup.
|
||||||
|
@ -520,20 +495,7 @@ class InitialSetup(object):
|
||||||
LOG.info('Current Kodi video memory cache in bytes: %s', cache)
|
LOG.info('Current Kodi video memory cache in bytes: %s', cache)
|
||||||
utils.settings('kodi_video_cache', value=cache)
|
utils.settings('kodi_video_cache', value=cache)
|
||||||
|
|
||||||
# Hack to make PKC Kodi master lock compatible
|
reboot = sources.pkc_sources_hack() or reboot
|
||||||
try:
|
|
||||||
with utils.XmlKodiSetting('sources.xml',
|
|
||||||
force_create=True,
|
|
||||||
top_element='sources') as xml:
|
|
||||||
changed = False
|
|
||||||
for extension in ('smb://', 'nfs://'):
|
|
||||||
root = xml.set_setting(['video'])
|
|
||||||
changed = self._add_sources(root, extension) or changed
|
|
||||||
if changed:
|
|
||||||
xml.write_xml = True
|
|
||||||
reboot = True
|
|
||||||
except utils.ParseError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Do we need to migrate stuff?
|
# Do we need to migrate stuff?
|
||||||
migration.check_migration()
|
migration.check_migration()
|
||||||
|
|
48
resources/lib/sources.py
Normal file
48
resources/lib/sources.py
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import xml.etree.ElementTree as etree
|
||||||
|
|
||||||
|
from . import utils
|
||||||
|
|
||||||
|
|
||||||
|
def pkc_sources_hack():
|
||||||
|
# Hack to make PKC Kodi master lock compatible
|
||||||
|
try:
|
||||||
|
with utils.XmlKodiSetting('sources.xml',
|
||||||
|
force_create=True,
|
||||||
|
top_element='sources') as xml:
|
||||||
|
changed = False
|
||||||
|
for extension in ('smb://', 'nfs://'):
|
||||||
|
root = xml.set_setting(['video'])
|
||||||
|
changed = add_source(root, extension) or changed
|
||||||
|
if changed:
|
||||||
|
xml.write_xml = True
|
||||||
|
except utils.ParseError:
|
||||||
|
pass
|
||||||
|
return changed
|
||||||
|
|
||||||
|
|
||||||
|
def add_source(root, source_path):
|
||||||
|
changed = False
|
||||||
|
# Originally, 2 sources were necessary for the PKC Masterlock Hack
|
||||||
|
count = 1
|
||||||
|
for source in root.findall('.//path'):
|
||||||
|
if source.text == source_path:
|
||||||
|
count -= 1
|
||||||
|
if count == 0:
|
||||||
|
# sources already set
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
# Missing smb:// occurences, re-add.
|
||||||
|
changed = True
|
||||||
|
for _ in range(0, count):
|
||||||
|
source = etree.SubElement(root, 'source')
|
||||||
|
etree.SubElement(
|
||||||
|
source,
|
||||||
|
'name').text = "PlexKodiConnect Masterlock Hack"
|
||||||
|
etree.SubElement(
|
||||||
|
source,
|
||||||
|
'path',
|
||||||
|
{'pathversion': "1"}).text = source_path
|
||||||
|
etree.SubElement(source, 'allowsharing').text = "true"
|
||||||
|
return changed
|
Loading…
Reference in a new issue