Solved: Help needed with original foreign movie titles

Any questions? Need some help?
Post Reply
User avatar
Nhoise
Power User
Posts: 17
Joined: 08 Feb 2015, 20:15

Solved: Help needed with original foreign movie titles

Post by Nhoise »

I've been breaking my brain over this a couple hours already and can't really find much documentation on it either so i thought i'd make a thread to see if anyone could shed some light on it.
I'm currently trying to restructure/rename folders in this format:

Code: Select all

*\Genre\English Title (Year) - (Original Title)
What i came up with is:

Code: Select all

*\{genres[0]}\{n.upperInitial()} ({y}) - ({"$primaryTitle".upperInitial()})
It's working fine except that it is putting an original title for all the movies even though i put the $ (which to my understanding should only apply that part if it exist, but i'm guessing i'm wrong in that).
So i did some more searching on the forums and i came across this piece of code shared by rednoah:

Code: Select all

*\{genres[0]}\{allOf{info.OriginalName}{n.upperInitial()}.unique().join(' - ')} ({y})
For the most part it is working a lot better except i don't understand how it works (and i'd really like to)
I've been messing around with it for a bit to change the order of names from: Original - English (Year) (which this code results in) to my preferred format but i haven't been able to without errors.
And from the few movies i'm using to test this on it's also applying the original name to 2 of the 11 films which don't have one listed on TMDb (i.e https://www.themoviedb.org/movie/16523- ... things-are)
Would really appreciate some help on this as this piece of software is the closest thing i've found to be able to do exactly what i want out of it, and believe me i've tried a bunch.
Last edited by Nhoise on 11 Feb 2015, 19:40, edited 1 time in total.
skullzy
Power User
Posts: 50
Joined: 07 Jan 2015, 22:19

Re: Help needed with original foreign movie titles

Post by skullzy »

This is just a guess on my part, but if you are trying to reverse Original Title - Title (Year) to Title - Original Title (Year), then I would assume you have to essentially switch those two parts around in order to get what you want.

So it would look like this

Code: Select all

*\{genres[0]}\{allOf{n.upperInitial()}{info.OriginalName}.unique().join(' - ')} ({y})
Which if I'm right, would show the name in reverse..

UPDATE - Looked into this a bit more for you, the following would give you Title (year) - (Original Title)

Code: Select all

*\{genres[0]}\{n.upperInitial()} ({y}) - ({info.OriginalName})
User avatar
rednoah
The Source
Posts: 23928
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help needed with original foreign movie titles

Post by rednoah »

"$primaryTitle" is identical to primaryTitle.

You're probably looking for something like this:

Code: Select all

{" - (${primaryTitle.upperInitial()})"}
:idea: Please read the FAQ and How to Request Help.
User avatar
Nhoise
Power User
Posts: 17
Joined: 08 Feb 2015, 20:15

Re: Help needed with original foreign movie titles

Post by Nhoise »

skullzy wrote:UPDATE - Looked into this a bit more for you, the following would give you Title (year) - (Original Title)

Code: Select all

*\{genres[0]}\{n.upperInitial()} ({y}) - ({info.OriginalName})
The problem is that this is putting an original name for all the movies, not only the ones which are foreign.
I'm guessing the ".unique().join(' - ')" is necessary
rednoah wrote:

Code: Select all

{" - (${primaryTitle.upperInitial()})"}
I'm guessing than that's not the expression i'm looking for then, it's taking the original name for all the films, not only the foreign ones.

