A little help with my naming script

All about user-defined episode / movie format expressions
Post Reply
Phatty
Posts: 9
Joined: 01 May 2019, 15:17

A little help with my naming script

Post by Phatty »

Hi Guys

I was very proud of how I managed cut up others code and chomp it together to get my naming convention.
I recently started using it on my new linux GCP VM but it would seem there is one part of this naming does not carry over very well (the "/" causes it to create a new sub folder).

Anyone able to help re jig this so that rather than a / it - or + or even just a space.

The other thing I would love to add is the ability to add [Director cut] [extended] etc...

Any help would be appreciated.

Code: Select all

G:/Movies/{n.colon(' - ')} ({y})/{n.colon(' - ')} ({y}){' CD'+pi} - {vf} {
def mHDRCol = ["BT.709" : "NO", "BT.2020" : "YES"];
if(self.video[0].bitdepth != null && self.bitdepth >= 10 && self.video[0].colourprimaries != null &&  mHDRCol.get(self.video[0].colourprimaries) == "YES") 'HDR ' else '';
} {video[0].bitdepth.match('10') ? '[10bit]' : null} {vc} {
def best = any{audio.max{it.StreamSize.toInteger()}}{ audio.max{it.BitRate.replaceAll(/Unknown\s?\/\s?/).split(' / ')*.toInteger().max()}}{null};
def ChannelString = any{(best.'ChannelPositionsString2'.replaceAll(/Object\sBased\s\/|(\d+)?\sobjects\s\/|0.(?=\d.\d)/, '').split(' / ').collect{ it.split('/')*.toDouble().sum() }.max()).toString()}{null};
def audioCodec = (ac == 'MP3'||ac == 'AAC') ? ac : any{best.FormatProfile ? (best.Codec+'.'+best.FormatProfile.replaceAll(/\s?\/.*|E-AC-3\+|TrueHD|AC3|Matrix/)).replaceAll(/\.\+|\+\./, '+').replaceAll(/\.$/).replaceAll(/DTS\./, 'DTS-') : null}{best.Codec}{aco}{ac}{'ERROR'};
allOf{audioCodec}{any{ChannelString}{channels}}.join(' ');
}{subt}
kim
Power User
Posts: 1027
Joined: 15 May 2014, 16:17

Re: A little help with my naming script

Post by kim »

what does this mean ?
Phatty wrote: 24 May 2020, 21:54 I recently started using it on my new linux GCP VM but it would seem there is one part of this naming does not carry over very well (the "/" causes it to create a new sub folder).

Anyone able to help re jig this so that rather than a / it - or + or even just a space.
are you using format in CLI or GUI ?
(if CLI you may need to escape something?)

better code of your format:

Code: Select all

{'G:/Movies/'}
{ny}
{'/' + ny}
{' ' + tags}
{any{' CD' + pi}{}}
{' - ' + vf}
{def mHDRCol = ["BT.709" : "NO", "BT.2020" : "YES"];
	if(self.video[0].bitdepth != null && self.bitdepth >= 10 && self.video[0].colourprimaries != null && mHDRCol.get(self.video[0].colourprimaries) == "YES") 'HDR ' else ''}
{any{video[0].bitdepth.match('10') ? ' [10bit]' : null}{}}
{' ' + vc}
{def best = any{audio.max{it.StreamSize.toInteger()}}{ audio.max{it.BitRate.replaceAll(/Unknown\s?\/\s?/).split(' / ')*.toInteger().max()}}{null};
def ChannelString = any{(best.'ChannelPositionsString2'.replaceAll(/Object\sBased\s\/|(\d+)?\sobjects\s\/|0.(?=\d.\d)/, '').split(' / ').collect{ it.split('/')*.toDouble().sum() }.max()).toString()}{null};
def audioCodec = (ac == 'MP3'||ac == 'AAC') ? ac :
	any{best.FormatProfile ? (best.Codec+'.'+best.FormatProfile.replaceAll(/\s?\/.*|E-AC-3\+|TrueHD|AC3|Matrix/)).replaceAll(/\.\+|\+\./, '+').replaceAll(/\.$/).replaceAll(/DTS\./, 'DTS-') : null}{best.Codec}{aco}{ac}{'ERROR'};
	' '+ allOf{audioCodec}{any{ChannelString}{channels}}.join(' ')}
{subt}
Also you may want to look here:
viewtopic.php?f=5&t=5285&p=48827#p48827

e.g.

Code: Select all

