!7 sclass YouTubeDownloader extends DynModule { transient JTextArea ta; transient JTextField tfURL, tfDest; transient JButton btnGo; start { doEvery(1000, r updateMe); } visualize { tfURL = jtextfield("https://www.youtube.com/watch?v=YYOKMUTTDdA"); // Full paste componentPopupMenu_clear(tfURL); componentPopupMenuItem(tfURL, "Paste", r { tfURL.selectAll(); tfURL.paste() }); tfDest = jtextfield(desktopDir()); onEnter(tfURL, r go); ret northAndCenterWithMargins( vstackWithSpacing( centerAndEast(withLabel("Video URL to download:", tfURL), withLeftMargin(btnGo = jbutton("Download", r go))), withLabel("Destination directory:", tfDest)), ta = typeWriterTextArea()); } void unvisualize() { ta = null; } void update { if (ta != null) setText(ta, localPrintLog()); } void go { thread "YouTube Download" { temp tempDisableButton(btnGo); installOrUpdateYouTubeDL(); S url = formatYouTubeURL_long(gtt(tfURL)); File dir = newFile(gtt(tfDest)); downloadImpl(url, dir); print("Done (possibly)"); } } S downloadImpl() { ret youtubeDownloadVideo(url, dir); } }