How to Troubleshoot a Script That Is Stalling

Hi, I'm using youtube-dl to download a list of videos via KM script and about every 10 videos or so it will just stall. Often when I restart the script on the same video it will work and move on. I haven't been able to replicate the issue in the terminal, but I know it's stalling on the script action. Unfortunately when it stalls there doesn't seem to be a way for me to preserve a log, so I'm stuck with no clues as to why it's stalling. Any advice?

can you share your script to see your process.

I use this:
image

there's a --verbose setting, and a sleep one as well

2 Likes

Sure thing, take a look:

Doing more testing, I'm noticing that if I run the macro on each link individually it doesn't stall, whereas if it's repeating for a list it will stall. I wondered if it was tripping over itself somehow so I added a 5 second pause and still got the same result.

A simple workaround that's working alright for me is to just set an action timeout for about 45 seconds on the script. If it times out I have it go again and that virtually always works. It seems ytdl is smart about continuing where it left off when it sees the partial download.

That said, I really would like to know if it's at all possible for KM to capture live command line results BEFORE the script completes. It would be incredibly helpful to access the live percentage on the download for example.

If you change the "Save results to Variable" to Display Results in a Window, you can get more information while it is progressing

Hey @hayleyh,

I've used youtube-dl and other tools extensively to download things.

You're better off to script the Terminal.app for batch jobs.

You get better feedback and a more robust system.

-Chris

That hasn't been my experience, the window won't show up until the download completes.

Hm, I'll think on that. It's a very specific macro for downloading, organizing, and logging videos. I'm not sure I could get it precise enough without processing each video one by one -- or rather I'm not sure I'm advanced enough to build something like that.

Not possible.

Keyboard Maestro is a command-runner – not a terminal – so it is unable to post β€œlive” results.

youtube-dl has a verbose mode, so you might be able to get more information about the failure.

You can also write to a file from within a script, so you can emplace your own error messages.

But – troubleshooting something like this is often anything but easy.

-Chris

1 Like