Page 1 of 1

Running AMC script with complicated naming scheme

Posted: 06 Dec 2015, 06:19
by greenskye
I'm trying to run the AMC script on linux with a custom naming scheme. I didn't develop this scheme myself, just found it posted online somewhere and it's worked well for me. Trying to use it via command line has proven frustrating however.

This is my naming scheme:

Code: Select all

D:/Movies/{collection.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/).replaceFirst(/^(?i)(Collection of the)\s(.+)/, /$2 Collection/).replaceAll(/Saga Collection/, "Saga").replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ")}/{norm = {it.upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceAll(/\b[IiVvXx]+\b/, { it.upper() }).replaceAll(/\b[0-9](?i:th|nd|rd)\b/, { it.lower() }).replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)}; norm(n)}{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""} ({y}{' '+any{certification}{imdb.certification}.replaceAll(/^\d+$/, 'PG-$0')})/{norm(n.space('.'))}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""}{'.(' + fn.matchAll(/extended|uncensored|remastered|unrated|uncut|directors.cut|special.edition/)*.upperInitial()*.lowerTrail().sort().join(', ').replaceAll(/[._]/, ".") + ')'}{".Part.$pi"}{".[$vf.$vc.$ac.$af]"}{'.'+lang}
I've tried using the escape script and xargs, but both give me this error:

Code: Select all

/bin/bash: -c: line 0: syntax error near unexpected token `('
/bin/bash: -c: line 0: `. /mnt/cache/.PhAzE-Common/Filebot/startcfg.sh; /usr/local/Filebot/filebot.sh -script fn:amc --output /mnt/user/Downloads --action copy -non-strict /mnt/user/Downloads/movies --def excludeList=amc.txt --action test --def movieFormat={collection.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/).replaceFirst(/^(?i)(Collection of the)\s(.+)/, /$2 Collection/).replaceAll(/Saga Collection/, "Saga").replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ")}/{norm = {it.upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceAll(/\b[IiVvXx]+\b/, { it.upper() }).replaceAll(/\b[0-9](?i:th|nd|rd)\b/, { it.lower() }).replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)}; norm(n)}{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""} ({y}{' '+any{certification}{imdb.certification}.replaceAll(/^\d+$/, 'PG-$0')})/{norm(n.space('.'))}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""}{'.(' + fn.matchAll(/extended|uncensored|remastered|unrated|uncut|directors.cut|special.edition/)*.upperInitial()*.lowerTrail().sort().join(', ').replaceAll(/[._]/, ".") + ')'}{".Part.$pi"}{".[$vf.$vc.$ac.$af]"}{'.'+lang}'
I'd like to keep using my naming scheme if at all possible, but I understand if it's just too big and unwieldy to modify properly.

Re: Running AMC script with complicated naming scheme

Posted: 06 Dec 2015, 09:55
by rednoah

Re: Running AMC script with complicated naming scheme

Posted: 06 Dec 2015, 17:32
by greenskye
I did read both of those, but I must still be missing something.

Here's my original unaltered naming format for reference:

Code: Select all

{collection.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/).replaceFirst(/^(?i)(Collection of the)\s(.+)/, /$2 Collection/).replaceAll(/Saga Collection/, "Saga").replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ")}/{norm = {it.upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceAll(/\b[IiVvXx]+\b/, { it.upper() }).replaceAll(/\b[0-9](?i:th|nd|rd)\b/, { it.lower() }).replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)}; norm(n)}{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""} ({y}{' '+any{certification}{imdb.certification}.replaceAll(/^\d+$/, 'PG-$0')})/{norm(n.space('.'))}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""}{'.(' + fn.matchAll(/extended|uncensored|remastered|unrated|uncut|directors.cut|special.edition/)*.upperInitial()*.lowerTrail().sort().join(', ').replaceAll(/[._]/, ".") + ')'}{".Part.$pi"}{".[$vf.$vc.$ac.$af]"}{'.'+lang}
This is what I get when I run it through the escape script:

Code: Select all

