Transpiled version (11889L) is out of date.
sclass DownloadVideo { S url; File dir = downloadedVideoDir(); new LS options; S extension = ".mp4"; S formatString = dropDotPrefix(extension); //"best[ext=mp4]"; // This might work? // problem with this is we don't know the output format //"bestvideo[height<=720]+bestaudio/best[height<=720]"; int maxFileSizeInMB = 100; S cmd; *(WithURL<?> url) { this(url?.url()); } *(S *url) { options.add("-U --no-playlist --no-mtime --write-description --write-info-json"); options.add("--write-annotations --write-thumbnail --print-json --restrict-filenames"; //options.add("--format " + dropDotPrefix(extension)); // demand our format options.add("-f " + pqO(formatString)); } DownloadedMedia get() { if (empty(url)) null; installFFMPEGIfMissing(); options.add("--max-filesize " + maxFileSizeInMB + "m"); S fn = md5FileName(url); File infoFile = newFile(dir, fn + ".info"); S json = loadTextFile(infoFile); if (isPossibleJSONMap(json)) { DownloadedMedia dm = new(null, json, extension); if (fileExists(dm!)) ret dm; } saveTextFile(newFile(dir, fn + ".url"), url); cmd = pqO(installYouTubeDL()) + " " + joinWithSpace(options) + " -o " + pqO(newFile(dir, youTubeDLDefaultFileNameTemplate())) + " " + safePlatformQuote(url); saveTextFile(newFile(dir, fn + ".cmd"), cmd); S output = backtick_verbose(cmd); saveTextFile(infoFile, output); ret new DownloadedMedia(cmd, output, extension); } }
Began life as a copy of #1032316
download show line numbers debug dex old transpilations
Travelled to 5 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1032339 |
Snippet name: | DownloadVideo |
Eternal ID of this version: | #1032339/10 |
Text MD5: | 459f50b2bd07506175191a1e753c63f5 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-09-02 03:01:04 |
Source code size: | 1614 bytes / 52 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 164 / 312 |
Version history: | 9 change(s) |
Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |