Movie Renaming Expression for "Studio" ?

All about user-defined episode / movie / file name format expressions
Post Reply
flecki
Posts: 4
Joined: 18 Jun 2020, 05:35

Movie Renaming Expression for "Studio" ?

Post by flecki »

BEGINNER Question!

Hello! I use MetaMovie by appfacture to tag my movies. Then I like to add the "studio" to my renaming, but I stuck with the expression for "studio".

MediaInfo shows as "ProductionStudio" but how can I put it into the right syntax?

It should look like this:

Warner Bros. Pictures - The Green Mile - 2000-02-10 - etc ...

I figured out everything so for, learning how to use filbot. But I stuck with that studio tag...

Can anyone help me out?
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Movie Renaming Expression for "Studio" ?

Post by kim »

Code: Select all

{info.productionCompanies}
AbedlaPaille
Posts: 107
Joined: 12 Apr 2020, 04:02

Re: Movie Renaming Expression for "Studio" ?

Post by AbedlaPaille »

Check out my Studios collections hardlinks, might help you understanding how it works.

Code: Select all

F:/Studios/

{info.productionCompanies =~ /Studio Ghibli/ ? 'Ghibli Collection' : info.productionCompanies =~ /Pixar/ ? 'Pixar Collection' : info.productionCompanies =~ /Marvel Studios/ ? 'MCU Collection' : ''}
	 
/

{y+'. '}

{norm = {it.slash('-').replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceAll(/\b[IiVvXx]+\b/, { it.upper() }).replaceAll(/\b[0-9](?i:th|nd|rd)\b/, { it.lower() })}; 
	{info.OriginalLanguage =~ /fr/ ? norm(localize.French.n) : norm(localize.English.n)}}

/

{info.OriginalLanguage =~ /fr/ ? norm(localize.French.ny) : norm(localize.English.ny)}

{! (info.OriginalLanguage ==~ /(en|fr)/) ? ' ('+norm(primaryTitle.ascii().upperInitial())+')' :''}