"{collection.replaceFirst(/\^(?i)(The)\\s(.+)/, /\$2, \$1/).replaceFirst(/\^(?i)(Collection of the)\\s(.+)/, /\$2 Collection/).replaceAll(/Saga Collection/, \"Saga\").replaceAll(/[\`´‘’ʻ\"\"“”]/, \"'\").replaceAll(/[:|]/, \" - \").replaceAll(/[?]/, \"!\").replaceAll(/[*\\s]+/, \" \")}/{norm = {it.upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/[\`´‘’ʻ\"\"“”]/, \"'\").replaceAll(/[:|]/, \" - \").replaceAll(/[?]/, \"!\").replaceAll(/[*\\s]+/, \" \").replaceAll(/\\b[IiVvXx]+\\b/, { it.upper() }).replaceAll(/\\b[0-9](?i:th|nd|rd)\\b/, { it.lower() }).replaceFirst(/\^(?i)(The)\\s(.+)/, /\$2, \$1/)}; norm(n)}{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':\"\"} ({y}{' '+any{certification}{imdb.certification}.replaceAll(/\^\\d+\$/, 'PG-\$0')})/{norm(n.space('.'))}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':\"\"}{'.(' + fn.matchAll(/extended|uncensored|remastered|unrated|uncut|directors.cut|special.edition/)*.upperInitial()*.lowerTrail().sort().join(', ').replaceAll(/[._]/, \".\") + ')'}{\".Part.\$pi\"}{\".[\$vf.\$vc.\$ac.\$af]\"}{'.'+lang}"
Running that format in my command:

Code: Select all

filebot -script fn:amc --output "/mnt/user/Downloads" --action copy -non-strict "/mnt/user/Downloads/movies" --def excludeList=amc.txt --action test --def "movieFormat={collection.replaceFirst(/\^(?i)(The)\\s(.+)/, /\$2, \$1/).replaceFirst(/\^(?i)(Collection of the)\\s(.+)/, /\$2 Collection/).replaceAll(/Saga Collection/, \"Saga\").replaceAll(/[\`´‘’ʻ\"\"“”]/, \"'\").replaceAll(/[:|]/, \" - \").replaceAll(/[?]/, \"!\").replaceAll(/[*\\s]+/, \" \")}/{norm = {it.upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/[\`´‘’ʻ\"\"“”]/, \"'\").replaceAll(/[:|]/, \" - \").replaceAll(/[?]/, \"!\").replaceAll(/[*\\s]+/, \" \").replaceAll(/\\b[IiVvXx]+\\b/, { it.upper() }).replaceAll(/\\b[0-9](?i:th|nd|rd)\\b/, { it.lower() }).replaceFirst(/\^(?i)(The)\\s(.+)/, /\$2, \$1/)}; norm(n)}{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':\"\"} ({y}{' '+any{certification}{imdb.certification}.replaceAll(/\^\\d+\$/, 'PG-\$0')})/{norm(n.space('.'))}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':\"\"}{'.(' + fn.matchAll(/extended|uncensored|remastered|unrated|uncut|directors.cut|special.edition/)*.upperInitial()*.lowerTrail().sort().join(', ').replaceAll(/[._]/, \".\") + ')'}{\".Part.\$pi\"}{\".[\$vf.\$vc.\$ac.\$af]\"}{'.'+lang}"
gives me a "-bash: !\: event not found" error.

Some research reveals that the escape script doesn't seem to properly handle exclamation marks. Apparently they get parsed without respect for quotation marks. You can escape them with backslash, but then the backslash is not escaped either. More information here:http://superuser.com/a/301330.

Code: Select all

replaceAll("!")
becomes

Code: Select all

