XBMC插件addon.xml编写说明

来源:互联网 发布:python 入门书籍推荐 编辑:程序博客网 时间:2024/05/17 03:57

XBMC插件addon.xml编写说明

翻译自http://wiki.xbmc.org/index.php?title=Addon.xml ,不完全翻译。

 

 

====================================

 

 

1. 引言

XBMC每一个皮肤或脚本(或插件)都要包含一个addon.xml文件,它会设置扩展的总体信息(开发人员,版本信息和依赖库)。下面我们会讲解如何书写一个这样的文件,另外会给出皮肤和脚本(插件)版本的不同。

 

 

2. 总体结构

Addon.xml有以下需要注意的:

l 必须出现<addon>标签,它是整个文件的顶层标签。

l <addon>标签中包含<requires>标签,它列出这个扩展运行所需的组件。

l 然后有一个或多个<extension>标签,每一个标签都会说明扩充的功能。

l 最后,有一个特别的<extension>标签为用户描述这个扩展的整体信息。

必须包含的内容

<addon> 标签

有四个属性:idversionnameprovider-name

标签名

说明

id

该扩展的唯一标识,必须独一无二,并且必须由小写字符、点号、下划线、破折线和数字组成,XBMC将把它的名字作为目录名,因此建议写成<类型>.<标识符>的形式。

version

写成X.Y.Z(主版本号.次版本号.补丁号)的形式。一般来讲,进行测试开发时写为0.y.z形式,正式发布时为1.0.0的形式。只有在beta版或发布版才使用字母,其他情况下应只包含数字。

name

扩展在XBMC界面中显示的名字。注意它必须是英文,而且不能被翻译。

Provider-name

该信息出现在“开发者”一栏中,可以是独立开发者也可以是一个团队,如果有多人开发,使用逗号隔开。

示例:<addon id="script.hello.world" name="Hello World" version="0.0.1" provider-name="Dev1, Dev2">


<requires>标签

包含一个或多个<import>标签,它表示这个扩展所需要的其他扩展的名称和版本号。这些扩展可以是XBMC本身的一部分,也可以是第三方扩展。XBMC只会运行那些依赖正确的扩展,即版本号正确。当用户从仓库中安装你的扩展时,XBMC会试图解析依赖,安装依赖的扩展。必须提供依赖正确的最低版本号。

当设置optional属性为true时将使对应的扩展为可选,这将会在真正需要它的时候再安装。如果依赖丢失,依赖的扩展仍然会被安装。

如果你的扩展依赖于第三方模块,必须由用户先安装后者再安装前者。如果在已知仓库中存在,则XBMC会自动安装,否则需要你在代码中自行获取,因为XBMC不知道在<requires>中做什么。

示例:

    <requires>

      <import addon="xbmc.python"                 version="2.1.0"/>

      <import addon="script.module.elementtree"   version="1.2.7"/>

      <import addon="script.module.simplejson"    version="2.0.10" optional="true"/>

    </requires>

下面的扩展只会在OPENELEC上安装:

    </requires>

        <import addon="os.openelec.tv" version="2.0" optional="false"/>

    </requires>

可选的标签:

    <import addon="script.module.simplejson"    version="2.0.10" optional="true"/>

 

依赖版本

每个版本的XBMC主程序需要的最低扩展版本不同,如下:

XBMC version

xbmc.python

xbmc.gui

xbmc.json

xbmc.metadata

xbmc.addon

Dharma 10.1 Deprecated

1.0

2.11

2.0

1.0

0.1

Eden 11.0

2.0

3.0

4.0

1.0

11.0

Frodo 12.0 & 12.1 & 12.2

2.1.0

4.0.0

6.0.0

2.1.0

12.0.0

Gotham 13.0

2.1.0

5.0.0

6.0.0

2.1.0

12.0.0

 <extension> 标签

该标签描述这个扩展的技术信息。所有的标签内容如下所示:

Extension point

Addon Category

xbmc.gui.skin

Skin

xbmc.gui.webinterface

Web interface

xbmc.addon.repository

<None>

xbmc.service

Services

xbmc.metadata.scraper.albums

Album information

xbmc.metadata.scraper.artists

