Help: Hazel and the amc script

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
m4hu
Posts: 10
Joined: 26 Jan 2016, 10:50

Help: Hazel and the amc script

Post by m4hu »

Hi i'm trying to automate my filebotting but i have issues with getting it running:

first i have to external hard drives: one for movies and one for tv shows.
new stuff comes into a specific download folder and gets extracted by jdownloader and later the script gets called on the files "if movies file" after the script is successfull hazel pushes the files to the designated harddrives into folders.
my script looks like this:

Code: Select all

filebot -script fn:amc --output "/Volumes/NERVstorage 2/Unsortiert" --mode interactive --action copy -non-strict --log-file amc.log
--def excludeList=amc.txt 
--def unsorted=y
--def movieFormat= "/Volumes/NERVstorage 4/Filme{ny}/{fn}" seriesFormat= "/Volumes/NERVstorage 2/Unsortiert{n}/{fn}
but it wont work. hazel will output an error message that the script errored

when i try this script :

Code: Select all

filebot -script fn:amc --output "/path/to/output" --action copy -non-strict "/path/to/input" --log-file amc.log --def excludeList=amc.txt
Everything works except that it get put in just one folder
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: AMC on mac (problem with output paths)

Post by rednoah »

Try a few things. Follow the examples verbatim. Be weary of the extra white space that is part of your command but not seen in any of the examples.

If Hazel tells your something didn’t work, then you’ll want to see the output the command produced, because that’ll probably tell you exactly what’s wrong.
:idea: Please read the FAQ and How to Request Help.
m4hu
Posts: 10
Joined: 26 Jan 2016, 10:50

Re: AMC on mac (problem with output paths)

Post by m4hu »

now i wont get an error anymore but movies get renamed and moved the wrong way. he seems to get all the --def right but still then does it wrong

Code: Select all

Run script [fn:amc] at [Thu Jul 19 10:18:36 CEST 2018]
Parameter: clean = y
Parameter: unsorted = y
Parameter: movieFormat = /Volumes/NERVstorage 4/Filme
Parameter: seriesFormat = /Volumes/NERVstorage 2/Unsortiert
Argument[0]: /Users/NERV/Downloads/Entpackt/Operation.12.Strong.2018/Operation.12.Strong.2018.mkv
Input: /Users/NERV/Downloads/Entpackt/Operation.12.Strong.2018/Operation.12.Strong.2018.mkv
xattr: [Operation.12.Strong.2018.mkv] => [12 Strong (2018)]
Group: [mov:12 strong 2018] => [Operation.12.Strong.2018.mkv]
Rename movies using [TheMovieDB]
Auto-detect movie from context: [/Users/NERV/Downloads/Entpackt/Operation.12.Strong.2018/Operation.12.Strong.2018.mkv]
[MOVE] From [/Users/NERV/Downloads/Entpackt/Operation.12.Strong.2018/Operation.12.Strong.2018.mkv] to [/Volumes/NERVstorage 4/Filme.mkv]
Processed 1 files
Done ヾ(@⌒ー⌒@)ノ
this is the script that kinda works:

Code: Select all

filebot -script fn:amc --output "/Volumes/NERVstorage 2/Unsortiert" --mode interactive --action move --def clean=y -non-strict $1 --log-file amc.log --def unsorted=y --def movieFormat="/Volumes/NERVstorage 4/Filme" seriesFormat="/Volumes/NERVstorage 2/Unsortiert" ##--def excludeList=amc.txt
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: AMC on mac (problem with output paths)

Post by rednoah »

1.
This is completely wrong, as there are no variables in there at all, and hence every file will be moved to this exact output path, regardless of what file has been matched to what movie or episode:

Code: Select all

Parameter: movieFormat = /Volumes/NERVstorage 4/Filme
Parameter: seriesFormat = /Volumes/NERVstorage 2/Unsortiert

A correct movie format would look like this:

Code: Select all

/Volumes/A/{plex}
or this:

Code: Select all

/Volumes/B/Movies/{ny}
depending on your preferences, where {plex} and {ny} are variables that evaluate to different values for different movie / episode matches.


2.
I recommend using the {plex} binding:

Code: Select all

--def movieFormat="/Volumes/A/{plex}" seriesFormat="/Volumes/B/{plex}"
:arrow: viewtopic.php?f=5&t=4116
:idea: Please read the FAQ and How to Request Help.
m4hu
Posts: 10
Joined: 26 Jan 2016, 10:50

Re: AMC on mac (problem with output paths)

Post by m4hu »

Okay i changed it like you recommended now but now i get this output

Code: Select all

