Can we use external file for fn:renall script

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
stephen147
Donor
Posts: 131
Joined: 01 Sep 2015, 22:40

Can we use external file for fn:renall script

Post by stephen147 »

I've been trying to point to a groovy file for the fn:renall script like so:

Code: Select all

set "FOLDER_PROCESS=_To Process"
set "FOLDER_ROOT=Z:/Movies & TV/_Newly DL'd"
set "GROOVY_MOVIE=Movie Format.groovy"

filebot -script fn:renall "%FOLDER_ROOT%/%FOLDER_PROCESS%" -non-strict ^
--format @"%FOLDER_ROOT%/%GROOVY_MOVIE%" ^
--action test --log info ^
--db TheMovieDB ^
--def target=folder
@pause
Is there any way to do the same as the amc script? e.g.

Code: Select all

--def movieFormat=@"path/to/groovy/file.groovy"
:!: This would be useful to have the same groovy file for both.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Can we use external file for fn:renall script

Post by rednoah »

Yes, but only for single-line formats:
viewtopic.php?f=4&t=3244

Best to use PowerShell or Groovy so you can easily build command-line scripts. CMD is not your friend.

e.g.

Code: Select all

$VALUE = @"
Bob
went
to town
to buy
a fat
pig.
"@

Write-Host "$VALUE"
:idea: Please read the FAQ and How to Request Help.
stephen147
Donor
Posts: 131
Joined: 01 Sep 2015, 22:40

Re: Can we use external file for fn:renall script

Post by stephen147 »

New to PowerShell.

Here's the ps1 I have. I've tried the Get-Content function here.

Code: Select all

$FOLDER_PROCESS="_To Process"
$FOLDER_ROOT="Z:/Movies & TV/_Newly DL'd"
$GROOVY_MOVIE="Movie Format.groovy"
$FMT=(Write-Host (Get-Content $FOLDER_ROOT"/"$GROOVY_MOVIE))

filebot -script fn:renall $FOLDER_ROOT"/"$FOLDER_PROCESS -non-strict --format $FMT --db TheMovieDB
filebot -script fn:renall $FOLDER_ROOT"/"$FOLDER_PROCESS -non-strict --format $FMT --db TheMovieDB --def target=folder
Then my external file:

Code: Select all

