Running FileBot from the console, Groovy scripting, shell scripts, etc
eurotrato
Posts: 4 Joined: 20 Oct 2021, 09:52
Post
by eurotrato » 20 Oct 2021, 10:19
Hi there. I have this code that does not work with version 4.9.4
I want to select multimedia by format and bitrate. Or even format, video bitrate and file size.
Code: Select all
{ny} -
{ (hd == 'SD' && vf == '240p') ? ( ((bytes/1073741824).round(1) >= 0.7 && bitrate >= 1.1e6d ? 'DVDRip' : {any{text.size()}{0} > 0 ? 'TVRip':'TVRip'})) :
(hd == 'SD' && vf == '360p') ? ( ((bytes/1073741824).round(1) >= 0.7 && bitrate >= 1.1e6d ? 'DVDRip' : {any{text.size()}{0} > 0 ? 'TVRip':'TVRip'})) :
(hd == 'SD' && vf == '480p') ? ( ((bytes/1073741824).round(1) >= 0.7 && bitrate >= 1.1e6d ? 'DVDRip' : {any{text.size()}{0} > 0 ? 'TVRip':'TVRip'})) :
(hd == 'SD' && vf == '576p') ? ( ((bytes/1073741824).round(1) >= 0.7 && bitrate >= 1.1e6d ? 'DVDRip' : {any{text.size()}{0} > 0 ? 'TVRip':'TVRip'})) :
((hd == 'HD') ?
(((bytes/1073741824).round(0) > 0 && bitrate >= 18e6 ? 'BDRemux' :
(bitrate > 8e6) ? {any{text.size()}{0} > 0 ? 'BDRip':'BDRip'} :
(bitrate > 2.2e6) ? {any{text.size()}{0} > 0 ? 'MicroHD':'MicroHD'} :
{any{text.size()}{0} > 0 ? 'HDRip':'HDRip'})) :
(hd == 'UHD') ?
(((bytes/1073741824).round(1) > 0 && bitrate >= 32e6d ? 'UHDRemux' :
(bitrate > 16e6d) ? {any{text.size()}{0} > 0 ? 'UHDRip':'UHDRip'} :
{any{text.size()}{0} > 0 ? 'MicroUHD':'MicroUHD'}))
}
Another alternative, but format is missing (480p, 720p, 1080p, etc):
Code: Select all
{
if (bitrate > 18e6)
" BDRemux"
else if (bitrate > 5e6)
" BDRip"
else if (bitrate > 1.5e6)
" MicroHD"
else
""
}
Thanks for the help.
rednoah
The Source
Posts: 23930 Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:
Post
by rednoah » 20 Oct 2021, 12:11
{bytes} and
{bitrate} are no longer simple
Number objects, so you might need to update your custom format a little bit. See linked post for details:
viewtopic.php?p=55485#p55485
Note that your format is also syntactically incorrect, which is unrelated to
{bytes} and
{bitrate} , somewhere in that incomprehensible sequence of nested ternary expressions:
Code: Select all
SyntaxError: expecting ':', found ''
Did you write the code yourself for your specific purpose or did you copy & paste it from somewhere? The code above seems to guess source media based on resolution / file size / video length. However,
source media bindings {vs} and {source} is probably more suitable for typical use cases where you can guess the source media from the file path.
rednoah
The Source
Posts: 23930 Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:
Post
by rednoah » 20 Oct 2021, 12:14
I'd rewrite the code in a more human-readable manner like so:
Code: Select all
{
if (hd == 'SD')
if (bytes.MB >= 700 && bitrate.mbps >= 1.1)
return 'DVDRip'
else
return 'TVRip'
if (hd == 'HD')
if (bytes.GB >= 1 && bitrate.mbps >= 18)
return 'BDRemux'
else if (bitrate.mbps >= 8)
return 'BDRip'
else if (bitrate.mbps >= 2.2)
return 'MicroHD'
else
return 'HDRip'
if (hd == 'UHD')
if (bytes.GB >= 1 && bitrate.mbps >= 32)
return 'UHDRemux'
else if (bitrate.mbps >= 16)
return 'UHDRip'
else
return 'MicroUHD'
}
eurotrato
Posts: 4 Joined: 20 Oct 2021, 09:52
Post
by eurotrato » 20 Oct 2021, 12:18
Hi there. This is the correct code and working in version 4.8.5 and that in the new version it does not work:
Code: Select all
{ (hd == 'SD' && vf == '240p') ? ( ((bytes/1073741824).round(1) >= 0.7 && bitrate >= 1100000 ? 'DVDRip' : {any{text.size()}{0} > 0 ? 'TVRip':'TVRip'})) :
(hd == 'SD' && vf == '360p') ? ( ((bytes/1073741824).round(1) >= 0.7 && bitrate >= 1100000 ? 'DVDRip' : {any{text.size()}{0} > 0 ? 'TVRip':'TVRip'})) :
(hd == 'SD' && vf == '480p') ? ( ((bytes/1073741824).round(1) >= 0.7 && bitrate >= 1100000 ? 'DVDRip' : {any{text.size()}{0} > 0 ? 'TVRip':'TVRip'})) :
(hd == 'SD' && vf == '576p') ? ( ((bytes/1073741824).round(1) >= 0.7 && bitrate >= 1100000 ? 'DVDRip' : {any{text.size()}{0} > 0 ? 'TVRip':'TVRip'})) :
((hd == 'HD') ?
(((bytes/1073741824).round(1) > 0 && bitrate >= 18000000 ? 'BDRemux' :
(bitrate > 8000000) ? {any{text.size()}{0} > 0 ? 'BDRip':'BDRip'} :
(bitrate > 2200000) ? {any{text.size()}{0} > 0 ? 'MicroHD':'MicroHD'} :
{any{text.size()}{0} > 0 ? 'HDRip':'HDRip'})) :
(hd == 'UHD') ?
(((bytes/1073741824).round(1) > 0 && bitrate >= 32000000 ? 'BDRemux' :
(bitrate > 16000000) ? {any{text.size()}{0} > 0 ? 'BDRip':'BDRip'} :
{any{text.size()}{0} > 0 ? 'MicroHD':'MicroHD'})) :
(hd == 'HD' && vf == '10XXX80p' ?
((bytes/1073741824).round(1) > 5 && bitrate >= 18000000) ? 'BDRemux_1080p' :
(bitrate > 8000000) ? {any{text.size()}{0} > 0 ? 'BDRip_720p':'BDRip_1080p'} :
{any{text.size()}{0} > 0 ? 'BRRip_1080p_1':'BRRip_1080p_1'} :
{any{text.size()}{0} > 0 ? 'BRRip_1080p_2':'BRRip_1080p_2'}))}
My knowledge is very poor and I only copy and paste script from other people.
I appreciate the help and that you serve as my guru.
Thanks if you can fix the transition of the new variables for me.
P.S. I use google translator from Spain and a registered version of the program. Thanks again.
eurotrato
Posts: 4 Joined: 20 Oct 2021, 09:52
Post
by eurotrato » 20 Oct 2021, 12:20
You are a crack. In the end I have left the code like this:
Code: Select all
{
if (hd == 'SD')
if (bytes.MB >= 700 && bitrate.mbps >= 1.1)
return 'DVDRip'
else
return 'TVRip'
if (hd == 'HD' && vf == '720p')
if (bytes.GB >= 0.1 && bitrate.mbps >= 18)
return 'BDRemux'
else if (bitrate.mbps >= 8)
return 'BDRip'
else if (bitrate.mbps >= 2.2)
return 'MicroHD'
else
return 'HDRip'
if (hd == 'HD' && vf == '1080p')
if (bytes.GB >= 0.1 && bitrate.mbps >= 18)
return 'BDRemux'
else if (bitrate.mbps >= 8)
return 'BDRip'
else if (bitrate.mbps >= 2.2)
return 'MicroHD'
else
return 'BRRip'
if (hd == 'UHD')
if (bytes.GB >= 0.1 && bitrate.mbps >= 32)
return 'UHDRemux'
else if (bitrate.mbps >= 16)
return 'UHDRip'
else if (bitrate.mbps >= 4)
return 'MicroUHD'
else
return 'BRRip'
}
Thank you very much for the help. Without you I would not have made it.
rednoah
The Source
Posts: 23930 Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:
Post
by rednoah » 20 Oct 2021, 15:05
Why unnecessarily duplicate large swathes of code when just want to add an extra condition?
Code: Select all
{
if (hd == 'SD')
if (bytes.MB >= 700 && bitrate.mbps >= 1.1)
return 'DVDRip'
else
return 'TVRip'
if (hd == 'HD')
if (bytes.MB >= 100 && bitrate.mbps >= 18)
return 'BDRemux'
else if (bitrate.mbps >= 8)
return 'BDRip'
else if (bitrate.mbps >= 2.2)
return 'MicroHD'
else if (vf == '1080p')
return 'BRRip'
else
return 'HDRip'
if (hd == 'UHD')
if (bytes.MB >= 100 && bitrate.mbps >= 32)
return 'UHDRemux'
else if (bitrate.mbps >= 16)
return 'UHDRip'
else if (bitrate.mbps >= 4)
return 'MicroUHD'
else
return 'BRRip'
}