mapping - euzu/tuliprox GitHub Wiki
Has the root item mappings which has the following top level entries:
-
templatesoptional -
tagsoptional -
mappingmandatory
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.
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 them -
suffix: suffix for the tag -
prefix: prefix for the tag
Has the following top level entries:
-
idmandatory -
match_as_asciioptional default isfalse -
mappermandatory -
counteroptional
Is referenced in the config.yml, should be a unique identifier
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.
Has the following top level entries:
-
filteroptional patternattributessuffixprefixassignments
The filter is a string with a statement (@see filter statements). It is optional and allows you to filter the content.
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.
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.
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
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
Attributes is a map of key value pairs. Valid keys and values are:
idchnonamegrouptitlelogologo_smallparent_codeaudio_tracktime_shiftrecsource
Example configuration is:
assignments:
title: nameThis configuration sets title property to the value of name.
transform is a list of transformations.
Each transformation can have the following attributes:
-
fieldmandatory the field where the transformation will be applied -
modifiermandatory, values are:lowercase,uppercaseandcapitalize -
patternoptional 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: lowercasechannel name to uppercase:
mapper:
- pattern: 'Group ~ ".*"'
transform:
- field: name
modifier: uppercaseEach mapping can have a list of counter.
A counter has the following fields:
-
filter: filter expression -
value: an initial start value -
field:title,name,chno -
modifier:assign,suffix,prefix -
concat: 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>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'