[SNIPPET] Use Custom Series Names / Force Series Name / Hardcode Series Name

All about user-defined episode / movie / file name format expressions
Locked
User avatar
rednoah
The Source
Posts: 23922
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

[SNIPPET] Use Custom Series Names / Force Series Name / Hardcode Series Name

Post by rednoah »

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"


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

Screenshot

:idea: 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.



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() }
"Deep Space 9" => "DS9"

Format: Select all

{ n.acronym() }
:idea: Please read the FAQ and How to Request Help.
Locked