{
def space = call{' '}
def ChannelString = any{(0.0+audio.'ChannelPositionsString2'*.replaceAll(/Object\sBased\s\/|0.(?=\d.\d)/, '')*.split(' / ')*.collect{ it.split('/')*.toBigDecimal().sum() }*.max().max()).toString()}{channels};
def codecSubVersion = any{audio.any{ a -> call{a.FormatProfile} =~ 'HRA' } ? '.HRA' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'X / MA / Core' } ? '-X' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'MA / Core' } ? '.MA' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'ES Matrix / Core' } ? '-ES' : null}{null};
def codecVersion = any{audio.Codec.join().match(/DTS-HD/)+codecSubVersion+'.'+audio.Codec.join().match(/TrueHD/)}{audio.Codec.join().match(/DTS-HD/) && codecSubVersion == '-X' ? 'DTS-X' : null}{audio.Codec.join().match(/DTS-HD/)+codecSubVersion}{audio.Codec.join().match(/TrueHD/)}{audio.Codec.join().match(/DTS/)+codecSubVersion.replaceAll(/null/)}{ac};
def dir_root = call{'Z:/Movies & TV/'};
call{hd.matches(/(?i)SD/) ? '480p-720p/' : ''}+
call{hd.matches(/(?i)HD/) ? '720p-1080p/' : ''}+
call{hd.matches(/(?i)UHD/) ? '4k/' : ''};
def main_title =
call{n.replace(':','-').replaceAll(/[\/:*?"<>|]/,' - ')}+
space + '(' + call{y} + ')'+
space + call{fn.matches(/(?i).+\b25th.+?anniv.+/) ? '(25th Anniv. Edition)' : ''}+
space + call{fn.matches(/(?i).+\b\(limited\b.*?\).+/) ? '(Limited Edition)' : ''}+
space + call{fn.matches(/(?i).+\b\(uncut\b.*?\).+/) ? '(Uncut)' : ''}+
space + call{fn.matches(/(?i).+\bcollector.+?s.+?edition\b.+/) ? '(Collector\'s Edition)' : ''}+
space + call{fn.matches(/(?i).+\bdirect.+?cut\b.+/) ? '(Director\'s Cut)' : ''}+
space + call{fn.matches(/(?i).+\bextended.+?\b.+/) ? '(Extended)' : ''}+
space + call{fn.matches(/(?i).+\bextended.+?edit\b.+/) ? '(Extended Edition)' : ''}+
space + call{fn.matches(/(?i).+\bimax\b.+/) ? '(IMAX Edition)' : ''}+
space + call{fn.matches(/(?i).+\blimited\b.+/) ? '(Limited)' : ''}+
space + call{fn.matches(/(?i).+\bremastered\b.+/) ? '(Remastered)' : ''}+
space + call{fn.matches(/(?i).+\bsuper.+duper.+cut\b.+/) ? '(Super Duper Cut)' : ''}+
space + call{fn.matches(/(?i).+\btheatrical\b.+/) ? '(Theatrical)' : ''}+
space + call{fn.matches(/(?i).+\bunrated\b.+/) ? '(Unrated)' : ''}+
space + call{any{fn.match(/\([^\()+?[^\d]+?\)\s*/)} {''}{''}}+
space + call{self.vf ? self.vf : self.hpi}+
space + call{hd}+
space + call{source.matches(/(?i)blu.*ray/) ? 'Blu-ray' : {source} ?: 'WEB-DL'}+
space + call{fn.matches(/(?i).+\bremux\b.+/) ? 'REMUX' : ''}+
space + call{self.hdr ? self.hdr + bitdepth + 'bit' : 'non-HDR'}+
space + call{vc}+
space + call(allOf{codecVersion.replaceAll(/null/)}{ChannelString + 'ch'}{aco.match(/Atmos/)}).join(' ')+
'_'+
call{any{"$group"}{fn.match(/(?<=[_-])[^\s_-]+?$/)}{'NA'}.replaceAll(/[-_\[\]]\s*|\.\w{3}$/, '')};
def lang = call{any{'.'+lang}{lang}}+{fn.matches(/(?i).+sdh.+/) ? '_SDH' : ''}{any{fn.match(/(?i)\(foreignpartsonly\)/)}{''}};
def ext = call{'.'+ext};
(main_title + lang).replaceAll(/null/).toString()
}
:!: Not sure if this FORMAT is even possible with FN:Renall. Works the best with the AMC script.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Can we use external file for fn:renall script

Post by rednoah »

1.
Formats do work the same in both GUI and CLI. Both amc and renall scripts do internally call the same rename() method.


2.
You can use filebot -script fn:sysenv to echo arguments exactly as received by FileBot, so you can check if the format FileBot does get is exactly the same as the one you have in your text file.
:idea: Please read the FAQ and How to Request Help.
stephen147
Donor
Posts: 131
Joined: 01 Sep 2015, 22:40

Re: Can we use external file for fn:renall script

Post by stephen147 »

1. That's strange, I've run into no issue with that format code in amc or via the GUI.

2. Ather running this in PowerShell with the same format as above:

Code: Select all

filebot -script fn:sysenv
$FOLDER_PROCESS="_To Process"
$FOLDER_ROOT="Z:/Movies & TV/_Newly DL'd"
$GROOVY_MOVIE="Movie Format.groovy"
$FORMAT=(Write-Host (Get-Content $FOLDER_ROOT"/"$GROOVY_MOVIE))
filebot -script fn:renall $FOLDER_ROOT"/"$FOLDER_PROCESS -non-strict --format "$FORMAT" --db TheMovieDB --action test --log info
The output is as follows:

Code: Select all

# Environment Variables #
GOOGLE_DEFAULT_CLIENT_ID: no
USERDOMAIN_ROAMINGPROFILE: DESKTOP-REDACTED
PROCESSOR_LEVEL: 23
VS140COMNTOOLS: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
SESSIONNAME: Console
ALLUSERSPROFILE: C:\ProgramData
INTEL_DEV_REDIST: C:\Program Files (x86)\Common Files\Intel\Shared Libraries\
PROCESSOR_ARCHITECTURE: AMD64
GOOGLE_DEFAULT_CLIENT_SECRET: no
PSModulePath: C:\Users\username_redacted\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\Intel\Wired Networking\
ADSK_3DSMAX_x64_2016: C:\Program Files\Autodesk\3ds Max 2016\
SystemDrive: C:
ADSK_3DSMAX_x64_2017: C:\Program Files\Autodesk\3ds Max 2017\
USERNAME_redacted: username_redacted
RF_10_PATH: C:\Program Files\Next Limit\RealFlow 10
ProgramFiles(x86): C:\Program Files (x86)
FPS_BROWSER_USER_PROFILE_STRING: Default
PATHEXT: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL
DriverData: C:\Windows\System32\Drivers\DriverData
ProgramData: C:\ProgramData
VRAY30_RT_FOR_3DSMAX2016_PLUGINS_x64: C:\Program Files\Chaos Group\V-Ray\RT for 3ds Max 2016 for x64/bin/plugins
ProgramW6432: C:\Program Files
BEATUNES_MEMORY: -Xmx1024m
HOMEPATH: \Users\username_redacted
PROCESSOR_IDENTIFIER: AMD64 Family 23 Model 1 Stepping 1, AuthenticAMD
ProgramFiles: C:\Program Files
PUBLIC: C:\Users\Public
windir: C:\WINDOWS
=::: ::\
LOCALAPPDATA: C:\Users\username_redacted\AppData\Local
USERDOMAIN: DESKTOP-REDACTED
FPS_BROWSER_APP_PROFILE_STRING: Internet Explorer
LOGONSERVER: \\DESKTOP-REDACTED
VRAY_MDL_PATH_3DSMAX2016_x64: C:\Program Files\Chaos Group\V-Ray\3dsmax 2016 for x64\mdl
asl.log: Destination=file
OneDrive: C:\Users\username_redacted\OneDrive
APPDATA: C:\Users\username_redacted\AppData\Roaming
J2D_D3D: true
GOOGLE_API_KEY: no
VBOX_MSI_INSTALL_PATH: C:\Program Files\Oracle\VirtualBox\
VRAY_OSL_PATH_3DSMAX2016_x64: C:\Program Files\Chaos Group\V-Ray\3dsmax 2016 for x64\opensl
CommonProgramFiles: C:\Program Files\Common Files
Path: C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\ImageMagick-7.0.6-Q16;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\PixPlant2Photoshop\x64;C:\Program Files\PixPlant2Photoshop;C:\Program Files\Common Files\Autodesk Shared\;C:\Users\username_redacted\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Autodesk\Backburner\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\AOMEI Backupper;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\PuTTY\;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files (x86)\Common Files\Acronis\VirtualFile\;C:\Program Files (x86)\Common Files\Acronis\VirtualFile64\;C:\Program Files (x86)\Common Files\Acronis\FileProtector\;C:\Program Files (x86)\Common Files\Acronis\FileProtector64\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;Z:\Downloads\Streamlink\bin;C:\ffmpeg\bin;C:\Users\username_redacted\AppData\Local\Microsoft\WindowsApps;;C:\Program Files\WindowsApps\PointPlanck.FileBot_4.8.5.0_x64__49ex9gnthnt12\jre\bin
OS: Windows_NT
COMPUTERNAME: DESKTOP-REDACTED
VRAY30_RT_FOR_3DSMAX2016_MAIN_x64: C:\Program Files\Chaos Group\V-Ray\RT for 3ds Max 2016 for x64/bin
VRAY_SEND_FEEDBACK: 0
metaflac.exe: Z:\Music\Programs\_Portable Installs\Mp3tag\_DO NOT DELETE\flac-1.3.2-win\win32\metaflac.exe
PROCESSOR_REVISION: 0101
CommonProgramW6432: C:\Program Files\Common Files
ComSpec: C:\WINDOWS\system32\cmd.exe
SystemRoot: C:\WINDOWS
TEMP: C:\Users\PC~1\AppData\Local\Temp
HOMEDRIVE: C:
USERPROFILE: C:\Users\username_redacted
TMP: C:\Users\PC~1\AppData\Local\Temp
CommonProgramFiles(x86): C:\Program Files (x86)\Common Files
NUMBER_OF_PROCESSORS: 32
RG_GPU_FRAMEWORK_ENGINE_RESOURCEDIR: C:\Program Files\Red Giant\RGFX


# Java System Properties #
awt.toolkit: sun.awt.windows.WToolkit
java.specification.version: 11
sun.cpu.isalist: amd64
sun.jnu.encoding: Cp1252
net.filebot.AcoustID.fpcalc: C:\Program Files\WindowsApps\PointPlanck.FileBot_4.8.5.0_x64__49ex9gnthnt12\lib\fpcalc.exe
sun.arch.data.model: 64
java.vendor.url: http://java.oracle.com/
jna.nounpack: true
sun.boot.library.path: C:\Program Files\WindowsApps\PointPlanck.FileBot_4.8.5.0_x64__49ex9gnthnt12\jre\bin
sun.java.command: C:\Program Files\WindowsApps\PointPlanck.FileBot_4.8.5.0_x64__49ex9gnthnt12\jar\filebot.jar -script fn:sysenv
jdk.debug: release
sun.stderr.encoding: cp850
java.specification.vendor: Oracle Corporation
jdk.module.path: C:\Program Files\WindowsApps\PointPlanck.FileBot_4.8.5.0_x64__49ex9gnthnt12\jre\ext\modules\lib
java.version.date: 2019-01-15
java.home: C:\Program Files\WindowsApps\PointPlanck.FileBot_4.8.5.0_x64__49ex9gnthnt12\jre
file.separator: \
java.vm.compressedOopsMode: Zero based
line.separator:

sun.stdout.encoding: cp850
java.specification.name: Java Platform API Specification
java.vm.specification.vendor: Oracle Corporation
useNativeShell: false
user.script:
sun.management.compiler: HotSpot 64-Bit Tiered Compilers
java.runtime.version: 11.0.2+9
user.name: username_redacted
sun.net.client.defaultConnectTimeout: 10000
java.net.useSystemProxies: true
file.encoding: Cp1252
java.vendor.version: 18.9
application.update: skip
java.io.tmpdir: C:\Users\username_redacted\AppData\Roaming\FileBot\tmp
swing.crossplatformlaf: javax.swing.plaf.nimbus.NimbusLookAndFeel
java.version: 11.0.2
java.vm.specification.name: Java Virtual Machine Specification
java.awt.printerjob: sun.awt.windows.WPrinterJob
sun.os.patch.level:
application.deployment: appx
java.library.path: C:\Program Files\WindowsApps\PointPlanck.FileBot_4.8.5.0_x64__49ex9gnthnt12\lib
java.vendor: Oracle Corporation
application.dir: C:\Users\username_redacted\AppData\Roaming\FileBot
sun.io.unicode.encoding: UnicodeLittle
sun.desktop: windows
java.class.path: C:\Program Files\WindowsApps\PointPlanck.FileBot_4.8.5.0_x64__49ex9gnthnt12\jar\filebot.jar
java.vm.vendor: Oracle Corporation
grape.root: C:\Users\username_redacted\AppData\Roaming\FileBot\grape
useExtendedFileAttributes: true
jna.library.path: C:\Program Files\WindowsApps\PointPlanck.FileBot_4.8.5.0_x64__49ex9gnthnt12\lib
user.variant:
user.timezone:
os.name: Windows 10
java.vm.specification.version: 11
sun.net.client.defaultReadTimeout: 60000
jna.boot.library.path: C:\Program Files\WindowsApps\PointPlanck.FileBot_4.8.5.0_x64__49ex9gnthnt12\lib
sun.java.launcher: SUN_STANDARD
user.country: GB
sun.cpu.endian: little
user.home: C:\Users\username_redacted
user.language: en
java.util.prefs.PreferencesFactory: net.filebot.util.prefs.FilePreferencesFactory
unixfs: false
useCreationDate: false
prism.order: sw
java.awt.graphicsenv: sun.awt.Win32GraphicsEnvironment
http.agent: FileBot/4.8.5
sun.java2d.d3d: false
path.separator: ;
os.version: 10.0
jna.nosys: true
java.runtime.name: OpenJDK Runtime Environment
java.vm.name: OpenJDK 64-Bit Server VM
java.vendor.url.bug: http://bugreport.java.com/bugreport/
user.dir: Z:\Movies & TV\_Newly DL'd
os.arch: amd64
net.filebot.util.prefs.file: C:\Users\username_redacted\AppData\Roaming\FileBot\settings.properties
java.vm.info: mixed mode
java.vm.version: 11.0.2+9
org.apache.commons.logging.Log: org.apache.commons.logging.impl.NoOpLog
java.class.version: 55.0


# Arguments #
args[0] = -script
args[1] = fn:sysenv


Done ?(?????)?
{       def space = call{' '}   def ChannelString = any{(0.0+audio.'ChannelPositionsString2'*.replaceAll(/Object\sBased\s\/|0.(?=\d.\d)/, '')*.split(' / ')*.collect{ it.split('/')*.toBigDecimal().sum() }*.max().max()).toString()}{channels};        def codecSubVersion = any{audio.any{ a -> call{a.FormatProfile} =~ 'HRA' } ? '.HRA' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'X / MA / Core' } ? '-X' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'MA / Core' } ? '.MA' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'ES Matrix / Core' } ? '-ES' : null}{null};       def codecVersion = any{audio.Codec.join().match(/DTS-HD/)+codecSubVersion+'.'+audio.Codec.join().match(/TrueHD/)}{audio.Codec.join().match(/DTS-HD/) && codecSubVersion == '-X' ? 'DTS-X' : null}{audio.Codec.join().match(/DTS-HD/)+codecSubVersion}{audio.Codec.join().match(/TrueHD/)}{audio.Codec.join().match(/DTS/)+codecSubVersion.replaceAll(/null/)}{ac};      def dir_root = call{'Z:/Movies & TV/'};         call{hd.matches(/(?i)SD/) ? '480p-720p/' : ''}+         call{hd.matches(/(?i)HD/) ? '720p-1080p/' : ''}+        call{hd.matches(/(?i)UHD/) ? '4k/' : ''};       def main_title =        call{n.replace(':','-').replaceAll(/[\/:*?"<>|]/,' - ')}+       space + '(' + call{y} + ')'+    space + call{fn.matches(/(?i).+\b25th.+?anniv.+/) ? '(25th Anniv. Edition)' : ''}+      space + call{fn.matches(/(?i).+\b\(limited\b.*?\).+/) ? '(Limited Edition)' : ''}+     space + call{fn.matches(/(?i).+\b\(uncut\b.*?\).+/) ? '(Uncut)' : ''}+   space + call{fn.matches(/(?i).+\bcollector.+?s.+?edition\b.+/) ? '(Collector\'s Edition)' : ''}+        space + call{fn.matches(/(?i).+\bdirect.+?cut\b.+/) ? '(Director\'s Cut)' : ''}+        space + call{fn.matches(/(?i).+\bextended.+?\b.+/) ? '(Extended)' : ''}+        space + call{fn.matches(/(?i).+\bextended.+?edit\b.+/) ? '(Extended Edition)' : ''}+    space + call{fn.matches(/(?i).+\bimax\b.+/) ? '(IMAX Edition)' : ''}+   space + call{fn.matches(/(?i).+\blimited\b.+/) ? '(Limited)' : ''}+     space + call{fn.matches(/(?i).+\bremastered\b.+/) ? '(Remastered)' : ''}+       space + call{fn.matches(/(?i).+\bsuper.+duper.+cut\b.+/) ? '(Super Duper Cut)' : ''}+   space + call{fn.matches(/(?i).+\btheatrical\b.+/) ? '(Theatrical)' : ''}+       space + call{fn.matches(/(?i).+\bunrated\b.+/) ? '(Unrated)' : ''}+     space + call{any{fn.match(/\([^\()+?[^\d]+?\)\s*/)} {''}{''}}+
space + call{self.vf ? self.vf : self.hpi}+     space + call{hd}+       space + call{source.matches(/(?i)blu.*ray/) ? 'Blu-ray' : {source} ?: 'WEB-DL'}+        space + call{fn.matches(/(?i).+\bremux\b.+/) ? 'REMUX' : ''}+   space + call{self.hdr ? self.hdr + bitdepth + 'bit' : 'non-HDR'}+       space + call{vc}+       space + call(allOf{codecVersion.replaceAll(/null/)}{ChannelString + 'ch'}{aco.match(/Atmos/)}).join(' ')+       '_'+    call{any{"$group"}{fn.match(/(?<=[_-])[^\s_-]+?$/)}{'NA'}.replaceAll(/[-_\[\]]\s*|\.\w{3}$/, '')};      def lang = call{any{'.'+lang}{lang}}+{fn.matches(/(?i).+sdh.+/) ? '_SDH' : ''}{any{fn.match(/(?i)\(foreignpartsonly\)/)}{''}};  def ext = call{'.'+ext};        (main_title + "/" + main_title + lang).replaceAll(/null/).toString() }
Illegal Argument: java.nio.file.NoSuchFileException: Z:\Movies & TV\_Newly DL'd\TheMovieDB (TheMovieDB)
Argument[1]: Path must be a directory: TheMovieDB
[TEST] from [Z:\Movies & TV\_Newly DL'd\_To Process\1408 (2007) (Director's Cut) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_SiNNERS\1408 (2007) (Director's Cut) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_SiNNERS.nfo] to [Z:\Movies & TV\_Newly DL'd\_To Process\1408 (2007) (Director's Cut) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_SiNNERS\--db.nfo]
[TEST] from [Z:\Movies & TV\_Newly DL'd\_To Process\1408 (2007) (Director's Cut) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_SiNNERS\1408 (2007) (Director's Cut) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_SiNNERS.mkv] to [Z:\Movies & TV\_Newly DL'd\_To Process\1408 (2007) (Director's Cut) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_SiNNERS\--db.mkv]
Skipped [Z:\Movies & TV\_Newly DL'd\_To Process\1408 (2007) (Director's Cut) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_SiNNERS\--db.url] because [Z:\Movies & TV\_Newly DL'd\_To Process\1408 (2007) (Director's Cut) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_SiNNERS\--db.url] already exists
Skipped [Z:\Movies & TV\_Newly DL'd\_To Process\1408 (2007) (Director's Cut) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_SiNNERS\tmdb.url] because [Z:\Movies & TV\_Newly DL'd\_To Process\1408 (2007) (Director's Cut) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_SiNNERS\--db.url] already exists
Skipped [Z:\Movies & TV\_Newly DL'd\_To Process\300 (2007) 720p HD BRRip non-HDR x265 DTS 5.1ch_ESiR\--db.nfo] because [Z:\Movies & TV\_Newly DL'd\_To Process\300 (2007) 720p HD BRRip non-HDR x265 DTS 5.1ch_ESiR\--db.nfo] already exists
Skipped [Z:\Movies & TV\_Newly DL'd\_To Process\300 (2007) 720p HD BRRip non-HDR x265 DTS 5.1ch_ESiR\--db.mkv] because [Z:\Movies & TV\_Newly DL'd\_To Process\300 (2007) 720p HD BRRip non-HDR x265 DTS 5.1ch_ESiR\--db.mkv] already exists
Skipped [Z:\Movies & TV\_Newly DL'd\_To Process\300 (2007) 720p HD BRRip non-HDR x265 DTS 5.1ch_ESiR\--db.srt] because [Z:\Movies & TV\_Newly DL'd\_To Process\300 (2007) 720p HD BRRip non-HDR x265 DTS 5.1ch_ESiR\--db.srt] already exists
Skipped [Z:\Movies & TV\_Newly DL'd\_To Process\300 (2007) 720p HD BRRip non-HDR x265 DTS 5.1ch_ESiR\--db.url] because [Z:\Movies & TV\_Newly DL'd\_To Process\300 (2007) 720p HD BRRip non-HDR x265 DTS 5.1ch_ESiR\--db.url] already exists
Skipped [Z:\Movies & TV\_Newly DL'd\_To Process\300 (2007) 720p HD BRRip non-HDR x265 DTS 5.1ch_ESiR\tmdb.url] because [Z:\Movies & TV\_Newly DL'd\_To Process\300 (2007) 720p HD BRRip non-HDR x265 DTS 5.1ch_ESiR\--db.url] already exists
CmdlineException: Failed to identify or process any files
TheMovieDB
java.nio.file.NoSuchFileException: TheMovieDB
        at net.filebot.cli.ScriptShellMethods.getMediaFolders(ScriptShellMethods.java:205)
        at net.filebot.cli.ScriptShellMethods.eachMediaFolder(ScriptShellMethods.java:229)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at Script1.run(Script1.groovy:14)
        at net.filebot.cli.ScriptShell.evaluate(ScriptShell.java:64)
        at net.filebot.cli.ScriptShell.runScript(ScriptShell.java:74)
        at net.filebot.cli.ArgumentProcessor.runScript(ArgumentProcessor.java:163)
        at net.filebot.cli.ArgumentProcessor.run(ArgumentProcessor.java:37)
        at net.filebot.Main.main(Main.java:132)

Illegal Argument: java.nio.file.NoSuchFileException: Z:\Movies & TV\_Newly DL'd\TheMovieDB (TheMovieDB)
Argument[1]: Path must be a directory: TheMovieDB
[TEST] from [Z:\Movies & TV\_Newly DL'd\_To Process\1408 (2007) (Director's Cut) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_SiNNERS] to [Z:\Movies & TV\_Newly DL'd\_To Process\--db]
[TEST] from [Z:\Movies & TV\_Newly DL'd\_To Process\300 (2007) 720p HD BRRip non-HDR x265 DTS 5.1ch_ESiR] to [Z:\Movies & TV\_Newly DL'd\_To Process\--db]
TheMovieDB
java.nio.file.NoSuchFileException: TheMovieDB
        at net.filebot.cli.ScriptShellMethods.getMediaFolders(ScriptShellMethods.java:205)
        at net.filebot.cli.ScriptShellMethods.eachMediaFolder(ScriptShellMethods.java:229)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at Script1.run(Script1.groovy:14)
        at net.filebot.cli.ScriptShell.evaluate(ScriptShell.java:64)
        at net.filebot.cli.ScriptShell.runScript(ScriptShell.java:74)
        at net.filebot.cli.ArgumentProcessor.runScript(ArgumentProcessor.java:163)
        at net.filebot.cli.ArgumentProcessor.run(ArgumentProcessor.java:37)
        at net.filebot.Main.main(Main.java:132)

PS Z:\Movies & TV\_Newly DL'd>  filebot -script fn:sysenv
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Can we use external file for fn:renall script

Post by rednoah »

1.
I mean this:

Code: Select all

$FORMAT=(Write-Host (Get-Content $FOLDER_ROOT"/"$GROOVY_MOVIE))
filebot -script fn:sysenv --format "$FORMAT"
:arrow: Now we can check if args[3] is exactly your format or not.


2.
I suspect that the main reason why everything is broken, is because arguments are quoted completely wrong.

BAD:

Code: Select all

$FOLDER_ROOT"/"$FOLDER_PROCESS
GOOD:

Code: Select all

"$FOLDER_ROOT/$FOLDER_PROCESS"
Compare BAD:

Code: Select all

filebot -script fn:sysenv $FOLDER_ROOT"/"$FOLDER_PROCESS -non-strict --format "$FORMAT" --db TheMovieDB --action test --log info
Compare GOOD:

Code: Select all

filebot -script fn:sysenv "$FOLDER_ROOT/$FOLDER_PROCESS" -non-strict --format "$FORMAT" --db TheMovieDB --action test --log info
:idea: Please read the FAQ and How to Request Help.
stephen147
Donor
Posts: 131
Joined: 01 Sep 2015, 22:40

Re: Can we use external file for fn:renall script

Post by stephen147 »

This works:

Code: Select all

$FOLDER_ROOT="Z:/Movies & TV/_Newly DL'd"
$GROOVY_MOVIE="Movie Format.groovy"
$FORMAT=Get-Content $FOLDER_ROOT"/"$GROOVY_MOVIE
filebot -script fn:sysenv --format "$FORMAT"
Returns:

Code: Select all

# Arguments #
args[0] = -script
args[1] = fn:sysenv
args[2] = --format
args[3] = {     def space = call{' '};  call(space) + call{n} }
That is with this simple test external file:

Code: Select all

{
	def space = call{' '};
	call(space) + call{n}
}
But this format posting.php?mode=reply&f=4&t=10753#pr43758 doesn't work which my original code.

It throws an error:

Code: Select all

Option "--format" takes an operand
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Can we use external file for fn:renall script

Post by rednoah »

1.
Well, we confirm that we're passing the wrong value:

Code: Select all

args[3] = {     def space = call{' '};  call(space) + call{n} }
Presumably, this is wrong, but I'm no PowerShell expert:

Code: Select all

$FORMAT=Get-Content $FOLDER_ROOT"/"$GROOVY_MOVIE

2.
Here's how it works with bash:

Code: Select all

$ cat 1234.txt
1
2
3
4
$ FORMAT="$(cat 1234.txt)"
$ filebot -script fn:sysenv "$FORMAT"
...
# Arguments #
args[0] = -script
args[1] = fn:sysenv
args[2] = 1
2
3
4

EDIT:

This works:

Code: Select all

filebot -script fn:sysenv @"
1
2
3
"@
This does not:

Code: Select all

$VALUE=Get-Content 1234.txt
filebot -script fn:sysenv "$VALUE"
Life is too short for CMD or PowerShell. Don't bother. It's easy with bash, python, groovy, etc.
:idea: Please read the FAQ and How to Request Help.
stephen147
Donor
Posts: 131
Joined: 01 Sep 2015, 22:40

Re: Can we use external file for fn:renall script

Post by stephen147 »

That is the correct output from PowerShell.

Code: Select all

# filebot -script fn:sysenv --format "{n}"
Returns:

Code: Select all

# Arguments #
args[0] = -script
args[1] = fn:sysenv
args[2] = --format
args[3] = {n}
RIGHT. :) I've found a section of code where the problem lies.

:!: This works

Code: Select all

{
	def space = call{' '};
	def ChannelString = any{(0.0+audio.'ChannelPositionsString2'*.replaceAll(/Object\sBased\s\/|0.(?=\d.\d)/, '')*.split(' / ')*.collect{ it.split('/')*.toBigDecimal().sum() }*.max().max()).toString()}{channels};
	def codecSubVersion = any{audio.any{ a -> call{a.FormatProfile} =~ 'HRA' } ? '.HRA' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'X / MA / Core' } ? '-X' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'MA / Core' } ? '.MA' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'ES Matrix / Core' } ? '-ES' : null}{null};
	def codecVersion = any{audio.Codec.join().match(/DTS-HD/)+codecSubVersion+'.'+audio.Codec.join().match(/TrueHD/)}{audio.Codec.join().match(/DTS-HD/) && codecSubVersion == '-X' ? 'DTS-X' : null}{audio.Codec.join().match(/DTS-HD/)+codecSubVersion}{audio.Codec.join().match(/TrueHD/)}{audio.Codec.join().match(/DTS/)+codecSubVersion.replaceAll(/null/)}{ac};
	def dir_root = call{'Z:/Movies & TV/'};
	call{hd.matches(/(?i)SD/) ? '480p-720p/' : ''}+
	call{hd.matches(/(?i)HD/) ? '720p-1080p/' : ''}+
	call{hd.matches(/(?i)UHD/) ? '4k/' : ''};
	def main_title =
	space + '(' + call{y} + ')'+
	space + call{fn.matches(/(?i).+\b25th.+?anniv.+/) ? '(25th Anniv. Edition)' : ''}+
	space + call{fn.matches(/(?i).+\b\(limited\b.*?\).+/) ? '(Limited Edition)' : ''}+
	space + call{fn.matches(/(?i).+\b\(uncut\b.*?\).+/) ? '(Uncut)' : ''}+
	space + call{fn.matches(/(?i).+\bcollector.+?s.+?edition\b.+/) ? '(Collector\'s Edition)' : ''}+
	space + call{fn.matches(/(?i).+\bdirect.+?cut\b.+/) ? '(Director\'s Cut)' : ''}+
	space + call{fn.matches(/(?i).+\bextended.+?\b.+/) ? '(Extended)' : ''}+
	space + call{fn.matches(/(?i).+\bextended.+?edit\b.+/) ? '(Extended Edition)' : ''}+
	space + call{fn.matches(/(?i).+\bimax\b.+/) ? '(IMAX Edition)' : ''}+
	space + call{fn.matches(/(?i).+\blimited\b.+/) ? '(Limited)' : ''}+
	space + call{fn.matches(/(?i).+\bremastered\b.+/) ? '(Remastered)' : ''}+
	space + call{fn.matches(/(?i).+\bsuper.+duper.+cut\b.+/) ? '(Super Duper Cut)' : ''}+
	space + call{fn.matches(/(?i).+\btheatrical\b.+/) ? '(Theatrical)' : ''}+
	space + call{fn.matches(/(?i).+\bunrated\b.+/) ? '(Unrated)' : ''}+
	space + call{any{fn.match(/\([^\()+?[^\d]+?\)\s*/)} {''}{''}}+
	space + call{self.vf ? self.vf : self.hpi}+
	space + call{hd}+
	space + call{source.matches(/(?i)blu.*ray/) ? 'Blu-ray' : {source} ?: 'WEB-DL'}+
	space + call{fn.matches(/(?i).+\bremux\b.+/) ? 'REMUX' : ''}+
	space + call{self.hdr ? self.hdr + bitdepth + 'bit' : 'non-HDR'}+
	space + call{vc}+
	space + call(allOf{codecVersion.replaceAll(/null/)}{ChannelString + 'ch'}{aco.match(/Atmos/)}).join(' ')+
	'_'+
	call{any{"$group"}{fn.match(/(?<=[_-])[^\s_-]+?$/)}{'NA'}.replaceAll(/[-_\[\]]\s*|\.\w{3}$/, '')};
	def lang = call{any{'.'+lang}{lang}}+{fn.matches(/(?i).+sdh.+/) ? '_SDH' : ''}{any{fn.match(/(?i)\(foreignpartsonly\)/)}{''}};
	def ext = call{'.'+ext};
	(call(main_title) + call(lang)).replaceAll(/null/)
}
:!: This does nawt:

Code: Select all

{
	def space = call{' '};
	def ChannelString = any{(0.0+audio.'ChannelPositionsString2'*.replaceAll(/Object\sBased\s\/|0.(?=\d.\d)/, '')*.split(' / ')*.collect{ it.split('/')*.toBigDecimal().sum() }*.max().max()).toString()}{channels};
	def codecSubVersion = any{audio.any{ a -> call{a.FormatProfile} =~ 'HRA' } ? '.HRA' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'X / MA / Core' } ? '-X' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'MA / Core' } ? '.MA' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'ES Matrix / Core' } ? '-ES' : null}{null};
	def codecVersion = any{audio.Codec.join().match(/DTS-HD/)+codecSubVersion+'.'+audio.Codec.join().match(/TrueHD/)}{audio.Codec.join().match(/DTS-HD/) && codecSubVersion == '-X' ? 'DTS-X' : null}{audio.Codec.join().match(/DTS-HD/)+codecSubVersion}{audio.Codec.join().match(/TrueHD/)}{audio.Codec.join().match(/DTS/)+codecSubVersion.replaceAll(/null/)}{ac};
	def dir_root = call{'Z:/Movies & TV/'};
	call{hd.matches(/(?i)SD/) ? '480p-720p/' : ''}+
	call{hd.matches(/(?i)HD/) ? '720p-1080p/' : ''}+
	call{hd.matches(/(?i)UHD/) ? '4k/' : ''};
	def main_title = call{n.replace(':','-').replaceAll(/[\/:*?"<>|]/,' - ')}+
	space + '(' + call{y} + ')'+
	space + call{fn.matches(/(?i).+\b25th.+?anniv.+/) ? '(25th Anniv. Edition)' : ''}+
	space + call{fn.matches(/(?i).+\b\(limited\b.*?\).+/) ? '(Limited Edition)' : ''}+
	space + call{fn.matches(/(?i).+\b\(uncut\b.*?\).+/) ? '(Uncut)' : ''}+
	space + call{fn.matches(/(?i).+\bcollector.+?s.+?edition\b.+/) ? '(Collector\'s Edition)' : ''}+
	space + call{fn.matches(/(?i).+\bdirect.+?cut\b.+/) ? '(Director\'s Cut)' : ''}+
	space + call{fn.matches(/(?i).+\bextended.+?\b.+/) ? '(Extended)' : ''}+
	space + call{fn.matches(/(?i).+\bextended.+?edit\b.+/) ? '(Extended Edition)' : ''}+
	space + call{fn.matches(/(?i).+\bimax\b.+/) ? '(IMAX Edition)' : ''}+
	space + call{fn.matches(/(?i).+\blimited\b.+/) ? '(Limited)' : ''}+
	space + call{fn.matches(/(?i).+\bremastered\b.+/) ? '(Remastered)' : ''}+
	space + call{fn.matches(/(?i).+\bsuper.+duper.+cut\b.+/) ? '(Super Duper Cut)' : ''}+
	space + call{fn.matches(/(?i).+\btheatrical\b.+/) ? '(Theatrical)' : ''}+
	space + call{fn.matches(/(?i).+\bunrated\b.+/) ? '(Unrated)' : ''}+
	space + call{any{fn.match(/\([^\()+?[^\d]+?\)\s*/)} {''}{''}}+
	space + call{self.vf ? self.vf : self.hpi}+
	space + call{hd}+
	space + call{source.matches(/(?i)blu.*ray/) ? 'Blu-ray' : {source} ?: 'WEB-DL'}+
	space + call{fn.matches(/(?i).+\bremux\b.+/) ? 'REMUX' : ''}+
	space + call{self.hdr ? self.hdr + bitdepth + 'bit' : 'non-HDR'}+
	space + call{vc}+
	space + call(allOf{codecVersion.replaceAll(/null/)}{ChannelString + 'ch'}{aco.match(/Atmos/)}).join(' ')+
	'_'+
	call{any{"$group"}{fn.match(/(?<=[_-])[^\s_-]+?$/)}{'NA'}.replaceAll(/[-_\[\]]\s*|\.\w{3}$/, '')};
	def lang = call{any{'.'+lang}{lang}}+{fn.matches(/(?i).+sdh.+/) ? '_SDH' : ''}{any{fn.match(/(?i)\(foreignpartsonly\)/)}{''}};
	def ext = call{'.'+ext};
	(call(main_title) + call(lang)).replaceAll(/null/)
}
:!: The only line difference is the added line:

Code: Select all

call{n.replace(':','-').replaceAll(/[\/:*?"<>|]/,' - ')}+
I get this error with it added:

Code: Select all

"-" is not a valid option
Although the working code is not perfect, it now shows a WARNING message (but still works):

Code: Select all

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedConstructor$1 (file:/C:/Program%20Files/WindowsApps/PointPlanck.FileBot_4.8.5.0_x64__49ex9gnthnt12/jar/groovy.jar) to constructor java.math.BigDecimal(java.math.BigInteger,long,int,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedConstructor$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[TEST] from [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 1\Movie 1.nfo] to [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 1\(2007) (Director's Cut) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_SiNNERS.nfo]
[TEST] from [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 1\Movie 1.mkv] to [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 1\(2007) (Director's Cut) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_SiNNERS.mkv]
[TEST] from [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 1\--db.url] to [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 1\(2007) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_db.url]
[TEST] from [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 1\tmdb.url] to [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 1\(2007) 1080p HD Blu-ray non-HDR x264 DTS 5.1ch_NA.url]
[TEST] from [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 2\Movie 2.nfo] to [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 2\(2007) 720p HD BRRip non-HDR x265 DTS 5.1ch_ESiR.nfo]
[TEST] from [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 2\Movie 2.mkv] to [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 2\(2007) 720p HD BRRip non-HDR x265 DTS 5.1ch_ESiR.mkv]
[TEST] from [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 2\Movie 2.en.srt] to [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 2\(2007) 720p HD BRRip non-HDR x265 DTS 5.1ch_ESiR.en.eng.srt]
[TEST] from [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 2\--db.url] to [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 2\(2007) 720p HD BRRip non-HDR x265 DTS 5.1ch_db.url]
[TEST] from [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 2\tmdb.url] to [Z:\Movies & TV\_Newly DL'd\_To Process\Movie 2\(2007) 720p HD BRRip non-HDR x265 DTS 5.1ch_NA.url]
stephen147
Donor
Posts: 131
Joined: 01 Sep 2015, 22:40

Re: Can we use external file for fn:renall script

Post by stephen147 »

Got it to work just before I pulled my hair out!! T'was a problem with the format code:

Code: Select all

.replace(':','-').replaceAll(/[\/:\"\*?<>|]/,' - ')
Was moved down to the end and just just used:

Code: Select all

call{n}+
as opposed to having the replace there. Makes total sense really. :oops:

New working code:

Code: Select all

{
	def space = call{' '};
	def ChannelString = any{(0.0+audio.'ChannelPositionsString2'*.replaceAll(/Object\sBased\s\/|0.(?=\d.\d)/, '')*.split(' / ')*.collect{ it.split('/')*.toBigDecimal().sum() }*.max().max()).toString()}{channels};
	def codecSubVersion = any{audio.any{ a -> call{a.FormatProfile} =~ 'HRA' } ? '.HRA' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'X / MA / Core' } ? '-X' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'MA / Core' } ? '.MA' : null}{audio.any{ a -> call{a.FormatProfile} =~ 'ES Matrix / Core' } ? '-ES' : null}{null};
	def codecVersion = any{audio.Codec.join().match(/DTS-HD/)+codecSubVersion+'.'+audio.Codec.join().match(/TrueHD/)}{audio.Codec.join().match(/DTS-HD/) && codecSubVersion == '-X' ? 'DTS-X' : null}{audio.Codec.join().match(/DTS-HD/)+codecSubVersion}{audio.Codec.join().match(/TrueHD/)}{audio.Codec.join().match(/DTS/)+codecSubVersion.replaceAll(/null/)}{ac};
	def dir_root = 'Z:/Movies & TV/'+
	call{hd.matches(/(?i)SD/) ? '480p-720p/' : ' '}+
	call{hd.matches(/(?i)HD/) ? '720p-1080p/' : ' '}+
	call{hd.matches(/(?i)UHD/) ? '4k/' : ' '};
	def main_title = call{n}+
	space + '(' + call{y} + ')'+
	space + call{fn.matches(/(?i).+\b25th.+?anniv.+/) ? '(25th Anniv. Edition)' : ' '}+
	space + call{fn.matches(/(?i).+\b\(limited\b.*?\).+/) ? '(Limited Edition)' : ' '}+
	space + call{fn.matches(/(?i).+\b\(uncut\b.*?\).+/) ? '(Uncut)' : ' '}+
	space + call{fn.matches(/(?i).+\bcollector.+?s.+?edition\b.+/) ? '(Collector\'s Edition)' : ' '}+
	space + call{fn.matches(/(?i).+\bdirect.+?cut\b.+/) ? '(Director\'s Cut)' : ' '}+
	space + call{fn.matches(/(?i).+\bextended.+?\b.+/) ? '(Extended)' : ' '}+
	space + call{fn.matches(/(?i).+\bextended.+?edit\b.+/) ? '(Extended Edition)' : ' '}+
	space + call{fn.matches(/(?i).+\bimax\b.+/) ? '(IMAX Edition)' : ' '}+
	space + call{fn.matches(/(?i).+\blimited\b.+/) ? '(Limited)' : ' '}+
	space + call{fn.matches(/(?i).+\bremastered\b.+/) ? '(Remastered)' : ' '}+
	space + call{fn.matches(/(?i).+\bsuper.+duper.+cut\b.+/) ? '(Super Duper Cut)' : ' '}+
	space + call{fn.matches(/(?i).+\btheatrical\b.+/) ? '(Theatrical)' : ' '}+
	space + call{fn.matches(/(?i).+\bunrated\b.+/) ? '(Unrated)' : ' '}+
	space + call{any{fn.match(/\([^\()+?[^\d]+?\)\s*/)} {' '}{' '}}+
	space + call{self.vf ? self.vf : self.hpi}+
	space + call{hd}+
	space + call{source.matches(/(?i)blu.*ray/) ? 'Blu-ray' : {source} ?: 'WEB-DL'}+
	space + call{fn.matches(/(?i).+\bremux\b.+/) ? 'REMUX' : ' '}+
	space + call{self.hdr ? self.hdr + bitdepth + 'bit' : 'non-HDR'}+
	space + call{vc}+
	space + call(allOf{codecVersion.replaceAll(/null/)}{ChannelString + 'ch'}{aco.match(/Atmos/)}).join(' ')+
	'_'+
	call{any{"$group"}{fn.match(/(?<=[_-])[^\s_-]+?$/)}{'NA'}.replaceAll(/[-_\[\]]\s*|\.\w{3}$/, '')};
	def lang = call{any{'.'+lang}{lang}}+{fn.matches(/(?i).+sdh.+/) ? '_SDH' : ''}{any{fn.match(/(?i)\(foreignpartsonly\)/)}{''}};
	def ext = call{'.'+ext};
	(call(main_title) + call(lang)).replaceAll(/null/,'')
}
Post Reply