replaceAll(\""'!'"\")
Tested this with echo and it all seemed to work. My newly formatted naming scheme became:

Code: Select all

{collection.replaceFirst(/\^(?i)(The)\\s(.+)/, /\$2, \$1/).replaceFirst(/\^(?i)(Collection of the)\\s(.+)/, /\$2 Collection/).replaceAll(/Saga Collection/, \"Saga\").replaceAll(/[\`´‘’ʻ\"\"“”]/, \"'\").replaceAll(/[:|]/, \" - \").replaceAll(/[?]/, \""'!'"\").replaceAll(/[*\\s]+/, \" \")}/{norm = {it.upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/[\`´‘’ʻ\"\"“”]/, \"'\").replaceAll(/[:|]/, \" - \").replaceAll(/[?]/, \""'!'"\").replaceAll(/[*\\s]+/, \" \").replaceAll(/\\b[IiVvXx]+\\b/, { it.upper() }).replaceAll(/\\b[0-9](?i:th|nd|rd)\\b/, { it.lower() }).replaceFirst(/\^(?i)(The)\\s(.+)/, /\$2, \$1/)}; norm(n)}{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':\"\"} ({y}{' '+any{certification}{imdb.certification}.replaceAll(/\^\\d+\$/, 'PG-\$0')})/{norm(n.space('.'))}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':\"\"}{'.(' + fn.matchAll(/extended|uncensored|remastered|unrated|uncut|directors.cut|special.edition/)*.upperInitial()*.lowerTrail().sort().join(', ').replaceAll(/[._]/, \".\") + ')'}{\".Part.\$pi\"}{\".[\$vf.\$vc.\$ac.\$af]\"}{'.'+lang}
However actually attempting to use it:

Code: Select all

filebot -script fn:amc --output "/mnt/user/Downloads" --action copy -non-strict "/mnt/user/Downloads/movies" --def excludeList=amc.txt --action test --def "movieFormat={collection.replaceFirst(/\^(?i)(The)\\s(.+)/, /\$2, \$1/).replaceFirst(/\^(?i)(Collection of the)\\s(.+)/, /\$2 Collection/).replaceAll(/Saga Collection/, \"Saga\").replaceAll(/[\`´‘’ʻ\"\"“”]/, \"'\").replaceAll(/[:|]/, \" - \").replaceAll(/[?]/, \""'!'"\").replaceAll(/[*\\s]+/, \" \")}/{norm = {it.upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/[\`´‘’ʻ\"\"“”]/, \"'\").replaceAll(/[:|]/, \" - \").replaceAll(/[?]/, \""'!'"\").replaceAll(/[*\\s]+/, \" \").replaceAll(/\\b[IiVvXx]+\\b/, { it.upper() }).replaceAll(/\\b[0-9](?i:th|nd|rd)\\b/, { it.lower() }).replaceFirst(/\^(?i)(The)\\s(.+)/, /\$2, \$1/)}; norm(n)}{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':\"\"} ({y}{' '+any{certification}{imdb.certification}.replaceAll(/\^\\d+\$/, 'PG-\$0')})/{norm(n.space('.'))}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':\"\"}{'.(' + fn.matchAll(/extended|uncensored|remastered|unrated|uncut|directors.cut|special.edition/)*.upperInitial()*.lowerTrail().sort().join(', ').replaceAll(/[._]/, \".\") + ')'}{\".Part.\$pi\"}{\".[\$vf.\$vc.\$ac.\$af]\"}{'.'+lang}"
gives me this error:

Code: Select all

/bin/bash: -c: line 0: syntax error near unexpected token `('
/bin/bash: -c: line 0: `. /mnt/cache/.PhAzE-Common/Filebot/startcfg.sh; /usr/local/Filebot/filebot.sh -script fn:amc --output /mnt/user/Downloads --action copy -non-strict /mnt/user/Downloads/movies --def excludeList=amc.txt --action test --def movieFormat={collection.replaceFirst(/\^(?i)(The)\s(.+)/, /$2, $1/).replaceFirst(/\^(?i)(Collection of the)\s(.+)/, /$2 Collection/).replaceAll(/Saga Collection/, "Saga").replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ")}/{norm = {it.upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceAll(/\b[IiVvXx]+\b/, { it.upper() }).replaceAll(/\b[0-9](?i:th|nd|rd)\b/, { it.lower() }).replaceFirst(/\^(?i)(The)\s(.+)/, /$2, $1/)}; norm(n)}{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""} ({y}{' '+any{certification}{imdb.certification}.replaceAll(/\^\d+$/, 'PG-$0')})/{norm(n.space('.'))}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""}{'.(' + fn.matchAll(/extended|uncensored|remastered|unrated|uncut|directors.cut|special.edition/)*.upperInitial()*.lowerTrail().sort().join(', ').replaceAll(/[._]/, ".") + ')'}{".Part.$pi"}{".[$vf.$vc.$ac.$af]"}{'.'+lang}'
I'm not sure why I can echo this command perfectly and yet trying to run it results in problems.

Re: Running AMC script with complicated naming scheme

Posted: 06 Dec 2015, 17:41
by rednoah
Well, since you're not on Windows you should use the better solution:
viewtopic.php?f=4&t=1041#p9794

Image

Re: Running AMC script with complicated naming scheme

Posted: 06 Dec 2015, 18:12
by greenskye
Using xargs gives me the same error.

Image

Re: Running AMC script with complicated naming scheme

Posted: 06 Dec 2015, 19:45
by rednoah
r3369 and newer will allow you to do this:

Code: Select all

--def "movieFormat=@/path/to/movieFormat.txt"

Re: Running AMC script with complicated naming scheme

Posted: 06 Dec 2015, 20:20
by greenskye
I take it that release isn't out yet? I have 4.6.1 which is r3315. I checked github, but I'm not sure how or where to search for r3369. Thanks for helping me.

Re: Running AMC script with complicated naming scheme

Posted: 06 Dec 2015, 20:32
by rednoah

Re: Running AMC script with complicated naming scheme

Posted: 06 Dec 2015, 22:41
by rednoah
As it turns out, the args4j library I use for argument parsing already has built-in support for something like that... :lol:

Code: Select all

filebot @/path/to/file
This may have been possible for years... :lol: