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

26
LINES

< > BotCompany Repo | #1017636 // downloadYouTubeComments - needs Python 2

JavaX fragment (include)

static L<Map> downloadYouTubeComments(S youTubeURL) {
  S youTubeID = extractYoutubeID(youTubeURL);
  File script = javaxCachesDir("YouTube Comments/downloader.py");
  File out = javaxCachesDir("YouTube Comments/" + youTubeID);
  if (!script.exists())
    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 " + youTubeID + " --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;
  }
  
  L<Map> result = map jsonDecode(linesFromFile(out));
  saveTextFile(youTubeCommentsCacheFile(youTubeID), structureLines(result));
  ret result;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017636
Snippet name: downloadYouTubeComments - needs Python 2
Eternal ID of this version: #1017636/1
Text MD5: 624851f39551fee43e215937a571c0b9
Author: stefan
Category: javax / networking
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-31 13:22:07
Source code size: 1124 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 293 / 323
Referenced in: [show references]