def getAddonInfo(self, infoId):
"""
--Returns the value of an addon property as a string.
infoId : string - id of the property that the module needs to access.
*Note, choices are (author, changelog, description, disclaimer, fanart. icon, id, name, path profile, stars, summary, type, version)
example:
- version = self.Addon.getAddonInfo('version')
"""
infoId = infoId.lower()
pathDir = xbmc.translatePath(self.addonPath)
if not os.path.exists(pathDir):
xbmc.log('The path ' + pathDir + 'for addon ' + self.addonId + 'dosen\'t exists', xbmc.LOGFATAL)
return ''
if infoId in ['changelog', 'fanart', 'icon', 'path', 'profile']:
if infoId == 'changelog': return os.path.join(pathDir, 'changelog.txt')
elif infoId == 'fanart': return os.path.join(pathDir, 'fanart.jpg')
elif infoId == 'icon': return os.path.join(pathDir, 'icon.png')
elif infoId == 'path': return pathDir
elif infoId == 'profile': return 'special://profile/addon_data/' + self.addonId + '/'
addonXmlFile = os.path.join(pathDir, 'addon.xml')
if not os.path.exists(addonXmlFile): return None
if infoId == 'author': infoId = 'provider-name'
attributes = ['id', 'version', 'name', 'provider-name']
root = self._parseXml(addonXmlFile)
if infoId in attributes: return root.attrib.get(infoId, None)
if infoId == 'type': infoId = 'point'
if infoId in ['point', 'library']:
for extension in root.iter('extension'):
if 'library' not in extension.attrib: continue
ret = extension.attrib.get(infoId, None)
break
else:
ret = None
return ret
metadata = ['summary', 'description', 'disclaimer', 'platform',
'supportedcontent', 'language', 'license', 'forum',
'website', 'source', 'email']
if infoId in metadata:
metadataInfo = root.find('./extension/{}'.format(infoId))
if metadataInfo is not None: return metadataInfo.text
return ''
if infoId == 'requires':
modList = []
for animp in root.findall('./requires/import'):
modList.append(animp.attrib)
return modList
if infoId == 'stars': return '0'
评论列表
文章目录