[SNIPPET] Use Custom Series Names / Force Series Name / Hardcode Series Name
Posted: 15 Jul 2012, 09:03
If you're not happy with the series names you get from your chosen database, then you can just have your custom format generate something different instead. There's lots of ways to do this:
Let's say we prefer acronyms:
"Deep Space 9" => "DS9"
"How I Met Your Mother" => "HIMYM"

We prefer TSV files (TAB-separated values) because TAB cannot appear in column values.
DO NOT use Microsoft tools such as Word or Excel to edit TSV files. Use tools such as Notepad++ or Sublime Text instead.
"The IT Crowd (UK)" => "The IT Crowd"
"Deep Space 9" => "DS9"
- hardcode the name in your custom format
- use pattern matching and replacement
- use character replacement
- use a custom lookup table
- use a custom lookup table read from an external TSV or CSV file
- use a custom function
Let's say we prefer acronyms:
"Deep Space 9" => "DS9"
"How I Met Your Mother" => "HIMYM"
e.g. hardcode the name in your custom format
Format: Select all
DS9 - {s00e00} - {t}
e.g. use pattern matching and replacement
Format: Select all
{
n.match(
'Deep Space 9' : 'DS9',
'How I Met Your Mother' : 'HIMYM'
) ?: n
}
e.g. use character replacement
Format: Select all
{
n.replace(
'Deep Space 9' : 'DS9',
'How I Met Your Mother' : 'HIMYM'
)
}
e.g. use a custom lookup table
Format: Select all
{
[
'Deep Space 9' : 'DS9',
'How I Met Your Mother' : 'HIMYM'
][n] ?: n
}
Format: Select all
{
[
580 : 'DS9',
1100 : 'HIMYM'
][id] ?: n
}
e.g. use a custom lookup table read from an external TSV or CSV file
Format: Select all
{
csv('/path/to/names.tsv')[n] ?: n
}
Console Output: Select all
$ cat ~/names.tsv
Deep Space 9 DS9
How I Met Your Mother HIMYM



e.g. use a custom function
Alternatively, you can use code to generically derive the series names you want from the series names you get from your chosen database."The IT Crowd (UK)" => "The IT Crowd"
Format: Select all
{ n.replaceTrailingBrackets() }
Format: Select all
{ n.acronym() }