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).

1  
!7
2  
3  
cm YouTubeDownloader {
4  
  transient JTextArea ta;
5  
  transient JTextField tfURL, tfDest;
6  
  transient JButton btnGo;
7  
  transient File lastFileMade;
8  
  
9  
  start {
10  
    doEvery(1000, r updateMe);
11  
  }
12  
  
13  
  visualize {
14  
    tfURL = jtextfield("https://www.youtube.com/watch?v=YYOKMUTTDdA");
15  
    
16  
    // Full paste
17  
    componentPopupMenu_clear(tfURL);
18  
    componentPopupMenuItem(tfURL, "Paste", r { tfURL.selectAll(); tfURL.paste() });
19  
    
20  
    tfDest = jtextfield(desktopDir());
21  
    onEnter(tfURL, r go);
22  
    ret northAndCenterWithMargins(
23  
      vstackWithSpacing(
24  
        centerAndEast(withLabel("Video URL to download:", tfURL), 
25  
          withLeftMargin(btnGo = jbutton("Download", r go))),
26  
        withLabel("Destination directory:", tfDest)),
27  
      ta = typeWriterTextArea());
28  
  }
29  
  
30  
  void unvisualize() { ta = null; }
31  
  
32  
  void update {
33  
    if (ta != null) setText(ta, localPrintLog());
34  
  }
35  
  
36  
  void go {
37  
    thread "YouTube Download" {
38  
      temp tempDisableButton(btnGo);
39  
      installOrUpdateYouTubeDL();
40  
      S url = /*formatYouTubeURL_long*/(gtt(tfURL));
41  
      File dir = newFile(gtt(tfDest));
42  
      S output = downloadImpl(url, dir);
43  
      File f = youtubeDLExtractDestination(output);
44  
      if (f != null)
45  
        print("\nMade: " + fileInfo(lastFileMade = f));
46  
      else
47  
        print("\nHmm. Did something go wrong?");
48  
    }
49  
  }
50  
  
51  
  S downloadImpl(S url, File dir) {
52  
    ret youtubeDownloadVideo(url, dir);
53  
  }
54  
  
55  
  // API
56  
  
57  
  File downloadAndReturnFile(S url, File dir) enter {
58  
    ret youtubeDLExtractDestination(downloadImpl(url, dir));
59  
  }
60  
}

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: 625 / 5986
Version history: 20 change(s)
Referenced in: [show references]