!7 sS options = "-f 140/171"; // audio only static File outputDir; static StringBuilder output; p { print("args: " + struct(args)); S url = or2(first(args), "https://www.youtube.com/watch?v=99Q31nyH16w"); // get youtube-dl File youtubeDL = installYouTubeDL(); S outputTemplate = f2s(new File(or(outputDir, programDir()), "%(title)s-%(id)s.%(ext)s")); output = new StringBuilder; // update console title with percentages final new LastLineBuffer buf; O onOutput = voidfunc(S s) { S fixed = fixNewLines(s); buf.append(fixed); output.append(fixed); S percent = regexpFirstGroup("([0-9.]+)%", buf.lastCompleteLine()); if (nempty(percent)) consoleTitle(percent + "% - " + programTitle()); }; // do the job backtickToConsoleX(platformQuote(youtubeDL) + " " + options + " -o " + bashQuote(outputTemplate) + " " + platformQuote(url), onOutput); // done consoleTitle("DONE - " + programTitle()); }