This code is the closest to only taking names for movies which have a foreign title (except a few where it's putting the english title again for some reason but this is manageable with some manual editing afterwards)

Code: Select all

*\{genres[0]}\{allOf{info.OriginalName.upperInitial()}{n}.unique().join(' - ')} ({y})
All i need then is to switch it around so that the format is English Title (Year) - (Original Title)
User avatar
Nhoise
Power User
Posts: 17
Joined: 08 Feb 2015, 20:15

Re: Help needed with original foreign movie titles

Post by Nhoise »

Well after reading up on the functions of the allOf, .unique() and .join() expressions i've been trying get my preferred format to work.
This is what i have now:

Code: Select all

*\{genres[0]}\{allOf{n.upperInitial()} {info.originalName.upperInitial()}.unique().join( ' - ' )} ({y})
This is as close as i've gotten to how i want it to be, but i'm not able to put () around the originalName and i can't get {y} to be in between the {n} and {originalName}
Is it possible to use {y} in the .join() by any chance? Just putting it in between the (' ') will result in the {y} being parsed as is.
I feel like i'm making a bit of progress though. :lol:
User avatar
Nhoise
Power User
Posts: 17
Joined: 08 Feb 2015, 20:15

Re: Help needed with original foreign movie titles

Post by Nhoise »

I've been working on this a little bit longer and somehow managed to get exactly what i wanted.
For people with more knowledge of Java/Groovy this will probably look absolutely terrible but hey, it's working. 8-)

Code: Select all

*\{genres[0]}\{allOf{n.upperInitial().replaceFirst(/^(?i)(The|A|An|)\s(.+)/, /$2, $1/)} {y} {info.originalName.upperInitial().replaceFirst(/^(?i)(The|A|An|)\s(.+)/, /$2, $1/)}.unique().join(' ')
.replaceAll("20", "(20").replaceAll("19", "(19")
.replaceAll("18", "(18").replaceAll("1 ", "1) - (")
.replaceAll("2 ", "2) - (").replaceAll("3 ", "3) - (")
.replaceAll("4 ", "4) - (").replaceAll("5 ", "5) - (")
.replaceAll("6 ", "6) - (").replaceAll("7 ", "7) - (")
.replaceAll("8 ", "8) - (").replaceAll("9 ", "9) - (")
.replaceAll("0 ", "0) - (").replaceAll(": ", " - ")})\
Will result in: (Examples)

Code: Select all

*\'Genre'\Demon, The (1978) - (Kichiku)
*\'Genre'\Our Day Will Come (2010) - (Notre Jour Viendra)
skullzy
Power User
Posts: 50
Joined: 07 Jan 2015, 22:19

Re: Help needed with original foreign movie titles

Post by skullzy »

Nhoise wrote:I've been working on this a little bit longer and somehow managed to get exactly what i wanted.
For people with more knowledge of Java/Groovy this will probably look absolutely terrible but hey, it's working. 8-)

Code: Select all

*\{genres[0]}\{allOf{n.upperInitial().replaceFirst(/^(?i)(The|A|An|)\s(.+)/, /$2, $1/)} {y} {info.originalName.upperInitial().replaceFirst(/^(?i)(The|A|An|)\s(.+)/, /$2, $1/)}.unique().join(' ')
.replaceAll("20", "(20").replaceAll("19", "(19")
.replaceAll("18", "(18").replaceAll("1 ", "1) - (")
.replaceAll("2 ", "2) - (").replaceAll("3 ", "3) - (")
.replaceAll("4 ", "4) - (").replaceAll("5 ", "5) - (")
.replaceAll("6 ", "6) - (").replaceAll("7 ", "7) - (")
.replaceAll("8 ", "8) - (").replaceAll("9 ", "9) - (")
.replaceAll("0 ", "0) - (").replaceAll(": ", " - ")})\
Will result in: (Examples)

Code: Select all

*\'Genre'\Demon, The (1978) - (Kichiku)
*\'Genre'\Our Day Will Come (2010) - (Notre Jour Viendra)

Oh I see what you wanted to do, soz I never replied sooner.

I'm not familiar with groovy, however I am familiar with other programming languages.. which brought me to the following code.

Code: Select all

*\{genres[0]}\{( n == info.originalName) ? n.replaceFirst(/^(?i)(The|A|An|)\s(.+)/, /$2, $1/) + " ($y)" : n.replaceFirst(/^(?i)(The|A|An|)\s(.+)/, /$2, $1/) +" ($y) - ("+ info.originalName +")"}
Essentially it's an if else statement.
If {Title} and {Original Title} match then use {Title - (Year)} If they don't match use {Title (Year) - (Original Title)}

Output:
*\'Genre'\Guest, The (2014)
*\'Genre'\Demon, The (1978) - (Kichiku)
*\'Genre'\Our Day Will Come (2010) - (Notre Jour Viendra)
User avatar
Nhoise
Power User
Posts: 17
Joined: 08 Feb 2015, 20:15

Re: Solved: Help needed with original foreign movie titles

Post by Nhoise »

Thank you kindly, that looks way more reliable that what i came up with and it also seems to work slightly faster. Kudo's for helping out.
Post Reply