Page 1 of 1

Hazel and Handbrake CLI error

PostPosted: Tue Mar 12, 2013 8:23 am
by tscibilia
Hey, i've recently been getting an error with my Hazel workflow for TVs and Movies http://www.noodlesoft.com/forums/viewtopic.php?f=4&t=1885

Code: Select all
2013-03-12 08:18:16.426 hazelworker[91403] SOME-TV-OR-MOVIEFILE.avi: Rule Run Handbrake CLI matched.
2013-03-12 08:18:16.488 hazelworker[91403] [Error] AppleScript failed: Error executing AppleScript on file /Volumes/home/Torrents/Downloaded/!PROCESSING/1.0 TV Shows - Handbrake/SOME-TV-OR-MOVIEFILE.avi.
2013-03-12 08:18:16.488 hazelworker[91403] AppleScript error: {
    NSLocalizedDescription = "The variable origFilepath is not defined.";
    NSLocalizedFailureReason = "The variable origFilepath is not defined.";
    OSAScriptErrorAppAddressKey = "<NSAppleEventDescriptor: null()>";
    OSAScriptErrorBriefMessageKey = "The variable origFilepath is not defined.";
    OSAScriptErrorMessageKey = "The variable origFilepath is not defined.";
    OSAScriptErrorNumberKey = "-2753";
    OSAScriptErrorOffendingObjectKey = "<NSAppleEventDescriptor: 'utxt'(\"origFilepath\")>";
    OSAScriptErrorRangeKey = "NSRange: {0, 0}";
}

Re: Hazel and Handbrake CLI error

PostPosted: Tue Mar 12, 2013 12:31 pm
by Mr_Noodle
Have you tried the script outside of Hazel (against the same file)? Also, have you installed anything that installs AppleScript extensions (.osax)?

Re: Hazel and Handbrake CLI error

PostPosted: Tue Mar 12, 2013 12:32 pm
by a_freyer
That error says that the variable origFilePath is not defined. Check your script to be sure you have declared and set this variable.

Re: Hazel and Handbrake CLI error

PostPosted: Tue Mar 12, 2013 7:10 pm
by tscibilia
Mr_Noodle wrote:Have you tried the script outside of Hazel (against the same file)? Also, have you installed anything that installs AppleScript extensions (.osax)?


the latest things ive installed were:
turbotax, instashare, doo, owncloud, and drive genius

i don't think they installed .osax files, but how can i be sure?

Re: Hazel and Handbrake CLI error

PostPosted: Tue Mar 12, 2013 8:00 pm
by tscibilia
a_freyer wrote:That error says that the variable origFilePath is not defined. Check your script to be sure you have declared and set this variable.


I see that but i don't know how to fix it. like i said it use to work fine.

I got the script from here...viewtopic.php?p=3447#p3447

Re: Hazel and Handbrake CLI error

PostPosted: Wed Mar 13, 2013 11:50 am
by Mr_Noodle
Check Library/ScriptingAdditions (both in your home folder and at the root of your drive). Again, though, you should try running the script outside of Hazel to confirm it works, making sure to run it against the same file that is giving you the error.

Re: Hazel and Handbrake CLI error

PostPosted: Wed Mar 13, 2013 11:52 am
by a_freyer
The line...

Code: Select all
         set origFilepath to quoted form of POSIX path of (theFile as alias)


...is likely what is causing the problem.

I anticipate that you are potentially sending a folder, or something similar to the script, causing origFilepath to be (null).

What are the rule conditions you have for this particular rule? To you include only certain file types? This this rule part of a "run rules on folder contents" group?

Re: Hazel and Handbrake CLI error

PostPosted: Wed Mar 13, 2013 3:04 pm
by AdamRoxby
I have had no luck in getting HandBrake CLI to convert movies.

I wanted it to convert my iPhone videos that are just too big and can be rendered down without loosing quality.

While doing some searching I found that a lot of people were using this program called HandBrakeBatch. What do people think to this as a solution?

http://www.osomac.com/apps/osx/handbrake-batch/

Re: Hazel and Handbrake CLI error