{tags ? ' '+tags : ' ['+fn.matchAll(/UNCENSORED|UNRATED|REMASTERED|EXTENDED|UNCUT|DIRECTOR\'?S[ ._-]CUT|THEATRICAL[ ._-]CUT|ULTIMATE[ ._-]CUT|FINAL[ ._-]CUT|SPECIAL[ ._-]EDITION/)*.upperInitial()*.sort().join(' ').replaceAll(/[.]/, " ") + ']'}

{any{' '+fn.match(/CD\d+/).upper()}
    {" CD$pi"}}

{allOf{vs}
      {vf}
      {channels.match(/5.1|7.1/)}
      {any{video.CodecID =~ /hev1|hevc|HEVC/ ? 'HEVC' : ''}
          {video.CodecID =~ /AVC|avc|avc1/ ? 'AVC' : ''}
          {vc}}
      {if (bitdepth == 10) '10bit'}
      {any{audio.size() > 2 ? 'MULTI' : audio.size() > 1 ? 'DUAL '+audioLanguages.join('-').upper() : ''}
          {audio[0].language != /en/ ? audioLanguages[0].name.upper() : ''}}
      {any{textLanguages =~ /fra/ ? 'VOSTFR' : textLanguages =~ /eng/ ? 'VOSTEN' : ''}
          {fn.match(/VOSTFR|Vostfr|vostFR|VostFR|vostfr/).upper()}}
      {mbps}.joining(' ', ' [', ']')}

{'.'+lang.ISO2}{if (ext == 'srt' && dc > 2) " ($di)"}
Keep in mind there's often a lot of production companies on a single movie.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Movie Renaming Expression for "Studio" ?

Post by kim »

doing same thing different

Code: Select all

{ info.productionCompanies =~ /Studio Ghibli/ ? 'Ghibli Collection' : info.productionCompanies =~ /Pixar/ ? 'Pixar Collection' : info.productionCompanies =~ /Marvel Studios/ ? 'MCU Collection' : '' } 

{ any{ def pc = info.productionCompanies; (pc =~ /Studio Ghibli/ ? 'Ghibli' : pc =~ /Pixar/ ? 'Pixar' : pc =~ /Marvel Studios/ ? 'MCU' : '') + ' Collection' }{''} } 

{ any{info.productionCompanies.join('*').match(/Ghibli|Pixar|Marvel Studios/).replace('Marvel Studios','MCU') + ' Collection'}{''} } 
Deadpool 2 ? ... maybe use keywords

Code: Select all

{ any{(info.productionCompanies.join('*').find(/Ghibli|Pixar/) || info.keywords.contains(/marvel cinematic universe/) ? 'MCU' : '') + ' Collection'}{''} }
flecki
Posts: 4
Joined: 18 Jun 2020, 05:35

Re: Movie Renaming Expression for "Studio" ?

Post by flecki »

Hello everybody!

I'm still a complete beginner with FileBot and I'm learning slowly.

My video files are all tagged with metadata and I want to generate movie names from this metadata. This works quite well so far.

Here is my expression:

Code: Select all

{media.ProductionStudio} - ({media.RecordedDate}) - {media.Title} - ({vf}) - ({media.OverallBitRateString.replace('/','p')}) - ({media.Framerate} fps) 
But there is one exception that drives me crazy:

"media.RecordedDate" is read out in a very unsightly format, either

"UTC 2016-11-10 12:00:00"
or
"2015-4-20T11:00:00Z"

and I still haven't found a way to make it look that way without the time and other stuff:

"2015-04-20"

No matter what I try, either there is nothing there anymore, or (with .format) yyyy-MM-dd is there instead of the date numbers. What can I do? I looked around in the forum and have tried ".parse" and ".format." so far.

Can anyone help me out?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Movie Renaming Expression for "Studio" ?

Post by rednoah »

You could use regular expressions to select the text you want:

Code: Select all

media.RecordedDate.match(/\d+-\d+-\d+/)
:idea: Please read the FAQ and How to Request Help.
flecki
Posts: 4
Joined: 18 Jun 2020, 05:35

Re: Movie Renaming Expression for "Studio" ?

Post by flecki »

Thats it!!! Woohoo! Thanks, rednoah! I am very apreciated!
flecki
Posts: 4
Joined: 18 Jun 2020, 05:35

Re: Movie Renaming Expression for "Studio" ?

Post by flecki »

rednoah wrote: 28 Jun 2020, 15:14 You could use regular expressions to select the text you want:

Code: Select all

media.RecordedDate.match(/\d+-\d+-\d+/)
may i ask an additional question? While doing it so works like a charm for my needs, i found that the date is this way: 2020-1-4 and i tried for days, figuring out how to add a 0 to 1-digit days and months, looking like this: 2020-01-04.

Is there a way to make it this way?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Movie Renaming Expression for "Studio" ?

Post by rednoah »

You'd have to split by - and then 0-pad each value and then join by - again.

A bit of basic Groovy programming will be helpful for writing that as Groovy code.


e.g.

Code: Select all

'2020-1-4'.split(/\D/)*.pad(2).join('-')
// Result: 2020-01-04
:idea: Please read the FAQ and How to Request Help.
SnakeBonD
Posts: 9
Joined: 23 Jan 2022, 15:09

Re: Movie Renaming Expression for "Studio" ?

Post by SnakeBonD »

I try to classify my movies by 'STUDIO' like this :

Code: Select all

{info.productionCompanies*.match(
	/DC Films/ : '/STUDIO/DC─COMICS/',
	/Warner Bros. Pictures/ : '/STUDIO/WARNER BROS/'
	).find()
}
Example of Aquaman

Code: Select all

{info.productionCompanies }
[Warner Bros. Pictures, The Safran Company, DC Films]

The script classefy Aquaman in Warner, and not in DC Comics:
_MOVIES/STUDIO/WARNER BROS/AQUAMAN/Aquaman (2018)

I think it classify according to the first results found.
But I want to prioritize some studios over others.
For example a DC Comics movie rather than Warner Bros. Have you an idea ?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Movie Renaming Expression for "Studio" ?

Post by rednoah »

e.g.

Format: Select all

{
	if ('DC Films' in info.productionCompanies)
		return '/STUDIO/DC─COMICS/'
	if ('Warner Bros. Pictures' in info.productionCompanies)
		return '/STUDIO/WARNER BROS/'
}
:idea: Please read the FAQ and How to Request Help.
SnakeBonD
Posts: 9
Joined: 23 Jan 2022, 15:09

Re: Movie Renaming Expression for "Studio" ?

Post by SnakeBonD »

Thanx rednoah, it's work for prioritize, but expression if word in need have exactly same word. Can I use more than one by request or I need one by one ?

Code: Select all

if ('DC Films, DC Entertainment' in info.productionCompanies)	return '/STUDIO/DC─COMICS/'

Code: Select all

	if ('DC Films' in info.productionCompanies)	return '/STUDIO/DC─COMICS/'
	if ('DC Comics' in info.productionCompanies)	return '/STUDIO/DC─COMICS/'	
	if ('DC Entertainment' in info.productionCompanies)	return '/STUDIO/DC─COMICS/'
With match I just need the beginning of a word, like 'DC '

[Warner Bros. Pictures, DC Comics, Syncopy, Legendary Pictures, Patalex III Productions Limited]
STUDIO\WARNER BROS\Batman Begins (2005)

[Warner Bros. Pictures, RatPac Entertainment, Atlas Entertainment, Cruel & Unusual Films, DC Entertainment]
STUDIO\WARNER BROS\Batman V Superman ː L'Aube De La Justice (2016)
SnakeBonD
Posts: 9
Joined: 23 Jan 2022, 15:09

Re: Movie Renaming Expression for "Studio" ?

Post by SnakeBonD »

I found another solution. I put priority studios first with any function:

Code: Select all

{// Classement des films par STUDIO, COLLECTION ou GENRE
	any
		{//Ranking by priority studios
			info.productionCompanies*.match(/DC Films/ : '/STUDIO/DC─COMICS/').find()}
		
		{//Ranking by others studios
			info.productionCompanies*.match(/Warner Bros. Pictures/ : '/STUDIO/WARNER BROS/').find()}
}
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Movie Renaming Expression for "Studio" ?

Post by rednoah »

You can use regex to match any set of text pattern:

Format: Select all

{
	if (info.productionCompanies =~ /DC/)
		return '/STUDIO/DC─COMICS/'
}

Format: Select all

{
	if (info.productionCompanies =~ /DC Films|DC Comics|DC Entertainment/)
		return '/STUDIO/DC─COMICS/'
}
:idea: Please read the FAQ and How to Request Help.
SnakeBonD
Posts: 9
Joined: 23 Jan 2022, 15:09

Re: Movie Renaming Expression for "Studio" ?

Post by SnakeBonD »

Yep, I think use that

Code: Select all

{
	if (info.productionCompanies =~ /DC Films|DC Comics|DC Entertainment/)
		return '/STUDIO/DC─COMICS/'+
		{collection
		.replaceAll(/[*\s]+/, " ")
		.replaceAll(/[`´‘’ʻ""“”.]/, "")
		.replaceAll(/[:*?"<()>|?]/)
		.replaceAll(/-/, "")
		.replaceAll(/(animation)/, "")
		.replaceAll(/Saga/, "")
		.replaceAll(/Collection/, "")
		.replaceAll(/Collezione/, "")
		.replaceAll(/Filmreihe/, "")
		.replaceAll(/Saga Collection/, "")
		.upper()+'/'}
}

{
	if (info.productionCompanies =~ /Marvel Studios|Marvel Entertainment|Marvel /)
		return '/STUDIO/MARVELS/'+
		{collection
		.replaceAll(/[*\s]+/, " ")
		.replaceAll(/[`´‘’ʻ""“”.]/, "")
		.replaceAll(/[:*?"<()>|?]/)
		.replaceAll(/-/, "")
		.replaceAll(/(animation)/, "")
		.replaceAll(/Saga/, "")
		.replaceAll(/Collection/, "")
		.replaceAll(/Collezione/, "")
		.replaceAll(/Filmreihe/, "")
		.replaceAll(/Saga Collection/, "")
		.upper()+'/'}
}
		
{
	if (info.productionCompanies =~ /Studio Ghibli|Ghibli/)
		return '/STUDIO/GHIBLI/'+
		{collection
		.replaceAll(/[*\s]+/, " ")
		.replaceAll(/[`´‘’ʻ""“”.]/, "")
		.replaceAll(/[:*?"<()>|?]/)
		.replaceAll(/-/, "")
		.replaceAll(/(animation)/, "")
		.replaceAll(/Saga/, "")
		.replaceAll(/Collection/, "")
		.replaceAll(/Collezione/, "")
		.replaceAll(/Filmreihe/, "")
		.replaceAll(/Saga Collection/, "")
		.upper()+'/'}
}
A bit heavy as code, no? Is there a possibility to optimize it?
I'm over 8192 character limit exceeded :mrgreen:
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Movie Renaming Expression for "Studio" ?

Post by rednoah »

Well, I mean you could write better code and not just exponentially copy & paste...


Personally, I would avoid copy & paste programming:

Format: Select all

{
	def studio = null

	if (info.productionCompanies =~ /DC /)
		studio = 'DC─COMICS'
	else if (info.productionCompanies =~ /Marvel /)
		studio = 'MARVELS'
	else if (info.productionCompanies =~ /Ghibli/)
		studio = 'GHIBLI'

	if (studio)
		return allOf{ 'STUDIO' }{ studio }{ collection.replaceAll(/[*\s]+/, " ").replaceAll(/[`´‘’ʻ""“”.:*?"<()>|?]|-|animation|Saga|Collection|Collezione|Filmreihe|Saga Collection/, "").upper() }.join('/')
}


That said, there is no 8192 character limit if you use external files, so copy & paste to your heart's desire:
viewtopic.php?t=10839
:idea: Please read the FAQ and How to Request Help.
SnakeBonD
Posts: 9
Joined: 23 Jan 2022, 15:09

Re: Movie Renaming Expression for "Studio" ?

Post by SnakeBonD »

Great news !
You reduced 200 lines of code to 15 lines! Thanks, that will make my job easier.
I didn't know, it will be easier to use an external file.
SnakeBonD
Posts: 9
Joined: 23 Jan 2022, 15:09

Re: Movie Renaming Expression for "Studio" ?

Post by SnakeBonD »

et voila :

Code: Select all

{file.path[0]}:/_MOVIES/

{any

{def anime = null
if (info.productionCompanies =~ /Toei Animation/)	anime = 'ANIMATION'
else if (info.keywords =~ /live action and animation/)	anime = 'ANIMATION'	
else if (info.keywords =~ /cartoon/)	anime = 'ANIMATION'	
else if (genre =~ /Animation/)	anime = 'ANIMATION'
else if (info.productionCompanies =~ /Ghibli/)	anime = 'ANIMATION'	
else if (info.productionCompanies =~ /C.O.R.E. Feature Animation/)	anime = 'ANIMATION'	
else if (info.productionCompanies =~ /DisneyToon Studios/)	anime = 'ANIMATION'	
else if (info.productionCompanies =~ /Walt Disney Animation/)	anime = 'ANIMATION'	
else if (info.productionCompanies =~ /Walt Disney Feature Animation/)	anime = 'ANIMATION'	
else if (info.productionCompanies =~ /Disney Television Animation/)	anime = 'ANIMATION'	
else if (info.productionCompanies =~ /Walt Disney Productions/)	anime = 'ANIMATION'	
else if (info.productionCompanies =~ /DreamWorks Animation/)	anime = 'ANIMATION'	
else if (info.productionCompanies =~ /Pixar/)	anime = 'ANIMATION'	
if (anime)
return allOf
{ anime+'/' }
{info.productionCompanies*.match(/Pixar/ : '/PIXAR/').find()}
{info.productionCompanies*.match(/DisneyToon Studios/ : '/DISNEY/').find()}
{info.productionCompanies*.match(/Walt Disney Animation/ : '/DISNEY/').find()}
{info.productionCompanies*.match(/Walt Disney Productions/ : '/DISNEY/').find()}
{info.productionCompanies*.match(/Walt Disney Pictures/ : '/DISNEY/').find()}
{info.productionCompanies*.match(/Walt Disney Feature Animation/ : '/DISNEY/').find()}
{info.productionCompanies*.match(/Disney Television Animation/ : '/DISNEY/').find()}
{info.productionCompanies*.match(/Sega/ : '/SEGA/').find()}
{info.productionCompanies*.match(/Ghibli/ : '/GHIBLI/').find()}
{info.productionCompanies*.match(/DreamWorks/ : '/DREAMWORKS/').find()}
{info.productionCompanies*.match(/Toei/ : '/TOEI/').find()}
{info.productionCompanies*.match(/Sony Pictures|Madhouse/ : '/MARVEL/').find()}
{ collection
.replaceAll(/[*\s]+/, " ")
.replaceAll(/[`´‘’ʻ""“”.:*?"<()>|?]|-|animation|Saga|Trilogy|Collection|Colección|Collezione|Filmreihe|Saga Collection/, "")
.upper()+'/' }
.join('/')
}

{def studio = null
if (info.productionCompanies =~ /Ghibli/)	studio = 'GHIBLI'
else if (info.keywords =~ /dc extended universe /)	studio = 'DC─COMICS'
else if (info.productionCompanies =~ /DC /)	studio = 'DC─COMICS'
else if (info.productionCompanies =~ /Marvel /)	studio = 'MARVELS'
else if (info.productionCompanies =~ /Lucasfilm/)	studio = 'LUCASFILM'
else if (info.productionCompanies =~ /EuropaCorp/)	studio = 'EUROPACORP'
else if (info.productionCompanies =~ /Warner Bros/)	studio = 'WARNER BROS'
else if (info.productionCompanies =~ /New Line Cinema/)	studio = 'NEW LINE'
else if (info.productionCompanies =~ /Sony/)	studio = 'SONY'
else if (info.productionCompanies =~ /Disney/)	studio = 'DISNEY'
else if (info.productionCompanies =~ /20th Century Fox/)	studio = 'CENTURY FOX'
else if (info.productionCompanies =~ /Paramount/)	studio = 'PARAMOUNT'
else if (info.productionCompanies =~ /Universal/)	studio = 'UNIVERSAL'
else if (info.productionCompanies =~ /NBC/)	studio = 'NBC'
else if (info.productionCompanies =~ /Lionsgate/)	studio = 'LIONSGATE'
else if (info.productionCompanies =~ /Metro-Goldwyn-Mayer/)	studio = 'MGM'
else if (info.productionCompanies =~ /UGC/)	studio = 'UGC'
else if (info.productionCompanies =~ /CANAL/)	studio = 'CANAL+'
else if (info.productionCompanies =~ /TF1/)	studio = 'TF1'
else if (info.productionCompanies =~ /M6/)	studio = 'M6'
if (studio)
return allOf{'/STUDIO/' }{ studio+'/' }
{ collection
.replaceAll(/[*\s]+/, " ")
.replaceAll(/[`´‘’ʻ""“”.:*?"<()>|?]|-|Animation|Saga|Trilogy|Collection|Colección|Collezione|Filmreihe|Saga Collection/, "")
.upper()+'/'
}
.join('/')
}

{allOf
	{//
	def order = ['Animation': 1, 'Musical': 2, 'Documentary': 3, 'Family': 4, 'History': 5, 'Science Fiction': 6, 'Horror': 7, 'Fantasy': 8, 'War': 9, 'Western': 10, 'Action': 11, 'Comedy': 12, 'Crime': 13, 'Thriller': 14, 'Adventure': 15, 'Mystery': 16, 'Romance': 17, 'Drama': 18].withDefault{ 100 }
	def map = ['Science Fiction': 'Sci-Fi']
	def genres = genres.toSorted{ order[it] }*.replace(map)
	'GENRE/'+genres.first().upper()+'/'
	}
	{//Classe les films par COLLECTION
	collection
	.replaceAll(/[*\s]+/, " ")
	.replaceAll(/[`´‘’ʻ""“”.:*?"<()>|?]|-|animation|Saga|Trilogy|Collection|Colección|Collezione|Filmreihe|Saga Collection/, "")
	.upper()+'/'
	}
	.join('/')
}

{'/INCLASSABLE/'}
}

{norm={it
	.upperInitial()
	.asciiQuotes()
	.lowerTrail()
	.replaceTrailingBrackets()
	.replaceAll(/[`´‘’ʻ""“”]/, ' ')
	.replaceAll(':', 'ː')
	.replaceAll(/[?]/, '?')
	.replaceAll(/[*\s]+/, ' ')
	.replaceAll(/\b[IiVvXx]+\b/, { it.upper() })
	.replaceAll(/\b[3d]+\b/, { it.upper() })
	.replaceAll(/\b[0-9](?i:th|nd|rd)\b/, { it.lower() })
	}; norm(n)
}

{any
	{" ("+d.format("yyyy")+")"}
	{" ("+y+")"}
}

{ if (norm(n) != norm(primaryTitle)) ' {'+norm(localize.en.n)+'}' }

{" ["+rating+"★]"}

{" [tmdb_"+tmdbId+"]"}

{
' ['}

{any
	{audio.Language =~ 'en' && text.language =~ 'fr' ? 'EN_FR ' : ''}
	{audio.Language =~ 'ja' && text.language =~ 'fr' ? 'JA_FR ' : ''}
	{audio.Language =~ 'ru' && text.language =~ 'fr' ? 'RU_FR ' : ''}
	{audio.Language =~ 'es' && text.language =~ 'fr' ? 'ES_FR ' : ''}
	{audio.Language =~ 'pt' && text.language =~ 'fr' ? 'PT_FR ' : ''}
	{audio.Language =~ 'de' && text.language =~ 'fr' ? 'DE_FR ' : ''}
	{audio.Language =~ 'sv' && text.language =~ 'fr' ? 'SV_FR ' : ''}
	{audio.Language =~ 'it' && text.language =~ 'fr' ? 'IT_FR ' : ''}
	{audio.Language =~ 'ko' && text.language =~ 'fr' ? 'KO_FR ' : ''}
	{audio.Language =~ 'nl' && text.language =~ 'fr' ? 'NL_FR ' : ''}
	{audio.Language =~ 'fi' && text.language =~ 'fr' ? 'FI_FR ' : ''}
	{audio.Language =~ 'zh' && text.language =~ 'fr' ? 'ZH_FR ' : ''}
	{audio.Language =~ null && text.language =~ 'fr' ? 'null_FR ' : ''}
	{audio.Language =~ 'fr' && text.language =~ null ? 'FR_null ' : ''}
	{audio.Language =~ 'fr' && text.language =~ 'fr' ? 'FR_FR ' : ''}
	{audio.Language =~ null && text.language =~ null ? 'null_null ' : ''}
	{audio.size() < 1 && text.language =~ null ? 'FR ' : ''}
}

{vf}	{channels}
{']'}
Post Reply