Hazel - Need help using hazel to add a video download to Downie

Here’s what I’m trying to have happen:

  1. Share YouTube link from iOS share sheet (via shortcuts) creates a file in an iCloud directory.
  2. Hazel is watching that directory and when a file is added runs an apple script that takes the url from the text file and opens it in Downie
  3. Downie is configured to save videos directly into my Plex library.

I have 1 & 3 solved. I’m stuck on 2. Here’s the AppleScript that works:
tell application "Downie" open location "https://www.youtube.com/watch?v=leymqM3a8ho" end tell

But I can’t figure out a way to have Hazel replace that YouTube url with the text contents of the file that triggers the rule.

Thanks for any help you can provide!

@Tjluoma explains the process and script here:

I have it running at home and it works perfectly with icloud and downie

1 Like

If I wanted to pass the content of a file to an AppleScript in Hazel, I’d probably do it like this, defining a function for calling the AppleScript within a shell script that reads in the file content to a variable I can then just pass in.

2021-03-25-21.05.10

You could also read the content from the file directly in AppleScript. theFile is the object you would reference. I just personally find shell scripting is often more straight forward than AppleScripting.

1 Like

Maybe not the answer you are looking for, and I would likely rather do this through a script as well, but this Keyboard Maestro macro works for me. It is triggered via AppleScript and Hazel:

1 Like

Note, if the OP does happen to have Keyboard Maestro (all Mac automators should :wink:), they would also have to leave their Mac unlocked to get this sort of interaction to work, which is bad practice from a security standpoint.

1 Like

This worked! Thanks.

1 Like

I briefly considered using KM, but I try not to cross the streams. Hazel for file automation, KM for macros, Text Expander for text expansion.

2 Likes

Totally understandable motivation!

Fair point, I have a headless Mac mini in a locked closet running automations like this.

I should work on getting out of GUI scripting macros, but until then I am fine with the trade-off.

1 Like