1 | sclass MediumPost { |
2 | S title, url, postID; |
3 | long updatedAt; |
4 | |
5 | *() {} |
6 | *(S *title, S *url) {} |
7 | *(S *title, S *url, S *postID) {} |
8 | *(S *title, S *url, S *postID, long *updatedAt) {} |
9 | } |
10 | |
11 | static L<MediumPost> getMediumPosts() { |
12 | ret getMediumPosts("stefanreich"); |
13 | } |
14 | |
15 | static L<MediumPost> getMediumPosts(S username) { |
16 | Map<S, O> data = loadMediumJSON(username); |
17 | |
18 | new L<MediumPost> lPosts; |
19 | |
20 | Map references = (Map) data.get("references"); |
21 | Map<S, Map> posts = (Map) references.get("Post"); |
22 | for (S postID : keys(posts)) { |
23 | Map post = posts.get(postID); |
24 | S uniqueSlug = getString(post, "uniqueSlug"); |
25 | S link = "https://medium.com/@" + username + "/" + uniqueSlug; |
26 | S title = or2(getString(post, "title"), "?"); |
27 | long updatedAt = (long) post.get("updatedAt"); |
28 | lPosts.add(new MediumPost(title, link, postID, updatedAt)); |
29 | //psl(post); |
30 | } |
31 | ret reversedList(sortedByField(lPosts, "updatedAt")); |
32 | } |
Began life as a copy of #1004101
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004104 |
Snippet name: | getMediumPosts - get someone's last posts at medium.com |
Eternal ID of this version: | #1004104/1 |
Text MD5: | 634748b2cddb2a307d81901b7ada9778 |
Author: | stefan |
Category: | javax / networking |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-12-28 17:51:58 |
Source code size: | 961 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 553 / 517 |
Referenced in: | [show references] |