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

26
LINES

< > BotCompany Repo | #1013724 // Test YouTube comment downloader (needs Python 2)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (6368L/43K).

1  
!7
2  
3  
sS youtubeURL = "https://www.youtube.com/watch?v=6vqLqoy6EO4";
4  
5  
p {
6  
  File script = programFile("downloader.py");
7  
  File out = programFile("comments.txt");
8  
  saveTextFile(script, unixLineBreaks(loadSnippet(#1013723)));
9  
  makeExecutable(script);
10  
  S cmd = (isWindows() ? "c:\\python27\\python " : "") + platformQuote(script);
11  
  
12  
  for (int retry = 0; ; retry++) {
13  
    if (retry >= 3) fail("Couldn't install modules");
14  
    
15  
    S stdout = loadTextFile(backtickToConsole(cmd + " --youtubeid " + extractYoutubeID(youtubeURL) + " --output " + platformQuote(out)));
16  
    S missingModule = regexpFirstGroupOneOf(
17  
      ll("ImportError: No module named ([a-z0-9]+)",
18  
        "ImportError: ([a-z0-9]+) does not seem to be installed"), stdout);
19  
    if (missingModule != null)
20  
      backtickToConsole("c:\\python27\\scripts\\pip install " + missingModule);
21  
    else
22  
      break;
23  
  }
24  
  
25  
  pnlStruct(map jsonDecode(linesFromFile(out)));
26  
}

Author comment

Should work out of the box on Windows if Python 2.7 is in c:\python27.

For Linux: Get Python and say: sudo -H pip2 install requests lxml cssselect

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1013724
Snippet name: Test YouTube comment downloader (needs Python 2)
Eternal ID of this version: #1013724/15
Text MD5: 9724aa218a328f1bc5d033d6fddfc400
Transpilation MD5: 88bf8113c3bc55e60c897691b84d477a
Author: stefan
Category: javax / networking
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-01-28 15:43:04
Source code size: 953 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 361 / 670
Version history: 14 change(s)
Referenced in: [show references]