PostPosted: Wed Mar 13, 2013 3:13 pm
by a_freyer
Depends on whether this has a command line interface or an applescript dictionary. Either?

Re: Hazel and Handbrake CLI error

PostPosted: Wed Mar 13, 2013 8:35 pm
by tscibilia
a_freyer wrote:The line...

Code: Select all
         set origFilepath to quoted form of POSIX path of (theFile as alias)


...is likely what is causing the problem.

I anticipate that you are potentially sending a folder, or something similar to the script, causing origFilepath to be (null).

What are the rule conditions you have for this particular rule? To you include only certain file types? This this rule part of a "run rules on folder contents" group?


Oddly enough you helped me get this procedure working a while back. here's my current set of rules viewtopic.php?f=4&t=1885#p7797

One last bit of info. all these files are on my networked synology drive that I mount to via afp://



1.0 TV Shows - Handbrake
Run Handbrake CLI
• If <all> conditions met for <the file or folder being matched>
<Date Added> is after <Date Last Matched>
<Extension> is not <m4v>
• Do the following
<Run AppleScript>
Code: Select all
tell application "Finder"
   try
      --Set to red label to indicate processing
      set label index of theFile to 2
      --Assemble original and new file paths
      set origFilepath to quoted form of POSIX path of (theFile as alias)
      set newFilepath to (characters 1 thru -5 of origFilepath as string) & "m4v'"
      --Start the conversion
      set shellCommand to "nice /Applications/HandBrakeCLI -i " & origFilepath & " -o " & newFilepath & " --preset=\"AppleTV 3\" ;"
      do shell script shellCommand
      --Set the label to orange
      set label index of theFile to 3
   end try
end tell
tell application "Finder"
   set movieName to name of item theFile
end tell
tell application "Growl"
   set the allNotificationsList to {"Handbrake convert complete"}
   set the enabledNotificationsList to {"Handbrake convert complete"}
   register as application "Handbrake Encode Growler" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "HandBrake"
   notify with name "Handbrake convert complete" title "Handbrake conversion complete" description "The video \"" & movieName & "\" has been converted." application name "Handbrake Encode Growler"
   --Remove the old file
   set shellCommand to "rm -f " & origFilepath
   do shell script shellCommand
end tell

Move to be Renamed (This works, but I'm not sure how low I can make the trigger such as 3 mins?)
• If <all> conditions met for <the file or folder being matched>
<Extension> is <m4v>
<Date Last Modified> is not in the last <30 minutes>
• Do the following
<Move> to folder <2.0 TV Shows - Rename>

Re: Hazel and Handbrake CLI error

PostPosted: Wed Mar 13, 2013 8:39 pm
by a_freyer
Edit -removed as unrelated

Re: Hazel and Handbrake CLI error

PostPosted: Wed Mar 13, 2013 10:26 pm
by tscibilia
i honestly have no idea, i got that script from here...viewtopic.php?p=3447#p3447

and i saw it being used here to...https://forum.handbrake.fr/viewtopic.ph ... zel#p70244


how can i "define origFilepath"
I'm confused because i never ran into this problem before. If i wanted to test this applescript outside of hazel (like in automator) i get a window that looks like this...how would i edit it to test the applescript because i get an error "variable theFile is not defined"
Code: Select all
on run {input, parameters}
   
   (* Your script goes here *)
   
   return input
end run

Re: Hazel and Handbrake CLI error

PostPosted: Wed Mar 13, 2013 10:29 pm
by a_freyer
Edit - removed as unrelated

Re: Hazel and Handbrake CLI error

PostPosted: Thu Mar 14, 2013 8:14 am
by tscibilia
i didn't try it in automator. coincidentally i was have other troubles with my network drives and found out that my Media drive was actually Media-1 and after i cleared my Library caches, unmounted everything in my Volumes folder and restarted. I tested the same old script through Hazel and it worked fine.

so does anyone know how to prevent network folders from mounted with the apprendix "-1"?

Re: Hazel and Handbrake CLI error

PostPosted: Fri Mar 15, 2013 12:49 pm
by Mr_Noodle
It would happen if there was another drive already mounted as "Media". Otherwise, not sure what is going on there.