Uses 911K of libraries. Click here for Pure Java version (13709L/74K).
1 | !7 |
2 | |
3 | concept Slurpable {
|
4 | S videoID; |
5 | S label; |
6 | bool slurped; |
7 | } |
8 | |
9 | cmodule YouTubeSurfer > DynPrintLogAndEnabled {
|
10 | switchable double interval = 10.0; |
11 | // TODO: test case for persisting concept references |
12 | // (set dynamicObjectIsLoading in module while destructuring) |
13 | transient Slurpable lastSlurped; |
14 | |
15 | start-thread {
|
16 | dbIndexing(Slurpable, 'videoID, Slurpable, 'slurped); |
17 | if (noConcepts(Slurpable)) addVideoID("GKvMhYCJA-c");
|
18 | doEvery(interval, rEnter { if (enabled) slurpOne() });
|
19 | printStats(); |
20 | print("Fetch interval: " + interval + " s");
|
21 | } |
22 | |
23 | Slurpable addVideoID(S videoID) {
|
24 | ret uniq Slurpable(+videoID); |
25 | } |
26 | |
27 | Cl<Slurpable> urlsToSlurp() {
|
28 | ret conceptsWhere(Slurpable, slurped := false); |
29 | } |
30 | |
31 | void slurpOne {
|
32 | Slurpable s = random(urlsToSlurp()), ret if null; |
33 | print(quote(s.label)); |
34 | new Var<S> html; |
35 | for (PairS p : videoLinksFromYouTubePage(s.videoID, +html)) |
36 | cset(addVideoID(p.a), label := p.b); |
37 | print(quote(htmlExtractTitle(html!))); |
38 | cset(s, slurped := true); |
39 | setField(lastSlurped := cloneToUnlisted(s)); |
40 | printStats(); |
41 | } |
42 | |
43 | void printStats { print(stats()); }
|
44 | S stats() {
|
45 | ret "URLs: " + countConcepts(Slurpable) + ", slurpable: " + l(urlsToSlurp()) + ". Last slurped: " + getString label(lastSlurped); |
46 | } |
47 | } |
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: | 477 / 11688 |
| Version history: | 11 change(s) |
| Referenced in: | [show references] |