Artist information

xbmc.metadata.scraper.movies

Movie information

xbmc.metadata.scraper.musicvideos

Music video information

xbmc.metadata.scraper.tvshows

TV information

xbmc.metadata.scraper.library

<None>

xbmc.ui.screensaver

Screensaver

xbmc.player.musicviz

Visualization

xbmc.python.pluginsource

Music Add-ons (audio) / Picture Add-ons (image) / Program Add-ons (executable) / Video Add-ons (video)

xbmc.python.script

Music Add-ons (audio) / Picture Add-ons (image) / Program Add-ons (executable) / Video Add-ons (video)

xbmc.python.weather

Weather

xbmc.python.subtitles

Subtitles

xbmc.python.lyrics

Lyrics

xbmc.python.library

<None>

xbmc.python.module

<None>

xbmc.addon.video

<None>

xbmc.addon.audio

<None>

xbmc.addon.image

<None>

如果扩展不属于上述类别,则不能被用户直接安装,而是由需要它们的其他扩展来安装。

Xbmc.python.pluginsource标签

最常用的extension<extension point="xbmc.python.pluginsource">标签有一个library属性,它是插件启动时的脚本名称,必须存在于扩展主目录下。该extension还有一个子标签<provides>,它是一个由空格分隔的列表,包括图像、视频、音频和可执行文件。它将决定该扩展出现在哪个类别中。

image => Pictures

video => Video

audio => Music

executable => Programs

<blank> => No visible presence

例如:

    <extension point="xbmc.python.pluginsource" library="gpodderxbmc.py">

        <provides>audio video</provides>

    </extension>

 

Xbmc.addon.metadata标签

This special extension point must be provided by all add-ons, and is the way that your add-on is described to users of the XBMC add-on manager.

每个扩展都要包含这个标签,它为XBMC扩展管理器提供信息。

需要的信息

包含一系列必需的标签,至少应该有英文表述:

summary属性可以有一个或多个,用来说明该扩展的用途。必须是单句。可以使用lang=”ch”来翻译成其他文字。如:

<summary lang="en">Hello World script provides some basic examples on how to create your first script.</summary>

 

一个或多个description标签提供扩展更详细的细处。也可以翻译成其他语言。如:

<description lang="en">Hello World script provides some basic examples on how to create your first script

 and hopefully will increase the number of XBMC users to start creating their own addons.</description>

 

一个或多个disclaimer标签用来向用户说明一些额外信息,可以没有。如:

<disclaimer lang="en">Feel free to use this script. For information visit the wiki.</disclaimer>

 

Platform标签用来表示在哪些平台(包括操作系统和硬件平台)上运行。默认为all即全平台运行。可以使用的选项有:

all

linux

osx

osx64

osx32

ios

windx

wingl

android

如:

<platform>all</platform>

 

Language标签。说明在内容中的语言,可以使用在插件、脚本或削刮器中。可以为空。

List of language codes (ISO-639:1988)

    <language>en de fr</language>

    或:

    <language></language>

 

Broken标签。表示在XBMC插件仓库中为不完整。如:

    <broken>deprecated</broken>

附加信息

 

License标签:使用的许可证。

    <license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license>

Forum标签,表明相关的论坛。

    <forum>put URL here</forum>

Website标签,表明相关网站。

    <website>put URL here</website>

Source标签:源代码地址。

    <source>put URL here</source>

 

E-mail标签:作者的电子邮箱地址。可以使用以下两种格式:

    <email>foo@bar.com</email>

    <email>foo at bar dot com</email>

皮肤插件中的特别项目

概览

defaultresolution

皮肤的默认分辨率。

defaultresolutionwide

默认的宽屏(1080i, 720p, 480p 16x9, NTSC 16x9 and PAL 16x9)分辨率。如果没有该文件,则使用<defaultresolution>文件夹。

defaultthemename

默认主题名称,目前设为default

effectslowdown

A multiplier that is applied to all <animation> effect lengths in the skin. Useful to slow down all animations globally so that you can better configure timings and see interactions between animating controls.

debugging

When set to true, it'll display onscreen debug information (xml filename, mouse position and focused control type and name) in the skin.

