Replace colon characters differently depending on the context

All about user-defined episode / movie format expressions
Post Reply
niXta
Posts: 3
Joined: 09 Nov 2016, 15:10

Replace colon characters differently depending on the context

Post by niXta »

Hi!

I want to convert:
text:text -> text.text
and
text: text -> text - text

For example:
11:14 (2003) -> 11.14 (2003)
while
District 13: Ultimatum (2009) -> District 13 - Ultimatum (2009)

This is my format atm: {ny.colon(' - ')}.{vf}{'.'+source}.{ac}{'.'s3d}.{vc}/{ny.colon(' - ')}.{vf}{'.'+source}.{ac}{'.'s3d}.{vc}{'[CD'+pi+']'}

I've tried to make it with {n.replaceAll(':^ ','.')} or something like it but I just can't figure it out.


I have also been thinking if it is possible to use the original title if it is a Swedish movie?

Thanks for the great program and expect an donation in the near future.
User avatar
rednoah
The Source
Posts: 18826
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [HELP] text:text -> text.text and text: text -> text - text

Post by rednoah »

1.
You can pass in different replacements for ratio-style colon and grammar-style colon:

Code: Select all

'Episode: 4:00am'.colon('.', ' - ')
You may need to install the latest revision for that one though.


2.
Depends on how you define what a "A Swedish Movie" is. ;)

e.g. Swedish movies are movies that are partially produced in Sweden:

Code: Select all

{'SE' in info.productionCountries ? primaryTitle : n}
@see viewtopic.php?f=5&t=4191
:idea: Please read the FAQ and How to Request Help.
niXta
Posts: 3
Joined: 09 Nov 2016, 15:10

Re: [HELP] text:text -> text.text and text: text -> text - text

Post by niXta »

rednoah wrote:1.
You can pass in different replacements for ratio-style colon and grammar-style colon:

Code: Select all

'Episode: 4:00am'.colon('.', ' - ')
You may need to install the latest revision for that one though.


2.
Depends on how you define what a "A Swedish Movie" is. ;)

e.g. Swedish movies are movies that are partially produced in Sweden:

Code: Select all

{'SE' in info.productionCountries ? primaryTitle : n}
@see viewtopic.php?f=5&t=4191
1.
Ok, that should work, does the ratio-style colon require numbers on both sides?
I am using the mac version atm, can you install the new revision from brew or app store?

2.
So, until I can install the new rev. I have come up the following:

Code: Select all

{'SE' in info.productionCountries ? primaryTitle : ny.upperInitial().colon(' - ')}.{vf}{'.'+source}.{ac}{'.'s3d}.{vc}/{'SE' in info.productionCountries ? primaryTitle : ny.upperInitial().colon(' - ')}.{vf}{'.'+source}.{ac}{'.'s3d}.{vc}{'[CD'+pi+']'}
It works on all non SE movies but on SE it capitalizes only the first word and not the rest of the words (Flickan som lekte med elden), also the year does not show. Therefore I tried to put in .upperInitial() but it didn't help.
I guess I can solve the year with

Code: Select all

{' ('+y+')'}
3.
A new thing I thought of is to group movie collections like all Bourne movies together like /Bourne/Bourne1/Bourne1.mkv and so on.
I had a look at some examples which lead me to something like:

Code: Select all

{any{"$collection/"}{"[]"}}{'SE' in info.productionCountries ? primaryTitle : ny.upperInitial().colon(' - ')}.{vf}{'.'+source}.{ac}{'.'s3d}.{vc}/{'SE' in info.productionCountries ? primaryTitle : ny.upperInitial().colon(' - ')}.{vf}{'.'+source}.{ac}{'.'s3d}.{vc}{'[CD'+pi+']'}
But I would like to name the collection in Swedish if 'SE'. I don't know how to get

Code: Select all

'SE' in info.productionCountries ? primaryTitle : n
(primaryTitle should probably be something about collection and "n" something else?)
in to

Code: Select all

{any{"$collection/"}{"[$y]"}}
Since this is getting really complex in my limited brain, could you please make sure to show me the whole working syntax in your reply?

Thanks again!
User avatar
rednoah
The Source
Posts: 18826
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace colon characters differently depending on the context

Post by rednoah »

1.
No, the latest revision is available as build, but not via any of the distribution channels (since there's a new revision every other day). You can also do a regex-replace (e.g. /\b[:]\b/) which will work with any release.

e.g.

Code: Select all

{'4:00am: Test'.replaceAll(/\b[:]\b/, '.')}

2.
Your format only applies upperInitial() in one of the two cases.

Note the difference:

Code: Select all

true ? 'A' : 'B'.lower()
(true ? 'A' : 'B').lower()

3.
e.g. use Swedish collection name:

Code: Select all

{localize.SWE.collection}
Note that TheMovieDB will probably default to English anyway because Swedish data probably hasn't been entered for a lot of movies or collections.

@see viewtopic.php?t=3761
:idea: Please read the FAQ and How to Request Help.
Post Reply