How to distinguish Subtitles from Groupname?

All about user-defined episode / movie / file name format expressions
Post Reply
Elamania
Posts: 39
Joined: 07 Sep 2015, 23:00

How to distinguish Subtitles from Groupname?

Post by Elamania »

Hello,
I want to name all the external Subtitles as the name of the Movie and only add the language and if it´s forced or not.

My problem i that often "forced" is taken as the groupname then or even the full eng-forced as it.
It is due to this additional group check:
{" ["+fn.match(/(?<=[-])\w+$/) +"]"}
which is matching forced and such. However, I cannot not use it since then a lot of groupnames would not be recognized.

I have now:

Code: Select all

{fileFolder={
		
		def genre=null;
		if(genres.contains("Horror")){
		genre=	"Horror Movies";
		}
		else if (genres.contains("Animation")){
		genre=	"Animation Movies";
		 }
		 else if (genres.contains("Komödie")){
			genre= "Comedy Movies";
		 }
		 else if (genres.contains("Drama")){
			genre= "Drama Movies";		 
		 }
		 else if (genres.contains("Science Fiction")){
			genre= "SciFi Movies";		 
		 }
		 else if (genres.contains("Action")){
			genre= "Action Movies";		 
		 }
		  else if (genres.contains("Abenteuer")){
			genre= "Adventure Movies";		 
		 }  
		else{
			genre="Movies";
		}
		return genre;
	}};
 {file.path[0]}:/Movies/{fileFolder}/ {collection+'/'} 
 {ny}/
{f.subtitle ? "Subs/" : null}   
 {ny}
 {' - ' + fn.matchAll(/extended|uncensored|remastered|unrated|uncut|Theatrical|Theatrical.Cut|Theatrical.edition|directors.cut|special.edition|imax|anniversary/)*.toUpperCase().sort().join(', ').replaceAll(/[._]/, " ")}  
 [{allOf{audio.language.contains("de") ? "Ger" : null}{audio.language.contains("en") ? "Eng" : null}{audio.language.contains("ja") ? "Jap" : null} join ""}]
 [{allOf{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""}{source.replace(/BluRay/,"BD").replace(/BDRip/,"BD")}{vf}{hdr}{video.bitdepth=='10' ? '10Bit' : null}{ac.replace(/MPEG Audio/,"mpg")}{channels}{vc} join "_"}]
{any{" ["+ group +"]"}{" ["+fn.match(/(?<=[-])\w+$/) +"]"}}{any{subt}{if(f.subtitle)fn.match(/.\w+$/).replaceAll(/\P{Alpha}+/,'.').toLowerCase().removeAll(/.(p|pro|contribution)$/).removeAll(/[.]$/)}{fn =~ /forced$/ ? '.forced' : null}}
	
If I use it like that I will get:
filename-Englisch-Forced -> filename [FORCED].eng.forced
filename_4608-eng1080 -> filename [eng1080].eng
filename-1080p-eng -> filename [eng].eng
So, the Subtitles are at least correctly recognized but they are also often recognized as groupname due to the phrase above. Obviously that means that the groupname is wrong anyway.

What can I do to recognize the correct Subtitle names and most of the groups?

If I remove everything relating to the Subtitles from the Scheme then the recognition is higher, but still not very good. eg.:
filename.x264-FDHQ -> filename [FDHQ]
filename.x265-FD -> filename [FD]
filename [WodkaE] -> filename
filename [EXQUISITE] ->filename
filename-Wodkae ->filename[Wodkae]
If I remove the "fn.match.." from the group the recognition is way worse, but forced and such is not recognized as a Sub anymore.

Is there an easy way to recognize the Subtitles correctly and at least more Groupnames?


2.)
How do I define an own method?
The "fileFolder" part is not working and I have no idea why.
I just want to move less kid friendly movies into other folders.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: How to distinguish Subtitles from Groupname?

Post by kim »

{fileFolder='dude'} = 'dude'
{fileFolder} = new {} = null

it only works IF within same {}
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: How to distinguish Subtitles from Groupname?

Post by kim »

maybe you can use?

Code: Select all

{ def order = ['Horror': 1, 'Animation': 2, 'Comedy': 3, 'Science Fiction': 4, 'Action': 5, 'Adventure': 6].withDefault{ 100 }
		def map = ['Science Fiction': 'SciFi']
		def genres = localize.eng.genres.toSorted{ order[it] }*.replace(map)
		genres.first()+ ' Movies'
}
Custom Collections Library
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to distinguish Subtitles from Groupname?

Post by rednoah »

1.
Looks like {group} doesn't work well for standalone subtitle files. File-based bindings are usually based on the primary video file, which in the case of subtitles is a nearby video file.

Here's what I get from the built-in bindings for a simple test case:

Code: Select all

$ filebot -mediainfo . --format "{group} | {subt} | {f.name}"
WodkaE | .eng.forced | Avatar 2009 WodkaE.eng-forced.srt
WodkaE |  | Avatar 2009 WodkaE.mp4
:idea: I can't quite help you fix your entire format all at once, but if you can post simple test cases for simple components that don't work as expected, then we can look at those one by one, so that you can then build your complex format best on those simple components that are known to work as expected.



2.
You can't define your own top-level bindings. You can define local variables and local methods though, but those will only be valid within the same top-level {...} expression.

If you're familiar with Groovy, then you may prefer to express your format within a single top-level {...} expression so that all your code runs within the same Groovy context to give yourself more control, i.e. local variables, local methods, exception handling, etc:

Code: Select all

{
	def fileName = "$n [$y]"
	def folderName = any{genres[0]}{'No Genre'}
	return "Movies" / folderName / fileName
}
:idea: viewtopic.php?t=1895
:idea: Please read the FAQ and How to Request Help.
Post Reply