Play Magnet Link in VLC via Peerflix

This will open the magnet link under your mouse pointer and open it in VLC via Peerflix.

Play Magnet Link.kmmacros (50.2 KB)


The issue I'd like to solve is that VLC opens in Always On Top mode, despite this being disabled in VLC Preferences. Any help appreciated.
VLC behaves normally if you open the file manually (i.e. not via Terminal), so I wonder if there's a way to pause until the video is partially downloaded and then open it via KM. Perhaps there's a way to keep checking the size of the folder (/tmp/torrent-stream) at intervals, and then open it in VLC once the size exceeds something sensible, like 50mb?

EDIT: It now waits for the folder size to indicate that enough has downloaded for the video to play and then opens it in VLC directly. I've updated the above macro accordingly. Big thanks to @Sleepy for helping with that!

Here's a companion macro that will ask you whether you want to trash the temporary files when you quit VLC, if any exist, then force-quit Terminal:

VLC - Delete Temporary Files?.kmmacros (41.7 KB)


(upload://v613M3lFk0ow72hN1p6mcOoFLu4.kmmacros) (41.7 KB)

1 Like

If you can control VLC from the GUI using your mouse and keyboard, why not just send the same keys/clicks using KM to turn off "Always on Top" mode?

As I said, it's already off in the settings. The issue is that launching VLC from Terminal for some reason forces it to be on top, despite this.

Oh, sorry. Then why not use a different way to open it? Did you try Execute Shell Script? Did you try the KM action "Open"?

Looking at the VLC command-line help wiki, you could try adding this option to the command line you use in terminal

      --video-on-top, --no-video-on-top 
                                 Always on top
                                 (default disabled)

Thanks for the suggestion, but it doesn't make any difference and VLC is still permanently on top. Weird, huh.

Do you happen to know of a way to 'pause until folder is greater than 50mb'? It's the only solution I can think of.

That might work, but you didn't say what happens when you use a different action to launch VLC, like the two options I mentioned above. That might be easier than calculating the size of a folder.

Sorry I didn't see your second comment till now. :man_facepalming:t2:

Of course, I can manually open the file once it's downloaded enough to play. The thing is, if you try to open the file in VLC (as part of the macro) before it's sufficiently downloaded, it fails and returns to the playlist window. That's why I figured pausing until the folder was over a certain size (and then opening via KM) might be one way to ensure it would play properly. I've tried a simple 10 second pause, but this doesn't always work, depending on the download speed, which is determined by the number of peers sharing the file, and their respective connection speeds.

Ok I feel like I'm close, but maybe I've misunderstood how to compare a variable to a number, because it always shows as "currently false", even when the file is much bigger. I've checked that the script is outputting the correct file size. Any suggestions?


I will help you with the folder size calculation approach, even though I think my other approach is simpler and I think we still haven't communicated our intentions correctly regarding it. But now we move on to the folder size approach, which is also valid.

I see you are using AppleScript to solve that. I think I know a much easier way. I'm not going to try to validate your AppleScript. Your calculation looks fine to me, so I'm not going to troubleshoot the AppleScript when I think there's a much easier solution. Let me work on the alternate solution instead. Be back soon.

Here's the magic potion you need:

Mind you, I don't know what the size is - I think it's measured in bytes. I'll leave that to you to figure out.

Thankyou! In my initial post, I did say that VLC works normally if it's not launched from Terminal. Sorry if I waffled so much that it became unclear. I'm a bit hungover today so not firing on all cylinders!

For what it's worth, the script is working fine, as you can see:


I just tested by adding a random video file to the folder (a jazz guitar lesson :nerd_face:) and it's getting the size just fine.

Did you use my action to calculate directory size? I can't tell from your last post.

No, sorry. I think we were typing at the same time!

I've typed out your text into the pause until action:

du -s ~/data | awk ‘{print $1}’

How do I tell it which folder it should be looking at?

The folder it uses in the case above is "~/data". Sorry if that wasn't clear.

For the record:

  1. The du -s command gets the size/name of the folder
  2. The string ~/data is the folder name
  3. The string " | awk '{print $1}' " removes the folder name, leaving just the size.

Ugh so close! It's not working for me. Have you tried it yourself?


You've got a space in your folder name. You probably need double quotes, I'm not sure. Or maybe "\ ". I have to test.

Oh wait, I thought I saw a space. Maybe you edited it? Let me reconsider now.

No you were right. Spotted that just now and edited the screenshot before I saw your reply. Still not working I'm afraid. Did I mention I'm hungover?

Well the first thing you should do is open a terminal window and type the du command in there.

As long as you can tolerate my imperfections, I'll tolerate yours.

My du command gives me this: what does your give?

du -s ~/data
26362000 /Users/myname/data
1 Like