Page 1 of 1

Remove redundent use of (Year) in title

Posted: 06 Dec 2013, 23:52
by Ithiel
Heya,

Got another curly one for you...

With my ever increasingly complicated renaming format (see below), I list the year and rating at the end of the shows main folder:
e.g. Boardwalk Empire (2010 TV-MA)\Season 01\Boardwalk Empire S01E01 Boardwalk Empire [360p XviD MP3 2ch].avi

Unfortunately, as Hollywood runs out of ideas of things to make shows about (or what to call them), we end up with an increasing number of shows that need to have their year referenced in the name to identify them - such as Once Upon A Time (2011). This leads me to have a bit of a problem..
e.g. Once Upon A Time (2011) (2011 TV-PG)\Season 03\Once Upon A Time (2011) S03E09 Save Henry [576p x264 AAC 2ch].mp4

So, I'm wondering - how do I remove the reference of a year if it's the same as the year I'm already showing (which it always should be). That is, how do I make "Once Upon A Time (2011) (2011 TV-PG)" appear sort as "Once Upon A Time (2011 TV-PG)", and any other shows like it (new or old etc.) without having to write individual exceptions for all of them. :-/

My current format:

Code: Select all

{norm = {it.upperInitial().lowerTrail().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)}; norm(n)}{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'} ({y}{" $certification"})/{episode.special ? 'Special' : 'Season '+s.pad(2)}/{norm(n)} {episode.special ? 'S00E'+special.pad(2) : s00e00} {norm(t)}{" [$vf $vc $ac $af]"}
Thanks! :-)

Re: Remove redundent use of (Year) in title

Posted: 07 Dec 2013, 07:17
by rednoah
Have you tried this?

Code: Select all

{n.replaceTrailingBrackets()}
Just get rid of the year in the {n} string.

Re: Remove redundent use of (Year) in title

Posted: 07 Dec 2013, 13:42
by Ithiel
Awesome - thanks mate. I was able to add that to my norm expression and it worked perfectly:

Code: Select all

{norm = {it.upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)}; norm(n)}{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'} ({y}{" $certification"})/{episode.special ? 'Special' : 'Season '+s.pad(2)}/{norm(n)} {episode.special ? 'S00E'+special.pad(2) : s00e00} {norm(t)}{" [$vf $vc $ac $af]"}
Result: Newsroom, The (2012 TV-MA)\Season 01\Newsroom, The S01E01 We Just Decided To [576p x264 AAC 2ch].mp4

Re: Remove redundent use of (Year) in title

Posted: 28 Jan 2014, 10:07
by vlotty
I'm pretty new to FileBot but seem to have gotten it working. Setup is Mac, with Transmission.

What if you want to avoid the double year problem but want to keep things like (UK) to differentiate between shows like The Office (US) and The Office (UK)?

My understanding is that by adding {n.replaceTrailingBrackets()} it would also remove things like (UK). Right now on some shows I'm getting something like:

Archer (2009)(2009)

My expression (very basic):

Code: Select all

seriesFormat=TV Shows/{n} ({y}){'/Season '+s}/{n} - s00e00 - {t}.{vf}"
Thanks, so far FileBot is awesome!

Re: Remove redundent use of (Year) in title

Posted: 28 Jan 2014, 11:34
by rednoah
{n} is the unique name as specified by the database, may or may not contains (2000) (UK) etc

For episodes {y} is short for {startdate.year} (series start year) based on the information provided by the database.

Then you can easily combine that in...

One way:

Code: Select all

{n.replace(" ($y)",'')}
Or another:

Code: Select all

{n.replaceAll(/\s\(\d{4}\)/,'')}
But that's probably a bad idea since the folder/file would then not match the online database anymore and HTPC software may misidentify things.


This is what I'd do if I wanted to enforce a name (year) scheme for any series:

Code: Select all

{n}{n =~ y ? '' : " ($y)"}

Re: Remove redundent use of (Year) in title

Posted: 28 Jan 2014, 20:34
by vlotty
Thank you! I tried it out and it worked great.

Re: Remove redundent use of (Year) in title

Posted: 29 Jan 2014, 03:18
by vlotty
Actually-- I just noticed a different problem... so it works fine if the show already has a year in the name, it won't duplicate.

But if there is no year, it doesn't add it, for example:

Show Name ()

I have this as my script:

Code: Select all

/Applications/Filebot.app/Contents/MacOS/filebot -script fn:amc --output "/Volumes/Media" --log-file amc.log --action copy --conflict override -non-strict  --def "seriesFormat=/path/to/TV Shows/{n}{n =~ y ? '' : \" ($y)\"}{'/Season '+s}/{n} - {s00e00} - {t}{'.'+vf.match(/720[pP]|1080[pP]/)}" "ut_dir=$TR_TORRENT_DIR/$TR_TORRENT_NAME" "ut_kind=multi" "ut_title=$TR_TORRENT_NAME"
I added the \" to escape the quotes, which I assume is correct?

Also overall-- is there a reference for all the syntax and such that is possible? I have read the FAQs and looked at a lot of examples, but it's not clear to me what the syntax is. For example, how could I have figured out on my own that I could do a conditional? What does =~ and : do? Are these all regular expressions (which I only know of, but am not familiar with), or something else?

Thanks!

Re: Remove redundent use of (Year) in title

Posted: 29 Jan 2014, 09:46
by rednoah
First try it in the GUI. Pretty sure you just made mistake with cmdline escaping. Then check the log and see if amc gets passed in the format you think you're passing in.

As for syntax everything inside {...} is Groovy code. You can google Groovy for more details.

e.g.
http://groovy.codehaus.org/Regular+Expressions

EDIT: I assume the $ gets passed wrong => bash is evaluating $y already, which is nil, so empty string gets passed in, as if you passed in " ()"