Uses 911K of libraries. Click here for Pure Java version (13709L/74K).
!7 concept Slurpable { S videoID; S label; bool slurped; } cmodule YouTubeSurfer > DynPrintLogAndEnabled { switchable double interval = 10.0; // TODO: test case for persisting concept references // (set dynamicObjectIsLoading in module while destructuring) transient Slurpable lastSlurped; start-thread { dbIndexing(Slurpable, 'videoID, Slurpable, 'slurped); if (noConcepts(Slurpable)) addVideoID("GKvMhYCJA-c"); doEvery(interval, rEnter { if (enabled) slurpOne() }); printStats(); print("Fetch interval: " + interval + " s"); } Slurpable addVideoID(S videoID) { ret uniq Slurpable(+videoID); } Cl<Slurpable> urlsToSlurp() { ret conceptsWhere(Slurpable, slurped := false); } void slurpOne { Slurpable s = random(urlsToSlurp()), ret if null; print(quote(s.label)); new Var<S> html; for (PairS p : videoLinksFromYouTubePage(s.videoID, +html)) cset(addVideoID(p.a), label := p.b); print(quote(htmlExtractTitle(html!))); cset(s, slurped := true); setField(lastSlurped := cloneToUnlisted(s)); printStats(); } void printStats { print(stats()); } S stats() { ret "URLs: " + countConcepts(Slurpable) + ", slurpable: " + l(urlsToSlurp()) + ". Last slurped: " + getString label(lastSlurped); } }
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1028023 |
Snippet name: | YouTube Surfer |
Eternal ID of this version: | #1028023/12 |
Text MD5: | eedf7b712987610ddbc9e227564214d6 |
Transpilation MD5: | 3beee4677673cfd7a4bd79e6df89a49b |
Author: | stefan |
Category: | javax / networking |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-05-04 01:45:25 |
Source code size: | 1352 bytes / 47 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 230 / 11405 |
Version history: | 11 change(s) |
Referenced in: | #1028025 - dm_youTubeSurfer #1028029 - dm_youTubeSurferOpt |