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

15
LINES

< > BotCompany Repo | #1028022 // videoLinksFromYouTubePage

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4202L/28K).

// page contents is cached using webScrape
// returns pairs (video id, title plus stats)
static LPairS videoLinksFromYouTubePage(S url, O... _) {
  S html = emitIntermediate html(_, webScrape(youtubeURL(url)));
  LS l = regexpExtractAll([[\\"(label|videoId)\\":\\"(.*?)\\"]], html);
  //print(+l);
  S videoId = null;
  new LPairS out;
  for (S s : l) {
    PairS p = listToPair(unquoteAll(splitAtColon(unquoteRaw(s)))), continue if null;
    if (eq(p.a, "videoId")) videoId = p.b;
    else out.add(pair(videoId, p.b));
  }
  ret out;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028022
Snippet name: videoLinksFromYouTubePage
Eternal ID of this version: #1028022/13
Text MD5: cdae98e4b7906d29817cf76517120e8e
Transpilation MD5: 848679a4e4a1731949f8ae5dd5b1b8bc
Author: stefan
Category: javax / networking
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-04 01:17:22
Source code size: 550 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 133 / 237
Version history: 12 change(s)
Referenced in: [show references]