Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

60
LINES

< > BotCompany Repo | #1016304 // YouTube Video Downloader [Dyn Module, OK]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 1113K of libraries. Click here for Pure Java version (9166L/48K).

!7

cm YouTubeDownloader {
  transient JTextArea ta;
  transient JTextField tfURL, tfDest;
  transient JButton btnGo;
  transient File lastFileMade;
  
  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));
      S output = downloadImpl(url, dir);
      File f = youtubeDLExtractDestination(output);
      if (f != null)
        print("\nMade: " + fileInfo(lastFileMade = f));
      else
        print("\nHmm. Did something go wrong?");
    }
  }
  
  S downloadImpl(S url, File dir) {
    ret youtubeDownloadVideo(url, dir);
  }
  
  // API
  
  File downloadAndReturnFile(S url, File dir) enter {
    ret youtubeDLExtractDestination(downloadImpl(url, dir));
  }
}

Author comment

Began life as a copy of #1016189

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1016304
Snippet name: YouTube Video Downloader [Dyn Module, OK]
Eternal ID of this version: #1016304/21
Text MD5: 05c8b3f6c82ededaf7d8db79b7b4e747
Transpilation MD5: 297f97dee00760a88f4e742e70344dd0
Author: stefan
Category: javax / gui
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-18 03:25:15
Source code size: 1621 bytes / 60 lines
Pitched / IR pitched: No / No
Views / Downloads: 623 / 5984
Version history: 20 change(s)
Referenced in: [show references]