res

Support for arbitrary skin resolutions.

2.2.2 How window xml files are found

XBMC can run in many differing resolutions, and a skin should try and cater to all these resolutions. The easiest way is to develop for one specific resolution and make sure that all controls contain <width> and <height> tags. That way, XBMC can scale the controls to the new screen resolution.

However, you may choose to develop alternative window xml files for differing resolutions (such as for HDTV resolutions, or for widescreen versus 4x3 resolutions).

The order that XBMC looks for it's skin files are as follows:

It first looks in the current screenmode folder (one of 1080i, 720p, NTSC16x9, NTSC, PAL16x9 or PAL)

If the current screenmode is 1080i, it then looks in the 720p folder.

If the current screenmode is a widescreen mode (1080i, 720p, NTSC16x9, PAL16x9) then it looks in the <defaultresolutionwide> folder.

Finally, it looks in the <defaultresolution> folder.

This allows you to just put any window files that do not require special treatment for 16x9 resolutions etc. in the <defaultresolution> folder, preventing needless repetition.

 

script/plugin扩展的特别项目

未加入

 

3. addon.xml示例

皮肤扩展的addon.xml

<?xml version="1.0" encoding="UTF-8"?>

<addon

  id="skin.confluence"

  version="2.1.3"

  name="Confluence"

  provider-name="Jezz_X|Team XBMC">

  <requires>

    <import addon="xbmc.gui" version="4.0.0"/>

  </requires>

  <extension

    point="xbmc.gui.skin"

    defaultthemename="textures.xbt"

    debugging="false"

    effectslowdown="0.75">

    <res width="1280" height="720" aspect="16:9" default="true" folder="720p" />

  </extension>

  <extension point="xbmc.addon.metadata">

    <summary lang="en">Confluence skin by Jezz_X. (XBMC's default skin)</summary>

    <description lang="en">Confluence is the default skin for XBMC 9.11 and above. It is a combination of concepts from many popular skins, and attempts to embrace and integrate their good ideas into a skin that should be easy for first time XBMC users to understand and use.</description>

    <disclaimer lang="en">Confluence is the default skin for XBMC, removing it may cause issues</disclaimer>

    <platform>all</platform>

    <license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license>

    <forum></forum>

    <website></website>

    <email></email>

    <source></source>

  </extension>

</addon>

One thing to note is that all tag names are lower case. XML tag names are case sensitive!

scripts/plugins扩展的addon.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon
   id="script.artwork.downloader"
   name="Artwork Downloader"
   version="12.0.12"
   provider-name="Martijn">
  <requires>
    <import addon="xbmc.python"                 version="2.1.0"/>
    <import addon="xbmc.json"                   version="6.0.0"/>
    <import addon="xbmc.addon"                  version="12.0.0"/>
    <import addon="script.module.elementtree"   version="1.2.7"/>
    <import addon="script.module.simplejson"    version="2.0.10" optional="true"/>
    <import addon="script.common.plugin.cache"  version="1.3.0"/>
  </requires>
  <extension point="xbmc.python.script"         library="default.py">
    <provides>executable</provides>
  </extension>
  <extension point="xbmc.service" library="service.py" start="login"/>
  <extension point="xbmc.addon.metadata">
    <summary lang="en">Downloads Artwork for TV shows, Movies and Musicvideos in your library</summary>
    <description lang="en">Downloads all available artwork for TV shows, Movies and Musicvideos in your library. Check the options for supported artwork[CR]Artwork sources:[CR]www.fanart.tv[CR]www.thetvdb.com[CR]www.themoviedb.org[CR]Remark:[CR]Check your skin to see what type of artwork is supported![CR]Each TV Show/Movie must have its own folder![CR]Skin integration:[CR]See readme file</description>
    <disclaimer lang="en">For bugs, requests or general questions visit the Artwork Downloader thread on the XBMC forum.</disclaimer>
    <language></language>
    <platform>all</platform>
    <license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license>
    <forum></forum>
    <website></website>
    <email></email>
    <source></source>
  </extension>
</addon>

4. XBMC源代码

addon.xml 遵循XML Schema Definition 标准。