Play Magnet Link in VLC via Peerflix

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?

Screenshot

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:

Pasted_Image_10_03_2022__20_35

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?

image

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

image

Okay, I'm pretty sure the awk command strips out the name. So maybe it's your action that isn't working. Le the scroll back and look at it.

AHA! I think I see it.... I think your problem is that you have smart quotes turned on. Basically, never have that feature enabled if you use KM. Turn it off and re-enter the action manually.

I looked very closely at your action and I spotted the erroneous quote which caused your problem:

Genius!!!!! Can't believe you spotted that!!

Ok so I don't think we can use '50' any more, as the number isn't given in MB. If you look at my screenshot above, the number is 570320 (no idea what it means!). The file itself is 291.992741MB.

So if I divide the first by the second, I get 1953.19924066. So maybe I'll tell it to wait for 2000...?

...

Ok that didn't work. It opened for a split second and then closed again. I'll try a few values...

...

20000 seems to do it! Yay!! Thanks so much for your help. I'll edit my initial post with the latest version.

Thanks for the compliment. I can say for sure I'm not a genius, as I was tested once and fell well short of the arbitrary number. Although I was taking a test for adults when I was 17 and the test warned that it is not valid for under 18s.

As for the meaning of that number, I left that as your homework. You can read the man page for du. It might be clusters or kilobytes or bytes or something else.

As Sherlock Holmes said, once you eliminate the possible, then the other choice, no matter how unlikely, is the culprit. Once we eliminated the du command as the culprit, I stared at the other action and examined it byte by byte, thinking at every character. Then I spotted it, and I remembered this problem from before.

In my strong opinion, KM should come with a warning when you start the KM Editor that the Smart Quotes should be disabled before you proceed. This is to protect everyone who is not a genius with KM.

1 Like