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

!7

sS youtubeURL = "https://www.youtube.com/watch?v=6vqLqoy6EO4";

p {
  File script = programFile("downloader.py");
  File out = programFile("comments.txt");
  saveTextFile(script, unixLineBreaks(loadSnippet(#1013723)));
  makeExecutable(script);
  S cmd = (isWindows() ? "c:\\python27\\python " : "") + platformQuote(script);
  
  for (int retry = 0; ; retry++) {
    if (retry >= 3) fail("Couldn't install modules");
    
    S stdout = loadTextFile(backtickToConsole(cmd + " --youtubeid " + extractYoutubeID(youtubeURL) + " --output " + platformQuote(out)));
    S missingModule = regexpFirstGroupOneOf(
      ll("ImportError: No module named ([a-z0-9]+)",
        "ImportError: ([a-z0-9]+) does not seem to be installed"), stdout);
    if (missingModule != null)
      backtickToConsole("c:\\python27\\scripts\\pip install " + missingModule);
    else
      break;
  }
  
  pnlStruct(map jsonDecode(linesFromFile(out)));
}

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: 345 / 650
Version history: 14 change(s)
Referenced in: [show references]