[SNIPPET] Override / Hardcode Series Names

All about user-defined episode / movie format expressions
Post Reply
User avatar
rednoah
The Source
Posts: 16758
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

[SNIPPET] Override / Hardcode Series Names

Post by rednoah » 15 Jul 2012, 09:03

If you're not happy with the data you get from your chosen database, you can just make the expression format engine do what you want. There's lots of ways to do this.

Let's say we prefer acronyms for these shows:
Deep Space 9 => DS9
How I Met Your Mother => HIMYM

1. Hardcode the name

Code: Select all

DS9 {sxe} {t}
2. Pattern matching

Code: Select all

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

Code: Select all

n.replace('Deep Space 9','DS9').replace('How I Met Your Mother','HIMYM')
4. Mappings from a CSV file

Code: Select all

{csv('/path/to/names.csv').get(n) ?: n}
e.g. /path/to/names.csv

Code: Select all

Deep Space 9;DS9
How I Met Your Mother;HIMYM
... or anything else you can come up with! ;)


BTW If you just wanna modify the original string you can do just that, e.g.

"The IT Crowd (UK)" => "The IT Crowd"

Code: Select all

{n.replaceTrailingBrackets()}
"Deep Space 9" => "DS9"

Code: Select all

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

xflak
Power User
Posts: 53
Joined: 25 Feb 2015, 01:51

Re: [SNIPPET] Override/Hardcode Series Names

Post by xflak » 24 Feb 2017, 04:52

So I just updated filebot, and relative path references I used in my old code stopped working

Code: Select all

{csv('list.csv').get(n) ?: n}
to get it to work I had to replace the relative path with the absolute path

Code: Select all

{csv('C:/Program Files/FileBot/list.csv').get(n) ?: n}
Not a huge deal, but wanted to report in case it can either get rolled back and\or just to notify other potentially having the same issue

Thanks.

User avatar
rednoah
The Source
Posts: 16758
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [SNIPPET] Override/Hardcode Series Names

Post by rednoah » 24 Feb 2017, 07:33

Relative paths passed to csv(...) are now expected to be relative to your $HOME directory.
:idea: Please read the FAQ and How to Request Help.

garyleecn
Donor
Posts: 113
Joined: 19 Nov 2014, 03:48

Re: [SNIPPET] Override / Hardcode Series Names

Post by garyleecn » 24 Jul 2017, 01:52

so how do I integrate it with AMC?

User avatar
rednoah
The Source
Posts: 16758
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [SNIPPET] Override / Hardcode Series Names

Post by rednoah » 24 Jul 2017, 04:33

You pass in your own format. The amc manual has a section on how to use custom formats.
:idea: Please read the FAQ and How to Request Help.

Matt
Posts: 9
Joined: 22 Aug 2018, 19:19

Re: [SNIPPET] Override / Hardcode Series Names

Post by Matt » 16 Sep 2018, 17:42

How do you force Series + season ?
Examples:
Overlord III -> Overlord S3
Owarimonogatari -> Monogatari Series S11

Post Reply