|
Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
|
Skin-defined lookup tables for infolabel values
Skin maps let a skin replace the raw value of an infolabel with a string of its own choosing. A map is a list of key/value pairs; at runtime an infolabel is resolved to its current value, that value is looked up as a key, and the mapped string is displayed instead. Keys that the map does not define are displayed unchanged, so a map only has to list the values it wants to rewrite.
Typical uses are turning short technical values into presentable text, such as an audio codec eac3 into Dolby Digital+, or a two letter country code into a full country name, without needing a python script or a chain of String.IsEqual conditions.
Maps are defined with <map> tags in Includes.xml or descendants pulled in with <include file="..."/>, alongside the other definitions that file carries:
Or keep them in their own file and pull that in:
They are read with the $MAP[] label format. See the list of available tags for the definition rules.
A map is read with $MAP[mapname, infolabel]. Both are required and both are trimmed of surrounding whitespace:
Being a label format, it is not limited to <label>. It works wherever $INFO[] and $VAR[] do, including inside a <variable> value:
Like $INFO[] and $VAR[], two further optional arguments set a prefix and a postfix. They are added only when the infolabel resolves to a value, so a separator never appears on its own:
$ESCMAP[] behaves identically but escapes the result, in the same way $ESCINFO[] and $ESCVAR[] relate to $INFO[] and $VAR[]. Use it where the mapped value is passed on to something that parses it again, such as a builtin function argument.
$MAP[] is a label format. It is not valid inside a boolean condition.The simplest map rewrites a handful of values:
With the map above, a file whose audio codec is ac3 displays Dolby Digital, while a file whose codec is flac displays flac, because the map does not define that key.
A map may alias another with the ref attribute rather than repeating its entries. Entries listed in the aliasing map are searched first, so it can add keys the referenced map does not define, or override ones it does:
Here $MAP[AudioCodecsVerbose, ListItem.AudioCodec] gives Dolby Digital Plus with Atmos for eac3_ddp_atmos, and Dolby Digital for ac3, the latter coming from the referenced map.
Skin maps have the following available tags:
| Tag | Description |
|---|---|
| map | A single lookup table. Requires a name attribute; a map without one is ignored. Accepts an optional ref attribute naming another map to fall back to. |
| entry | One key/value pair, written as <entry key="rawvalue">Display value</entry>. Requires a non-empty key attribute and non-empty text; an entry missing either is ignored. (can be repeated) |
ref is skipped entirely. ref naming a map that is never defined is reported at load time, and lookups through it return the raw value. ref chain that loops back on itself is detected, aborted, and the raw value returned.