{'G:/Movies/'}
{ny}
{'/' + ny}
{' ' + tags}
{any{' CD' + pi}{}}
{' - ' + vf}
{def mHDRCol = ["BT.709" : "NO", "BT.2020" : "YES"];
	if(self.video[0].bitdepth != null && self.bitdepth >= 10 && self.video[0].colourprimaries != null && mHDRCol.get(self.video[0].colourprimaries) == "YES") 'HDR ' else ''}
{any{video[0].bitdepth.match('10') ? ' [10bit]' : null}{}}
{' ' + vc}
{
	def preferredLang = 'Eng'
	def useChFilter = false
	def filter = { [it.codec, it.ch] }

	def codecList =
	[
	'MP3' : 'MP3',
	'PCM' : 'PCM',
	'AAC LC' : 'AAC',
	'AAC LC SBR' : 'AAC',
	'AAC LC SBR PS' : 'AAC',
	'AC 3' : 'AC3',
	'AC 3 Dep' : 'EAC3',
	'E AC 3' : 'EAC3',
	'E AC 3 JOC' : 'EAC3 Atmos',
	'AC 3 Dep JOC' : 'EAC3 Atmos',
	'DTS' : 'DTS',
	'DTS 96 24' : 'DTS 96-24',
	'DTS ES' : 'DTS-ES',
	'DTS ES XXCH' : 'DTS-ES',
	'DTS XBR' : 'DTS-HD HRA',
	'DTS ES XBR' : 'DTS-HD HRA',
	'DTS ES XXCH XBR' : 'DTS-HD HRA',
	'DTS XLL' : 'DTS-HD MA',
	'DTS ES XLL' : 'DTS-HD MA',
	'DTS ES XXCH XLL' : 'DTS-HD MA',
	'DTS XLL X' : 'DTS X',
	'MLP FBA' : 'TrueHD',
	'MLP FBA 16 ch' : 'TrueHD Atmos'
	]

	def audioStreams = []
	def audioClean = { it.replaceAll(/[\p{Pd}\p{Space}]/, ' ').replaceAll(/\p{Space}{2,}/, ' ').slash(' ') }
	def channelClean = { it.replaceAll(/Debug.+|Object\sBased\s?\/?|(\d+)?\sobjects\s\/\s|0.(?=\d.\d)|20/).replaceAll(/6.0/,'5.1').replaceAll(/8.0/,'7.1') }
	def oneStream = { it.collect{ filter(it) }*.minus(null).unique().flatten().join(' ') }
	def dString = { it.toDouble().toString() }
	def toInt = { it.toInteger() }

	any{audio.collect{ au ->
		def codec = audioClean(any{ au['CodecID/Hint'] }{ au['Format'] })
		def format_profile = any{ audioClean(au['Format_AdditionalFeatures'])}{}
		def String ch = any{ channelClean(au.ChannelPositionsString2).tokenize('\\/')*.toDouble().toString().sum() }
			{ channelClean(dString(au.ChannelsOriginal)) } { channelClean(dString(au.Channels)) }

		def chFilter =	( ( ( (ac == 'AAC'||ac == 'MP3') && ch != '2.0') || ( (ac == 'AC3'||ac == 'EAC3'||ac == 'DTS'||ac == 'TrueHD'||ac == 'MLPFBA') && ch != '5.1' ) ) ? ch : null )

		def combined = allOf{codec}{format_profile}.join(' ')

		audioStreams << ['index' : codecList.findIndexOf { it.key == combined }, 'default' : any {au['default'][0].toBoolean() }{ audio.size == 1 ? true : '' },
		'codec' : codecList.get(combined, 'Add to "' + combined + '" codecList'), 'combined' : combined, 'ch' : useChFilter ? chFilter : ch,
		'bitrate' : any{ toInt(au.BitRate) }{ toInt(au.BitRate_Maximum) }{ dString(au.FrameRate) }{null},
		'objects' : any{ '[' + au['NumberOfDynamicObjects'] + ' Objs]' }{null}, 'lang' : any{ au.'LanguageString3'.upperInitial() }{null} ]
		return audioStreams
	}

	def addToList = audioStreams.codec.findAll{ it.contains('Add to') }.unique().sort()
	def bestBitRate = oneStream(audioStreams.findAll{ it.bitrate == audioStreams.bitrate.max() })

	' ' + any{addToList}{bestBitRate}
	}{'NO_AUDIO'}
}
{subt}
Phatty
Posts: 9
Joined: 01 May 2019, 15:17

Re: A little help with my naming script

Post by Phatty »

kim wrote: 24 May 2020, 23:09 what does this mean ?
Phatty wrote: 24 May 2020, 21:54 I recently started using it on my new linux GCP VM but it would seem there is one part of this naming does not carry over very well (the "/" causes it to create a new sub folder).

Anyone able to help re jig this so that rather than a / it - or + or even just a space.
are you using format in CLI or GUI ?
(if CLI you may need to escape something?)
I am using the GUI, my dev skills are next to none but with a lot of trail and error I managed to put that code on my first post together.
Perhaps this screen shot can explain it a little better (the mask of zorro film will end up with in a folder called something like

Code: Select all

the mask of zorro.....
with the file name of

Code: Select all

True HD 7.1.mkv
(sorry not sure how to get an image from clipboard in here, its asking for an image URL) https://photos.app.goo.gl/FYwgvgQtrHXzgqKf8

Thanks for the link to that thread about audio codecs I actually think that is where I got my original audio codec section from, ill take another look to see if I missed something.

Thanks again (it's late here so ill test tomorrow and let you know how the new revamped code works).
Also impressed with the speedy reply!

Update:
Could not wait, so just checked it, I can confirm I still have the same issues as explained in the image I linked above, its making files called True HD 7.1.mkv in a folder with the first part of the name
kim
Power User
Posts: 1027
Joined: 15 May 2014, 16:17

Re: A little help with my naming script

Post by kim »

what version of filebot are you using ?
because I think you are using an old mediainfo file (lower then 19.04 i think)

the easy fix is:
add

Code: Select all

.replaceAll(/\//, '+')
like so

Code: Select all

allOf{audioCodec}{any{ChannelString}{channels}}.join(' ').replaceAll(/\//, '+')
if you use newer mediainfo then try my 'e.g.' from above
https://mediaarea.net/en/MediaInfo

btw:
the format is something i also made a all time ago ;)
FYI: it does not work with newer mediainfo
viewtopic.php?f=4&t=6259&p=36159#p36159
Phatty
Posts: 9
Joined: 01 May 2019, 15:17

Re: A little help with my naming script

Post by Phatty »

you legend, that worked perfectly! thanks! :D
Post Reply