2. mapping.yml
Has the root item mappings which has the following top level entries:
templatesoptionaltagsoptionalmappingmandatory
2.1 templates
If you have a lot of repeats in you regexps, you can use templates to make your regexps cleaner.
You can reference other templates in templates with !name!;
templates:
- {name: delimiter, value: '[\s_-]*' }
- {name: quality, value: '(?i)(?P<quality>HD|LQ|4K|UHD)?'}
With this definition you can use delimiter and quality in your regexp's surrounded with ! like.
^.*TF1!delimiter!Series?!delimiter!Films?(!delimiter!!quality!)\s*$
This will replace all occurrences of !delimiter! and !quality! in the regexp string.
2.2 tags
Has the following top level entries:
name: unique name of the tag.captures: List of captured variable names likequality. The names should be equal to the regexp capture names.concat: if you have more than one captures defined this is the join string between themsuffix: suffix for the tagprefix: prefix for the tag
2.3 mapping
Has the following top level entries:
idmandatorymatch_as_asciioptional default isfalsemappermandatorycounteroptional
2.3.1 id
Is referenced in the config.yml, should be a unique identifier
2.3.2 match_as_ascii
If you have non ascii characters in you playlist and want to
write regexp without considering chars like é and use e instead, set this option to true.
unidecode is used to convert the text.
2.3.3 mapper
Has the following top level entries:
filteroptionalpatternattributessuffixprefixassignments
2.3.4.1 filter
The filter is a string with a statement (@see filter statements). It is optional and allows you to filter the content.
2.3.4.2 pattern
The pattern is a string with a statement (@see filter statements).
The pattern can have UnaryExpression NOT, BinaryExpression AND OR, and Comparison (Group|Title|Name|Url) ~ "regexp".
Filter fields are Group, Title, Name and Url.
Example filter: NOT Title ~ ".*Shopping.*"
The pattern for the mapper works different from a filter expression. A filter evaluates the complete expression and returns a result. The mapper pattern evaluates the expression, but matches directly comparisons and processes them immediately. To avoid misunderstandings, keep the pattern simply to comparisons.
The regular expression syntax is similar to Perl-style regular expressions, but lacks a few features like look around and backreferences.
2.3.4.3 attributes
Attributes is a map of key value pairs. Valid keys are:
idchnonamegrouptitlelogologo_smallparent_codeaudio_tracktime_shiftrecurl
If the regexps matches, the given fields will be set to the new value
You can use captures in attributes.
For example you want to rewrite the base_url for channels in a specific group.
mappings:
templates:
- name: sports
value: 'Group ~ ".*SPORT.*"'
- name: source
value: 'Url ~ "https?:\/\/(.*?)\/(?P<query>.*)$"'
mapping:
- id: sport-mapper
mapper:
- filter: '!sports!'
pattern: "!source!"
attributes:
url: http://my.bubble-gum.tv/<query>
In this example all channels the urls of all channels with a group name containing SPORT will be changed.
2.3.4.4 suffix
Suffix is a map of key value pairs. Valid keys are
- name
- group
- title
The special text <tag:tag_name> is used to append the tag if not empty.
Example:
suffix:
name: '<tag:quality>'
title: '-=[<tag:group>]=-'
In this example there must be 2 tag definitions quality and group.
If the regexps matches, the given fields will be appended to field value
2.3.4.5 prefix
Suffix is a map of key value pairs. Valid keys are
- name
- group
- title
The special text <tag:tag_name> is used to append the tag if not empty
Example:
suffix:
name: '<tag:quality>'
title: '-=[<tag:group>]=-'
In this example there must be 2 tag definitions quality and group.
If the regexps matches, the given fields will be prefixed to field value
2.3.4.6 assignments
Attributes is a map of key value pairs. Valid keys and values are:
idchnonamegrouptitlelogologo_smallparent_codeaudio_tracktime_shiftrecsource
Example configuration is:
assignments:
title: name
This configuration sets title property to the value of name.
2.3.3.6 transform
transform is a list of transformations.
Each transformation can have the following attributes:
fieldmandatory the field where the transformation will be appliedmodifiermandatory, values are:lowercase,uppercaseandcapitalizepatternoptional is a regular expression (not filter!) with captures. Only needed when you want to transform parts of the property.
For example: first 3 chars of channel name to lowercase:
mapper:
- pattern: 'Group ~ ".*"'
transform:
- field: name
pattern: "^(...)"
modifier: lowercase
channel name to uppercase:
mapper:
- pattern: 'Group ~ ".*"'
transform:
- field: name
modifier: uppercase
2.3.4 counter
Each mapping can have a list of counter.
A counter has the following fields:
filter: filter expressionvalue: an initial start valuefield:title,name,chnomodifier:assign,suffix,prefixconcat: is optional and only used ifsuffixorprefixmodifier given.
mapping:
- id: simple
match_as_ascii: true
counter:
- filter: 'Group ~ ".*FR.*"'
value: 9000
field: title
modifier: suffix
concat: " - "
mapper:
- <Mapper definition>
2.5 Example mapping.yml file.
mappings:
templates:
- name: delimiter
value: '[\s_-]*'
- name: quality
value: '(?i)(?P<quality>HD|LQ|4K|UHD)?'
- name: source
value: 'Url ~ "https?:\/\/(.*?)\/(?P<query>.*)$"'
tags:
- name: quality
captures:
- quality
concat: '|'
prefix: ' [ '
suffix: ' ]'
mapping:
- id: France
match_as_ascii: true
mapper:
- filter: 'Name ~ "^TF.*"'
pattern: '!source!'
attributes:
url: http://my.iptv.proxy.com/<query>
- pattern: 'Name ~ "^TF1$"'
attributes:
name: TF1
id: TF1.fr
chno: '1'
logo: https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/TF1_logo_2013.svg/320px-TF1_logo_2013.svg.png
suffix:
title: '<tag:quality>'
group: '|FR|TNT'
assignments:
title: name
- pattern: 'Name ~ "^TF1!delimiter!!quality!*Series[_ ]*Films$"'
attributes:
name: TF1 Series Films
id: TF1SeriesFilms.fr
chno: '20'
logo: https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/TF1_logo_2013.svg/320px-TF1_logo_2013.svg.png,
suffix:
group: '|FR|TNT'