Mappings

Mappings allow the user to replace (map) any values retrieved by the fetcher to a value defined by the user. Mappings can either be Text based or Regex based, so it can be as simple or as powerful as you want it to be.

Mappings can also be defined per media type and the following categories are available for mappings:

  • Global
    • Applied to all media types that are fetched
  • Movies
    • Will only apply the defined mappings for movie items
  • TV
    • Will only apply the defined mappings for tv items (series/season/episode)
  • Sorting
    • Will only apply the defined mapping for the Series Name gotten from an episode sorting file

Text Based Mappings

Text based mappings are very simple mappings that allow you to map specific values returned by fetchers with your custom value. If using text based mapping, you can set the mapping to either be an Exact Match and/or Case Sensitive map.

Exact Match

Match value that is exactly as the text entered in the pattern. The returned value must contain only what is defined as your pattern to be considered a match.

Match Case

Perform a CaSe SenSiTiVe match against the returned value. The returned value must be the same case as your pattern to be considered a match.

Text Example

Lets take for example the following values have been set for your mapping:

Pattern:                    Foo
Replacement:                Bar
Value returned by fetcher:  My Foo is better than your foo.

The results would be:

Match Case Enabled Match Case Disabled
Exact Match Enabled My Foo is better than your foo. My Foo is better than your foo.
Exact Match Disabled My Bar is better than your foo. My Bar is better than your Bar.

In the example above all matches with the option of Exact Match Enabled will fail, since exact match requires the returned value to match exactly what is defined as the pattern. If the value returned by the fetcher was just Foo, the Exact Match option would have succeeded (dependent on your Match Case setting).

Regex Based Mappings

Regex based mappings are a lot more powerful and offers more flexibility when comapred to text based mappings. It allows replacement of text using regular expressions. Not only can you define the text to replace using a regular expression, you can define what to replace it with using a replacement string containing special constructs which identify portions of the mathed text.

Constructs that can be used in a Regex replacement string:

$&            - matched text
$_            - original source string
$`            - text before match 
$'            - text after match 
${group_name} - text matched by named group 
$1, $2        - text matched by numbered group 
$$            - the literal "$" 

* Note: Exact Match and Match Case have no effect and are disabled when using Regex based mapping

Regex Example 1

Lets take for example the following values have been set for your mapping:

Pattern:                      \((?<first>\S+) (?<last>\S+)\)
Replacement:                  (${last}, ${first})
Value returned by fetcher:    Disabled Marine Jake Sully (Sam Worthington) travels to planet Pandora to become an avatar.

Result:                       Disabled Marine Jake Sully (Worthington, Sam) travels to planet Pandora to become an avatar.

The above example won't take into account all types of names, you would need a better regex pattern for that, but it is possible using Regex mappings.

Regex Example 2

Fetchers can return metadata in various formats for the same value, for example:

  • BBC 1
  • BBC1
  • BBC-1
  • BBC ONE
  • BBC-ONE

You can easily map all of the above studios to one value using the following regex mapping:

Pattern:                      (?i)(^BBC[ -]?(1|ONE)$)
Replacement:                  BBC One

The above will allow the studio to be mapped to the replacement value of BBC One, which will now be standard accross the board no matter what format the fetcher returns.

For help or examples with regex patterns visit Regular-Expressions.info.