Label Parsing

From Official Kodi Wiki
Revision as of 00:49, 14 April 2022 by Gade (talk | contribs) (→‎How the parsing works)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In label controls, fadelabel controls, built-in functions as well as in the LCD label definition files you can specify more than one piece of information to be displayed in a single line of text (or across multiple lines of text) by using the $INFO, $ESCINFO[] and $LOCALIZE keywords in a <label> tag. In addition to this, you can use the Label Formatting syntax to specify color and style information for the text (changeable within a single label).

1 Example

<label>A good example of a $INFO[MusicPlayer.Title,song title: , $COMMA and a]$INFO[MusicPlayer.Artist, song artist:]</label>
<label>The following will be localized from an addons strings - $ADDON[ 32001]</label>

2 How the parsing works

  1. Kodi runs through and replaces any $LOCALIZE[number] blocks with the real string from strings.po.
  2. Kodi then runs through and translates the $INFO[infolabel,prefix,postfix] blocks from left to right.
  3. If the Info manager returns an empty string from the infolabel, then nothing is rendered for that block.
  4. If the Info manager returns a non-empty string from the infolabel, then Kodi prints the prefix string, then the returned infolabel information, then the postfix string. Note that any $COMMA fields are replaced by real commas, and $$ is replaced by $.
  5. Any pieces of information outside of the $INFO blocks are rendered unchanged.

So, in the above example, if nothing is playing then the label will print: A good example of a

If a song is playing but it has no Title (ie MusicPlayer.Title returns an empty string) but does have an artist, it will return: A good example of a song artist: <Artist>

If a song is playing that has title and artist information, it will return: A good example of a song title: <Title>, and a song artist: <Artist>

$ESCINFO[] should be used when passing an infolabel to a built-in function, when this infolabel is likely to contain commas (,) and/or quotes (").

eg: PlayMedia($INFO[ListItem.Path]) might return: PlayMedia(/some/path/with_a_file_that_includes,a_comma.avi)

This will be read by the builtin function generator as PlayMedia called with 2 parameters: "/some/path/with_a_file_that_includes" and "a_comma.avi".

If you use PlayMedia($ESCINFO[ListItem.Path]) however, it will make sure that whatever is returned by the infolabel is sent on to the builtin as a single parameter.

3 See also