Merge pull request #1347 from lrusak/kodi-xml

merge xml files during installation of kodi
This commit is contained in:
MilhouseVH 2017-03-14 18:18:54 +00:00 committed by GitHub
commit 24e804e7da
13 changed files with 99 additions and 100 deletions

View File

@ -1,19 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<advancedsettings>
<showexitbutton>false</showexitbutton>
<remotedelay>1</remotedelay>
<cputempcommand>cputemp</cputempcommand>
<gputempcommand>gputemp</gputempcommand>
<video>
<latency>
<delay>0</delay>
<refresh>
<min>23</min>
<max>24</max>
<delay>175</delay>
</refresh>
</latency>
</video>
<samba>
<clienttimeout>30</clienttimeout>
</samba>

View File

@ -292,39 +292,27 @@ post_makeinstall_target() {
$SED "s|@ADDON_URL@|http://lrusak.libreelec.tv/addons/$ADDON_PATH|g" $INSTALL/usr/share/kodi/addons/repository.retroplayer.libreelec.tv/addon.xml
mkdir -p $INSTALL/usr/share/kodi/config
cp $PKG_DIR/config/guisettings.xml $INSTALL/usr/share/kodi/config
cp $PKG_DIR/config/sources.xml $INSTALL/usr/share/kodi/config
# install project specific configs
if [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/kodi/guisettings.xml ]; then
cp -R $PROJECT_DIR/$PROJECT/devices/$DEVICE/kodi/guisettings.xml $INSTALL/usr/share/kodi/config
elif [ -f $PROJECT_DIR/$PROJECT/kodi/guisettings.xml ]; then
cp -R $PROJECT_DIR/$PROJECT/kodi/guisettings.xml $INSTALL/usr/share/kodi/config
fi
if [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/kodi/sources.xml ]; then
cp -R $PROJECT_DIR/$PROJECT/devices/$DEVICE/kodi/sources.xml $INSTALL/usr/share/kodi/config
elif [ -f $PROJECT_DIR/$PROJECT/kodi/sources.xml ]; then
cp -R $PROJECT_DIR/$PROJECT/kodi/sources.xml $INSTALL/usr/share/kodi/config
fi
mkdir -p $INSTALL/usr/share/kodi/system/
if [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/kodi/advancedsettings.xml ]; then
cp $PROJECT_DIR/$PROJECT/devices/$DEVICE/kodi/advancedsettings.xml $INSTALL/usr/share/kodi/system/
elif [ -f $PROJECT_DIR/$PROJECT/kodi/advancedsettings.xml ]; then
cp $PROJECT_DIR/$PROJECT/kodi/advancedsettings.xml $INSTALL/usr/share/kodi/system/
else
cp $PKG_DIR/config/advancedsettings.xml $INSTALL/usr/share/kodi/system/
fi
mkdir -p $INSTALL/usr/share/kodi/system/settings
if [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/kodi/appliance.xml ]; then
cp $PROJECT_DIR/$PROJECT/devices/$DEVICE/kodi/appliance.xml $INSTALL/usr/share/kodi/system/settings
elif [ -f $PROJECT_DIR/$PROJECT/kodi/appliance.xml ]; then
cp $PROJECT_DIR/$PROJECT/kodi/appliance.xml $INSTALL/usr/share/kodi/system/settings
else
cp $PKG_DIR/config/appliance.xml $INSTALL/usr/share/kodi/system/settings
fi
$PKG_DIR/scripts/xml_merge.py $PKG_DIR/config/guisettings.xml \
$PROJECT_DIR/$PROJECT/kodi/guisettings.xml
$PROJECT_DIR/$PROJECT/devices/$DEVICE/kodi/guisettings.xml \
> $INSTALL/usr/share/kodi/config/guisettings.xml
$PKG_DIR/scripts/xml_merge.py $PKG_DIR/config/sources.xml \
$PROJECT_DIR/$PROJECT/kodi/sources.xml
$PROJECT_DIR/$PROJECT/devices/$DEVICE/kodi/sources.xml \
> $INSTALL/usr/share/kodi/config/sources.xml
$PKG_DIR/scripts/xml_merge.py $PKG_DIR/config/advancedsettings.xml \
$PROJECT_DIR/$PROJECT/kodi/advancedsettings.xml
$PROJECT_DIR/$PROJECT/devices/$DEVICE/kodi/advancedsettings.xml \
> $INSTALL/usr/share/kodi/system/advancedsettings.xml
$PKG_DIR/scripts/xml_merge.py $PKG_DIR/config/appliance.xml \
$PROJECT_DIR/$PROJECT/kodi/appliance.xml
$PROJECT_DIR/$PROJECT/devices/$DEVICE/kodi/appliance.xml \
> $INSTALL/usr/share/kodi/system/settings/appliance.xml
# update addon manifest
ADDON_MANIFEST=$INSTALL/usr/share/kodi/system/addon-manifest.xml

View File

@ -0,0 +1,51 @@
#!/usr/bin/env python2
# taken from http://stackoverflow.com/a/14879370 with minor modifications
import os
import sys
import xml.dom.minidom
from xml.etree import ElementTree as et
class XMLCombiner(object):
def __init__(self, filenames):
assert len(filenames) > 0, 'No filenames!'
self.roots = [et.parse(f).getroot() for f in filenames]
def prettyPrint(self, etree_xml):
minidom = xml.dom.minidom.parseString(et.tostring(etree_xml))
return "\n".join([line for line in minidom.toprettyxml(indent=" ", encoding="utf-8").split('\n') if line.strip() != ""])
def combine(self):
for r in self.roots[1:]:
self.combine_element(self.roots[0], r)
return self.prettyPrint(self.roots[0])
def combine_element(self, one, other):
mapping = {el.tag: el for el in one}
for el in other:
if len(el) == 0:
try:
mapping[el.tag].text = el.text
except KeyError:
mapping[el.tag] = el
one.append(el)
else:
try:
self.combine_element(mapping[el.tag], el)
except KeyError:
mapping[el.tag] = el
one.append(el)
if __name__ == '__main__':
try:
r = XMLCombiner([sys.argv[1], sys.argv[2], sys.argv[3]]).combine()
except IOError:
try:
r = XMLCombiner([sys.argv[1], sys.argv[2]]).combine()
except IOError:
try:
r = XMLCombiner([sys.argv[1], sys.argv[3]]).combine()
except IOError:
r = XMLCombiner([sys.argv[1]]).combine()
print(r)

View File

@ -0,0 +1,14 @@
<advancedsettings>
<cputempcommand>cputemp</cputempcommand>
<gputempcommand>gputemp</gputempcommand>
<video>
<latency>
<delay>0</delay>
<refresh>
<min>23</min>
<max>24</max>
<delay>175</delay>
</refresh>
</latency>
</video>
</advancedsettings>

View File

@ -0,0 +1,4 @@
<advancedsettings>
<cputempcommand>cputemp</cputempcommand>
<gputempcommand>gputemp</gputempcommand>
</advancedsettings>

View File

@ -1,12 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<advancedsettings>
<showexitbutton>false</showexitbutton>
<remotedelay>1</remotedelay>
<fanartres>720</fanartres>
<imageres>540</imageres>
<samba>
<clienttimeout>30</clienttimeout>
</samba>
</advancedsettings>

View File

@ -1,12 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<advancedsettings>
<showexitbutton>false</showexitbutton>
<remotedelay>1</remotedelay>
<fanartres>720</fanartres>
<imageres>540</imageres>
<samba>
<clienttimeout>30</clienttimeout>
</samba>
</advancedsettings>

View File

@ -1,9 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<advancedsettings>
<showexitbutton>false</showexitbutton>
<remotedelay>1</remotedelay>
<samba>
<clienttimeout>30</clienttimeout>
</samba>
<cputempcommand>cputemp</cputempcommand>
<gputempcommand>gputemp</gputempcommand>
</advancedsettings>

View File

@ -1,9 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<advancedsettings>
<showexitbutton>false</showexitbutton>
<remotedelay>1</remotedelay>
<samba>
<clienttimeout>30</clienttimeout>
</samba>
<cputempcommand>cputemp</cputempcommand>
<gputempcommand>gputemp</gputempcommand>
</advancedsettings>

View File

@ -1,9 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<advancedsettings>
<showexitbutton>false</showexitbutton>
<remotedelay>1</remotedelay>
<samba>
<clienttimeout>30</clienttimeout>
</samba>
<cputempcommand>cputemp</cputempcommand>
<gputempcommand>gputemp</gputempcommand>
</advancedsettings>

View File

@ -1,9 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<advancedsettings>
<showexitbutton>false</showexitbutton>
<remotedelay>1</remotedelay>
<samba>
<clienttimeout>30</clienttimeout>
</samba>
<cputempcommand>cputemp</cputempcommand>
<gputempcommand>gputemp</gputempcommand>
</advancedsettings>

View File

@ -1,8 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<advancedsettings>
<showexitbutton>false</showexitbutton>
<remotedelay>1</remotedelay>
<samba>
<clienttimeout>30</clienttimeout>
</samba>
<cputempcommand>cputemp</cputempcommand>
<gputempcommand>gputemp</gputempcommand>
</advancedsettings>

View File

@ -8,9 +8,4 @@
<audiooutput>
<audiodevice>ALSA:hdmi:CARD=imxhdmisoc,DEV=0</audiodevice>
</audiooutput>
<!--
<videoscreen>
<updateresolutions>false</updateresolutions>
</videoscreen>
-->
</settings>