2018-07-19 12:59:15.746 hazelworker[99427] DEBUG: Rule executed. Updating match date for file /Users/NERV/Downloads/Entpackt/TheBlacklist.s04.51.SO/S04E15.Der Apotheker (Nr. 59).mp4: 2018-07-19 10:59:14 +0000
2018-07-19 12:59:15.746 hazelworker[99427] DEBUG: Action changed file: S04E15.Der Apotheker (Nr. 59).mp4
2018-07-19 12:59:15.749 hazelworker[99427] S04E16.Dembe Zuma (Nr. 10).mp4: Rule AMC matched.
2018-07-19 12:59:15.749 hazelworker[99427] DEBUG: New rule signature. Executing actions.
Old signatures: (
)
New Signature:{typeObject isType: "public.movie"}:{(shellscript:/bin/bash:ee375b7d8fbc855e10b4b6dd99be2934,{
})}
2018-07-19 12:59:17.116 hazelworker[99427] DEBUG: == script output ==
Locking /Users/NERV/.filebot/logs/amc.log
Illegal Argument: java.nio.file.NoSuchFileException: /Users/NERV/Downloads/Entpackt/TheBlacklist.s04.51.SO/S04E16.Dembe (/Users/NERV/Downloads/Entpackt/TheBlacklist.s04.51.SO/S04E16.Dembe)
Illegal Argument: java.nio.file.NoSuchFileException: /Users/NERV/Downloads/Entpackt/Zuma (Zuma)
Illegal Argument: java.nio.file.NoSuchFileException: /Users/NERV/Downloads/Entpackt/(Nr. ((Nr.)
Illegal Argument: java.nio.file.NoSuchFileException: /Users/NERV/Downloads/Entpackt/10).mp4 (10).mp4)
Run script [fn:amc] at [Thu Jul 19 12:59:16 CEST 2018]
Parameter: clean = y
Parameter: unsorted = y
Parameter: seriesFormat = /Volumes/NERVstorage 2/Unsortiert/{plex}
Parameter: movieFormat = /Volumes/NERVstorage 4/Filme/{plex}
Argument[0]: File does not exist: /Users/NERV/Downloads/Entpackt/TheBlacklist.s04.51.SO/S04E16.Dembe
Argument[1]: File does not exist: Zuma
Argument[2]: File does not exist: (Nr.
Argument[3]: File does not exist: 10).mp4
Skip small video file: 10).mp4
No files selected for processing
Done ヾ(@⌒ー⌒@)ノ
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: AMC on mac (problem with output paths)

Post by rednoah »

Lots of random errors. Looks like you're not quoting your arguments correctly.

This thread will explain things in detail:
viewtopic.php?t=1899

I think it'll be easier to first learn how to use the AMC script via the Terminal manually, and only start integrating with Hazel once you get how everything works and have a working prototype command.

I'd recommend making your own shell script first, such as this:

Code: Select all

#!/bin/sh
/usr/local/bin/filebot -script fn:amc --output "$HOME/Media" --action duplicate --conflict skip -non-strict --log-file amc.log --def excludeList=".excludes" unsorted=y music=y artwork=y "$@"
Now you can call your own script like this:

Code: Select all

/path/to/amc.sh "/path/to/Avatar.mp4"
which allows you to easily test and call your script yourself, and then it'll make it easier to have Hazel call the same script, and just passing in the file arguments automatically.



EDIT:

How did you set things up with Hazel? Screenshots? Does Hazel have documentation or examples on how to call command-line tools that might be helpful to you?

:arrow: Here's how it works with Automator: viewtopic.php?f=4&t=3908
:idea: Please read the FAQ and How to Request Help.
m4hu
Posts: 10
Joined: 26 Jan 2016, 10:50

Re: AMC on mac (problem with output paths)

Post by m4hu »

So Hazel watches over my a my Download/Extracted Folder for new Folders (created by jdownloader)

Image

if this rule is matched it will then run this Rule h it matches the files in the folder. So when its a movie,mp4 or mkv file is found it runs the shellscript

Image
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: AMC on mac (problem with output paths)

Post by rednoah »

1.
What other options are available in the second combo box instead of embedded script?

:idea: I recommend making your own amc.sh shell script as described above, and then selecting that. Presumably, Hazel will then just call the script and pass in the file arguments appropriately without you having to worry about quoting or escaping arguments.


2.
If you're using JD, then integrating FileBot directly with JD might worth considering:
viewtopic.php?f=4&t=3478
:idea: Please read the FAQ and How to Request Help.
m4hu
Posts: 10
Joined: 26 Jan 2016, 10:50

Re: AMC on mac (problem with output paths)

Post by m4hu »

in the second combobox i can choose "other..." but i cant select a .sh or .bash file form there.

when running this script in terminal (of course with changing the input from $1 to the folderpath) everything works fine :/
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: AMC on mac (problem with output paths)

Post by rednoah »

I've tried Hazel (Evaluation), and it works fine out of the box.


1. Create shell script file: amc.sh

Code: Select all

#!/bin/sh
/usr/local/bin/filebot -script fn:amc "$@" --output "$HOME/Media" --action duplicate --conflict skip -non-strict --log-file "$HOME/amc.log" --action TEST --def excludeList=".excludes" unsorted=y music=y artwork=y
:!: DO NOT make your own customizations prematurely, so we don't accidentally break things.


2. Make amc.sh executable:

Code: Select all

chmod +x /path/to/amc.sh

3.
Select amc.sh in Hazel (this works now, because presumably Hazel will only allow you to select executable files).


4.
Modify amc.sh to your needs. Before making modifications, make sure it works. After making modifications, make sure it works. After each and every step, make sure it works. That way you know exactly when and how things break, and so you can easily see and fix any issue.

At this point, we know that Hazel can run our script, because we can check the log and see if it's called or not. However, for rapid testing, it's much easier to call the script from terminal directly, e.g.

Code: Select all

/path/to/amc.sh /path/to/test/folder
We use this options so we can easily test things:

Code: Select all

--log-file "$HOME/amc.log" --action TEST
* specify --log-file so we know exactly where the log file is (your $HOME folder) so we can check what's going on after each test run
* specify --action TEST so that we're just doing dry-runs for now, which makes it easy to test things on the same files over and over (especially useful when prototyping custom formats)


5.
Change --action TEST to --action MOVE to actually move files, instead of just doing dry runs.
:idea: Please read the FAQ and How to Request Help.
Post Reply