HDR Snippet with UTorrent

All about user-defined episode / movie / file name format expressions
Post Reply
jrhessey
Posts: 10
Joined: 30 Jun 2021, 14:16

HDR Snippet with UTorrent

Post by jrhessey »

I'm trying to use the HDR/Dobly Vision detection snippet that devster wrote in the run program of uTorrent. It's bombing out on all the double quotes.

Here is the code being executed

Code: Select all

"C:\Program Files\FileBot\filebot.launcher.exe" -script fn:amc --output "P:" --action move --conflict auto -non-strict --log-file "p:\amc6.log" --def clean=y deleteafterextract=y emby=embyserver:05ef5cd09bf54b2ea00e8756be8389a2 movieFormat="p:\movies\{n.sortName('$2, $1')} ({y} {certification})\{n}.{vf}.{audio[0].Channels}ch.{vc}.{ac}.{{def _HDRMap = ["HDR10": "HDR10","SMPTE ST 2086": "HDR10","SMPTE ST 2094 App 3": "Advanced HDR","SMPTE ST 2094 App 4": "HDR10+","Dolby Vision / SMPTE ST 2086": "Dolby Vision","Dolby Vision / HDR10": "Dolby Vision","ETSI TS 103 433": "SL-HDR1","SL-HDR1": "SL-HDR1","SL-HDR2": "SL-HDR2","SL-HDR3": "SL-HDR3","Technicolor Advanced HDR": "Technicolor Advanced HDR",]def vid = video.first()if (bitdepth > 8) {switch (vid) {case { vid =~ /\bHDR_Format_Commercial/ }:vid["HDR_Format_Commercial"]breakcase { vid =~ /\bHDR_/ }:_HDR = any{ vid["HDR_Format"] }{ vid["HDR_Format/String"] }hdr_out = _HDRMap.get(_HDR, _HDR)if ( hdr_out.findMatch(/vision/) ) {dv_info = allOf{ "P" }{ vid["HDR_Format_Profile"].match(/[dh][ve][hvca][e13v]\.\d(\d)/) }{ "." + vid["HDR_Format_Compatibility"].match(/HDR10|SDR/).replace("HDR10", "1").replace("SDR", "2") }.join()hdr_out = "$hdr_out $dv_info"}hdr_outbreakcase { it["transfer_characteristics"].findMatch(/HLG/) && it["colour_primaries"] == "BT.2020" }:"HLG10"breakcase { it["transfer_characteristics"] == "PQ" && it["colour_primaries"] == "BT.2020" }:"HDR10"breakdefault:"$bitdepth-bit"break}}}" seriesFormat="P:\TV Shows\{n}\{'Season '+s}\{n} - {s00e00} - {t}.{vf}.{af}.{vc}.{ac}.{def _HDRMap = ["HDR10": "HDR10","SMPTE ST 2086": "HDR10","SMPTE ST 2094 App 3": "Advanced HDR","SMPTE ST 2094 App 4": "HDR10+","Dolby Vision / SMPTE ST 2086": "Dolby Vision","Dolby Vision / HDR10": "Dolby Vision","ETSI TS 103 433": "SL-HDR1","SL-HDR1": "SL-HDR1","SL-HDR2": "SL-HDR2","SL-HDR3": "SL-HDR3","Technicolor Advanced HDR": "Technicolor Advanced HDR",]def vid = video.first()if (bitdepth > 8) {switch (vid) {case { vid =~ /\bHDR_Format_Commercial/ }:vid["HDR_Format_Commercial"]breakcase { vid =~ /\bHDR_/ }:_HDR = any{ vid["HDR_Format"] }{ vid["HDR_Format/String"] }hdr_out = _HDRMap.get(_HDR, _HDR)if ( hdr_out.findMatch(/vision/) ) {dv_info = allOf{ "P" }{ vid["HDR_Format_Profile"].match(/[dh][ve][hvca][e13v]\.\d(\d)/) }{ "." + vid["HDR_Format_Compatibility"].match(/HDR10|SDR/).replace("HDR10", "1").replace("SDR", "2") }.join()hdr_out = "$hdr_out $dv_info"}hdr_outbreakcase { it["transfer_characteristics"].findMatch(/HLG/) && it["colour_primaries"] == "BT.2020" }:"HLG10"breakcase { it["transfer_characteristics"] == "PQ" && it["colour_primaries"] == "BT.2020" }:"HDR10"breakdefault:"$bitdepth-bit"break}}}" "ut_label=Movies-R" "ut_state=5" "ut_title=Mortal.Kombat.2021.WEB-DL.2160p.Dolby_Vision.P5.by.DVT.mp4" "ut_kind=single" "ut_file=Mortal.Kombat.2021.WEB-DL.2160p.Dolby_Vision.P5.by.DVT.mp4" "ut_dir=P:\TBOT"

Here is the error in the log file
Parameter: movieFormat = p:\movies\{n.sortName('$2, $1')} ({y} {certification})\{n}.{vf}.{audio[0].Channels}ch.{vc}.{ac}.{{def _HDRMap = [HDR10: HDR10,SMPTE
Argument[0]: C:\
Argument[1]: C:\
Argument[2]: C:\
Argument[3]: C:\
Invalid usage: input [C:\, C:\, C:\, C:\] must not include a filesystem root
Abort (×_×)
File does not exist: ST
File does not exist: 2086: HDR10,SMPTE
File does not exist: ST
File does not exist: 2094
File does not exist: App
File does not exist: 3: Advanced
File does not exist: HDR,SMPTE
File does not exist: ST
File does not exist: 2094
File does not exist: App
File does not exist: 4: HDR10+,Dolby
File does not exist: Vision
File does not exist: SMPTE
File does not exist: ST
File does not exist: 2086: Dolby
File does not exist: Vision,Dolby
File does not exist: Vision
File does not exist: HDR10: Dolby
File does not exist: Vision,ETSI
File does not exist: TS
File does not exist: 103
File does not exist: 433: SL-HDR1,SL-HDR1: SL-HDR1,SL-HDR2: SL-HDR2,SL-HDR3: SL-HDR3,Technicolor
File does not exist: Advanced
File does not exist: HDR: Technicolor
File does not exist: Advanced
File does not exist: HDR,]def vid = video.first()if (bitdepth > 8) {switch (vid) {case { vid =~ /\bHDR_Format_Commercial/ }:vid[HDR_Format_Commercial]breakcase { vid =~ /\bHDR_/ }:_HDR = any{ vid[HDR_Format] }{ vid[HDR_Format/String] }hdr_out = _HDRMap.get(_HDR, _HDR)if ( hdr_out.findMatch(/vision/) ) {dv_info = allOf{ P }{ vid[HDR_Format_Profile].match(/[dh][ve][hvca][e13v]\.\d(\d)/) }{ . + vid[HDR_Format_Compatibility].match(/HDR10|SDR/).replace(HDR10, 1).replace(SDR, 2) }.join()hdr_out = $hdr_out
File does not exist: $dv_info}hdr_outbreakcase { it[transfer_characteristics].findMatch(/HLG/) && it[colour_primaries] == BT.2020 }:HLG10breakcase { it[transfer_characteristics] == PQ && it[colour_primaries] == BT.2020 }:HDR10breakdefault:$bitdepth-bitbreak}}}
File does not exist: seriesFormat=P:\TV Shows\{n}\{'Season '+s}\{n} - {s00e00} - {t}.{vf}.{af}.{vc}.{ac}.{def _HDRMap = [HDR10: HDR10,SMPTE
File does not exist: ST
File does not exist: 2086: HDR10,SMPTE
File does not exist: ST
File does not exist: 2094
File does not exist: App
File does not exist: 3: Advanced
File does not exist: HDR,SMPTE
File does not exist: ST
File does not exist: 2094
File does not exist: App
File does not exist: 4: HDR10+,Dolby
File does not exist: Vision
File does not exist: SMPTE
File does not exist: ST
File does not exist: 2086: Dolby
File does not exist: Vision,Dolby
File does not exist: Vision
File does not exist: HDR10: Dolby
File does not exist: Vision,ETSI
File does not exist: TS
File does not exist: 103
File does not exist: 433: SL-HDR1,SL-HDR1: SL-HDR1,SL-HDR2: SL-HDR2,SL-HDR3: SL-HDR3,Technicolor
File does not exist: Advanced
File does not exist: HDR: Technicolor
File does not exist: Advanced
File does not exist: HDR,]def vid = video.first()if (bitdepth > 8) {switch (vid) {case { vid =~ /\bHDR_Format_Commercial/ }:vid[HDR_Format_Commercial]breakcase { vid =~ /\bHDR_/ }:_HDR = any{ vid[HDR_Format] }{ vid[HDR_Format/String] }hdr_out = _HDRMap.get(_HDR, _HDR)if ( hdr_out.findMatch(/vision/) ) {dv_info = allOf{ P }{ vid[HDR_Format_Profile].match(/[dh][ve][hvca][e13v]\.\d(\d)/) }{ . + vid[HDR_Format_Compatibility].match(/HDR10|SDR/).replace(HDR10, 1).replace(SDR, 2) }.join()hdr_out = $hdr_out
File does not exist: $dv_info}hdr_outbreakcase { it[transfer_characteristics].findMatch(/HLG/) && it[colour_primaries] == BT.2020 }:HLG10breakcase { it[transfer_characteristics] == PQ && it[colour_primaries] == BT.2020 }:HDR10breakdefault:$bitdepth-bitbreak}}}
Do I need to wrap the double quotes in double quotes like

Code: Select all

"""HDR10""""
or convert them to single quotes

Code: Select all

'HDR10'
Thanks!!
Any help is greatly appreciated!!
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: HDR Snippet with UTorrent

Post by rednoah »

:arrow: Use the @file syntax for reading command-line arguments from external text files.
:idea: Please read the FAQ and How to Request Help.
jrhessey
Posts: 10
Joined: 30 Jun 2021, 14:16

Re: HDR Snippet with UTorrent

Post by jrhessey »

I've got it figured out for the most part now. I've got a small problem though when running from utorrent, I get a padded season number for the season folder name and I don't want that.

Here is the code from the preferences

Code: Select all

"C:\Program Files\FileBot\filebot.launcher.exe" @P:/filebotArgs.txt "ut_label=%L" "ut_state=%S" "ut_title=%N" "ut_kind=%K" "ut_file=%F" "ut_dir=%D"
Here is the contents from the filebotArgs.txt file

Code: Select all

-script
fn:amc
--output
P:
--action
move
--conflict
auto
-non-strict
--log-file
p:\amc6.log
--def
clean=y
deleteafterextract=y
emby=embyserver:05ef5cd09bf54b2ea00e8756be8389a2
movieFormat=P:\movieFormat.groovy
tvFormat=P:\tvFormat.groovy
here are the 2 formats

Movie

Code: Select all

/movies/{n.sortName('$2, $1')} ({y} {certification})/{n}.{hdr = 'HDR' ? allOf{vf}{af}{vc}{ac}{VIDEO[0].HDR_format_commercial}.join('.') : allOf{vf}{af}{vc}{ac}.join('.')}
TV

Code: Select all

/TV Shows/{n}/{'Season '+s}/{n} - {s00e00} - {t.replaceAll(/[!?:.]+$/).replaceAll(/[`´‘’ʻ]/, "'")}.{hdr = 'HDR' ? allOf{vf}{af}{vc}{ac}{VIDEO[0].HDR_format_commercial}.join('.') : allOf{vf}{af}{vc}{ac}.join('.')}
Below is the log file excerpt

Code: Select all

Run script [fn:amc] at [Tue Jul 06 16:54:02 EDT 2021]
Parameter: clean = y
Parameter: deleteafterextract = y
Parameter: emby = *****
Parameter: movieFormat = P:\movieFormat.groovy
Parameter: tvFormat = P:\tvFormat.groovy
Parameter: ut_label = tv-sonarr
Parameter: ut_state = 5
Parameter: ut_title = Danger.Force.S01E23.Family.Lies.1080p.AMZN.WEBRip.DDP2.0.x264-LAZY[rarbg]
Parameter: ut_kind = multi
Parameter: ut_file = Danger.Force.S01E23.Family.Lies.1080p.AMZN.WEB-DL.DDP2.0.H.264-LAZY.mkv
Parameter: ut_dir = P:\TBOT\Danger.Force.S01E23.Family.Lies.1080p.AMZN.WEBRip.DDP2.0.x264-LAZY[rarbg]
Invalid usage: input folder [P:\TBOT\Danger.Force.S01E23.Family.Lies.1080p.AMZN.WEBRip.DDP2.0.x264-LAZY[rarbg]] must not be inside output folder [P:\] and vice versa
Input: P:\TBOT\Danger.Force.S01E23.Family.Lies.1080p.AMZN.WEBRip.DDP2.0.x264-LAZY[rarbg]\Danger.Force.S01E23.Family.Lies.1080p.AMZN.WEB-DL.DDP2.0.H.264-LAZY.mkv
Process as TV Series [tv-sonarr]
Group: {Series=true} => [Danger.Force.S01E23.Family.Lies.1080p.AMZN.WEB-DL.DDP2.0.H.264-LAZY.mkv]
Rename episodes using [TheTVDB] with [Airdate]
Lookup via [Danger Force]
Fetching episode data for [Danger Force]
[MOVE] from [P:\TBOT\Danger.Force.S01E23.Family.Lies.1080p.AMZN.WEBRip.DDP2.0.x264-LAZY[rarbg]\Danger.Force.S01E23.Family.Lies.1080p.AMZN.WEB-DL.DDP2.0.H.264-LAZY.mkv] to [P:\TV Shows\Danger Force\Season 01\Danger Force - S01E23 - Family Lies.mkv]
Processed 1 file
Notify Emby: [host:embyserver, token:05ef5cd09bf54b2ea00e8756be8389a2]
POST: https://embyserver:8920/Library/Refresh?api_key=05ef5cd09bf54b2ea00e8756be8389a2
Connect timed out
Clean clutter files and empty folders
Delete P:\TBOT\Danger.Force.S01E23.Family.Lies.1080p.AMZN.WEBRip.DDP2.0.x264-LAZY[rarbg]\RARBG_DO_NOT_MIRROR.exe
Delete P:\TBOT\Danger.Force.S01E23.Family.Lies.1080p.AMZN.WEBRip.DDP2.0.x264-LAZY[rarbg]\RARBG.txt
Delete P:\TBOT\Danger.Force.S01E23.Family.Lies.1080p.AMZN.WEBRip.DDP2.0.x264-LAZY[rarbg]
Done ヾ(@⌒ー⌒@)ノ
If I run it from GUI, I get an unpadded season number

From the gui, I have @p:/tvFormat.groovy entered for the format, so I'm calling the same format either way.

Not sure what's going on to give me a padded season number.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: HDR Snippet with UTorrent

Post by kim »

Code: Select all

{s00e00}
= e.g. S01E23 NOT S1E23
Gui or not

try

Code: Select all

{sxe}
wrong

Code: Select all

hdr = 'HDR'
ok

Code: Select all

hdr == 'HDR'
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: HDR Snippet with UTorrent

Post by rednoah »

1.
There is no --def tvFormat option, so your custom series format is never used.

:arrow: Please copy & paste the parameter names from the amc script documentation.



2.
--output folder must be a valid output folder even if your custom formats are absolute:

Code: Select all

Invalid usage: input folder [...] must not be inside output folder [...] and vice versa
:!: The amc script will currently give you a severe warning but future revisions may error out instead and break your automation.
:idea: Please read the FAQ and How to Request Help.
jrhessey
Posts: 10
Joined: 30 Jun 2021, 14:16

Re: HDR Snippet with UTorrent

Post by jrhessey »

I was asking about a padded SEASON folder, not the padded season number in the filename.

In testing older movies without an HDR field even available it said the field was undefined when I used the double equal. It's works as expected on all files with the single =.
jrhessey
Posts: 10
Joined: 30 Jun 2021, 14:16

Re: HDR Snippet with UTorrent

Post by jrhessey »

rednoah wrote: 07 Jul 2021, 05:24 1.
There is no --def tvFormat option, so your custom series format is never used.

:arrow: Please copy & paste the parameter names from the amc script documentation.



2.
--output folder must be a valid output folder even if your custom formats are absolute:

Code: Select all

Invalid usage: input folder [...] must not be inside output folder [...] and vice versa
:!: The amc script will currently give you a severe warning but future revisions may error out instead and break your automation.
Wow, I can't believe I overlooked that... It's working now.

How do I fix #2 though when the output is going to either p:\movies or p:\tv shows based on which type filebot/amc script determines it to be?
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: HDR Snippet with UTorrent

Post by kim »

In testing older movies without an HDR field even available it said the field was undefined when I used the double equal. It's works as expected on all files with the single =.
use this:

Code: Select all

{ any{allOf{vf}{af}{vc}{ac}{VIDEO[0].HDR_format_commercial}.join('.')} {allOf{vf}{af}{vc}{ac}.join('.')} }
FYI:
https://groovy-lang.org/operators.html

hdr = 'HDR'
same as
make hdr always = 'HDR'
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: HDR Snippet with UTorrent

Post by rednoah »

You’ll want to have a dedicated Media folder instead of using the drive root.
:idea: Please read the FAQ and How to Request Help.
jrhessey
Posts: 10
Joined: 30 Jun 2021, 14:16

Re: HDR Snippet with UTorrent

Post by jrhessey »

rednoah wrote: 07 Jul 2021, 16:06 You’ll want to have a dedicated Media folder instead of using the drive root.
Ahh, OK! I'll look at doing that next.

I really appreciate you help rednoah!!
jrhessey
Posts: 10
Joined: 30 Jun 2021, 14:16

Re: HDR Snippet with UTorrent

Post by jrhessey »

kim wrote: 07 Jul 2021, 15:14
In testing older movies without an HDR field even available it said the field was undefined when I used the double equal. It's works as expected on all files with the single =.
use this:

Code: Select all

{ any{allOf{vf}{af}{vc}{ac}{VIDEO[0].HDR_format_commercial}.join('.')} {allOf{vf}{af}{vc}{ac}.join('.')} }
FYI:
https://groovy-lang.org/operators.html

hdr = 'HDR'
same as
make hdr always = 'HDR'
Do I convert the original code

Code: Select all

p:/TV Shows/{n}/{'Season '+s}/{n} - {s00e00} - {t.replaceAll(/[!?:.]+$/).replaceAll(/[`´‘’ʻ]/, "'")}.{hdr = 'HDR' ? allOf{vf}{af}{vc}{ac}{VIDEO[0].HDR_format_commercial}.join('.') : allOf{vf}{af}{vc}{ac}.join('.')}
to this then

Code: Select all

p:/TV Shows/{n}/{'Season '+s}/{n} - {s00e00} - {t.replaceAll(/[!?:.]+$/).replaceAll(/[`´‘’ʻ]/, "'")}.{hdr == 'HDR' { any{allOf{vf}{af}{vc}{ac}{VIDEO[0].HDR_format_commercial}.join('.')} {allOf{vf}{af}{vc}{ac}.join('.')} }
Thanks for your help Kim, it's really appreciated!!
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: HDR Snippet with UTorrent

Post by kim »

Code: Select all

{hdr = 'HDR' ? allOf{vf}{af}{vc}{ac}{VIDEO[0].HDR_format_commercial}.join('.') : allOf{vf}{af}{vc}{ac}.join('.')}
with

Code: Select all

{ any{allOf{vf}{af}{vc}{ac}{VIDEO[0].HDR_format_commercial}.join('.')} {allOf{vf}{af}{vc}{ac}.join('.')} }
this handle error,but if no errors maybe you can get away with only this ?

Code: Select all

{allOf{vf}{af}{vc}{ac}{VIDEO[0].HDR_format_commercial}.join('.')}
this is the same result as your org. format

...so

Code: Select all

p:/TV Shows/{n}/{'Season '+s}/{n} - {s00e00} - {t.replaceAll(/[!?:.]+$/).replaceAll(/[`´‘’ʻ]/, "'")}.{ any{allOf{vf}{af}{vc}{ac}{VIDEO[0].HDR_format_commercial}.join('.')} {allOf{vf}{af}{vc}{ac}.join('.')} }
Post Reply