[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: 22899
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"


1. Hardcode the name in your custom format:

Format: Select all

DS9 - {s00e00} - {t}

2. Use pattern matching and replacement:

Format: Select all

{
	n.match(
		'Deep Space 9' : 'DS9',
		'How I Met Your Mother' : 'HIMYM'
	) ?: n
}

3. Use character replacement:

Format: Select all

{
	n.replace(
		'Deep Space 9' : 'DS9',
		'How I Met Your Mother' : 'HIMYM'
	)
}

4. Use a custom lookup table:

Format: Select all

{
	def table = [
		'Deep Space 9' : 'DS9',
		'How I Met Your Mother' : 'HIMYM'
	]
	table[n] ?: n
}

5. Use a custom lookup table read from an external TSV or CSV file:

Format: Select all

{
	def table = csv('/path/to/names.tsv')
	table[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.



6.
... or anything else you can come up with! Anything is possible!




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