Page 1 of 1

Add year when not present

Posted: 04 Nov 2015, 00:52
by Pab
Is it possible to add the year in brackets only if the year is not present, whilst also preserving other types of trailing brackets, such as (US) or (UK)? For example

Firefly -> Firefly (2002)
The Newsroom (2012) -> The Newsroom (2012)
Wilfred (US) -> Wilfred (US) (2011)

I've tried writing if statements to check if the year is present like this:

Code: Select all

{n.contains(y) ? '' : '(y)'}
But I couldn't quite get it outputting the year. What would be the correct way to go about getting this?

Thank you

Re: Add year when not present

Posted: 04 Nov 2015, 01:18
by rednoah
Everything within {...} is Groovy code, so:

Code: Select all

{n.contains(y) ? '' : ' ('+y+')'}

Re: Add year when not present

Posted: 04 Nov 2015, 01:35
by Pab
I think I tried that or something similar but it still isn't working. I tried on both mac and windows as well. Maybe some other part of the naming is interfering. Are there any other problems in this:

Code: Select all

D:/Tv/{genres.contains('Documentary') ? 'Docs - Series' : 'Shows'}/{info.status == 'Ended' ? 'Ended' : 'Ongoing'}/{n.replaceAll(/:/,/-/)} {n.contains(y) ? '' : ' ('+y+')'} ({certification}) [{audio.language}] [{series.id}]/Season {s.pad(2)}/{n.replaceAll(/:/,/-/)} - {s00e00} - {t.replaceAll(/:/,/-/).replaceAll(/[!?.]+$/)} - ({airdate.format('yyyy.MM.dd')}) - [{vc} {vf} {ac} {af}]{' ['+file.name.match(/EngSub|EngDub/)+']'}{'.'+lang}
Thanks again

Re: Add year when not present

Posted: 04 Nov 2015, 04:29
by rednoah
y is an Integer, not a String, so:

Code: Select all

{n.contains(y as String) ? '' : ' ('+y+')'}
Or just:

Code: Select all

{n =~ y ? '' : ' ('+y+')'}
EDIT:

The new {ny} binding will make this even easier.

Re: Add year when not present

Posted: 17 Dec 2016, 11:39
by tyrannicpuppy
Thank you so much.

This has helped significantly with my media due to shows like Doctor Who (of which I have classic and new), I like to have the Show folder with the Date, and kept getting double dates on some shows.

My only question is would it be possible to remove the date from the Video filename for shows that are listed with dates on TVDB (e.g. Castle (2009), The Flash (2014), Doctor Who (2005)) but not effect shows that don't (e.g. Arrow, Firefly).

i.e. I would like the files to appear as:
Volumes/Plex/TV/Castle (2009)/Season 01/Castle - S01E08 - Ghosts.mp4

My format is:

Code: Select all

/Volumes/Plex/TV/{ny}/{episode.special ? 'Specials' : 'Season '+s.pad(2)}/{n} - {episode.special ? 'S00E'+special.pad(2) : s00e00} - {t.replaceAll(/[`´‘’ʻ]/, /'/).replaceAll(/[!?.]+$/).replacePart(' [$1]')}
I have been trying to achieve it with .replaceAll but I am total noob when it comes to all of this and I cannot get it to work.

I'll be incredibly thankful to anyone who can help me with this.

Re: Add year when not present

Posted: 17 Dec 2016, 12:35
by rednoah
Use {ny} and things will just work, no double years.

If you want to remove the year from {n} then you could try the String.removeTrailingBrackets() helper function.

Re: Add year when not present

Posted: 17 Dec 2016, 13:13
by tyrannicpuppy
Perfect. It now works exactly as I wanted. Thank you so much.

Now I just have to incorporate it into my AMC.

Re: Add year when not present

Posted: 17 Dec 2016, 18:02
by rednoah
Use external text files: viewtopic.php?f=3&t=3244