XBMC插件python代码保存到收藏夹favourites.xml

XBMC插件python代码保存到收藏夹favourites.xml

首先favourites.xml的位置在userdata目录http://wiki.xbmc.org/?title=Userdata,在Python中设定xbmc.translatePath(“special://profile//favourites.xml”)

收藏夹文件favourites.xml的内容例子见http://wiki.xbmc.org/index.php?title=Favourites.xml

在python中保存此文件

from xml.dom.minidom import Document

doc = Document()
favourites = doc.createElement(‘favourites’)
doc.appendChild(favourites)
for each in favtree.findAll(‘favourite’):
favourite = doc.createElement(‘favourite’)
favourite.setAttribute(‘name’,’名字’)
favourite.setAttribute(‘thumb’,’TestThumb’)
favourite_text = doc.createTextNode(‘PlayMedia(“播放地址””)’)
favourite.appendChild(favourite_text)
favourites.appendChild(favourite)
f = open(FAVORITES_SAVETO, “w”)
f.write(doc.toprettyxml(indent = ”))
f.close()

另外也可以调用接口去改,不过貌似没找到,只找到一个Json的接口,待跟进

(1216)

1 thought on “XBMC插件python代码保存到收藏夹favourites.xml”

发表评论

This site uses Akismet to reduce spam. Learn how your comment data is processed.