Uses 107K of libraries. Click here for Pure Java version (6476L/47K/153K).
!7 lib 1013692 import org.apache.commons.exec.*; sbool useApacheCommonsExec = true; sS youTubeOptions = "-f 140/171"; // audio only static File outputDir; static StringBuilder output; p { //useApacheCommonsExec = isWindows(); set backtick_verbose; set backtick_keepScript; //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)) consoleTitleIfMain(percent + "% - " + programTitle()); }; // do the job S host = hostNameFromURL(url); S theOptions = cic(host, "youtu") ? youTubeOptions : ""; S cmd = platformQuote(youtubeDL) + " " + theOptions + " -o " + bashQuote(outputTemplate) + " " + platformQuote(url); if (useApacheCommonsExec) { print("Running with Apache: " + cmd); CommandLine cmdLine = CommandLine.parse(cmd); new DefaultExecutor executor; new ByteArrayOutputStream baos; OutputStream stream = teeOutputStream(printOutputStream(), baos); PumpStreamHandler pump = new(stream, stream); executor.setStreamHandler(pump); print("Exit value: " + executor.execute(cmdLine)); output.append(fromUTF8(toByteArray(baos))); } else backtickToConsoleX(cmd, onOutput); // done consoleTitle("DONE - " + programTitle()); }
TODO: spaces in path
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, wtqryiryparv
No comments. add comment