Hunger Games, The - Catching Fire (2012)

All about user-defined episode / movie format expressions
Post Reply
Posts: 1
Joined: 14 Jan 2019, 23:57

Hunger Games, The - Catching Fire (2012)

Post by alexauran » 15 Jan 2019, 00:51

Hi, I'm trying to get my formatting right, but I'm having some problems. My programming knowledge is from Visual Basic 6.0, so I'm way out of date. I've been reading and splicing code from the forum for days, but I don't have time to learn to code this the correct way.

Here is what I have so far:

Code: Select all

O:\movies\{norm = {it.upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceAll(/\b(?i: II| III| IV| V| VI| VII| VIII| IX| X| XI| XII)\b/, { it.upper() }).replaceAll(/1St/, "1st").replaceAll(/2Nd/, "2nd").replaceAll(/3Rd/, "3rd").replaceAll(/4Th/, "4th").replaceAll(/5Th/, "5th").replaceAll(/6Th/, "6th").replaceAll(/7Th/, "7th").replaceAll(/8Th/, "8th").replaceAll(/9Th/, "9th").replaceAll(/0Th/, "0th")}; norm(n)}{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""}{fn.contains('Extended') || fn.contains('EXTENDED') || fn.contains('extended.cut') ? ' (Extended)' : fn.contains('Special Edition') || fn.contains('SPECIAL EDITION') || fn.contains('SPECIAL.EDITION') ? ' (Special Edition)' : fn.contains('Unrated') || fn.contains('UNRATED') ? ' (Unrated)' : fn.contains('Uncensored') || fn.contains('UNCENSORED') ? ' (Uncensored)' : fn.contains('Remastered') || fn.contains('REMASTERED') ? ' (Remastered)':""} ({y}){" - $vf"}
Raw Filebot return from {n} ({y}:
The Hunger Games (2012)
The Hunger Games: Catching Fire (2013)
The Hunger Games: Mockingjay - Part 1 (2014)
The Hunger Games: Mockingjay - Part 2 (2015)

What I want after my formatting code:
Hunger Games, The (2012) - 1080p.mp4
Hunger Games, The - Catching Fire (2012) - 1080p.mp4
Hunger Games, The - Mockingjay - Part I (2012) - 1080p.mp4
Hunger Games, The - Mockingjay - Part II (2012) - 1080p.mp4

So basically, I I haven't solved how to move ", The " in front of the first - that appears.

I think the logical way to do this is something like this (forgive my pseudo-code, just explaining the best way I know how)

Code: Select all

if n starts with "The " = true
	if n contains ":" = true
                .replaceFirst(/[:|]/, ", The - ")
		.replaceAll(/[:|]/, ", - ")
		.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)
		.replaceAll(/[:|]/, ", - ")
	end if
end if
1) Am even close to thinking about this the right way? I have no java or groovy experience and not a ton of time to learn it for this.

2) My formatting adds unrated or extended back to the movie filename, but it doesn't work for most subtitle as they don't contain extra tags in their filenames, usually stuff like "".

I want to get:
Argo (Extended) (2012) - 1080p.mp4
Argo (Extended) (2012) -

but my code gives me:
Argo (Extended) (2012) - 1080p.mp4
Argo (2012) -

3) I have this from another user's code but I can't figure out exactly what it does. I know it's related to adding the Japanese name in anime but I don't get the terms or functions.
{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'}

Any help is greatly appreciated.

User avatar
The Source
Posts: 16820
Joined: 16 Nov 2011, 08:59
Location: Taipei

Re: heavy custom formatting issues

Post by rednoah » 15 Jan 2019, 04:03

This should do:

Code: Select all

{n.split(': ')*.sortName('$2, $1').join(' - ')}

Bindings such as {tags} will check the primary video file, but if the video file and subtitle files have completely unrelated names, then that won't work either.

:idea: There's always a way, but it'll get tricky if the built-in feature don't work out-of-the-box.

n and primaryTitle are top-level bindings / variables. The norm() function is defined in the first line of your format code, which would benefit from some code clean-up & code structure using new lines.
:idea: Please read the FAQ and How to Request Help.

Post Reply