1 | sclass YTChatMessage { |
2 | S text, publishedAt, authorChannelId, authorDisplayName; |
3 | } |
4 | |
5 | sclass YTChatMessages { |
6 | S nextPageToken; |
7 | int pollingIntervalMillis; |
8 | L<YTChatMessage> messages; |
9 | } |
10 | |
11 | static YTChatMessages youTubeGetChatMessages(S liveStreamID) { |
12 | ret youTubeGetChatMessages(liveStreamID, null); |
13 | } |
14 | |
15 | static YTChatMessages youTubeGetChatMessages(S liveStreamID, S pageToken) { |
16 | S page = loadPageWithParamsSilently("https://www.googleapis.com/youtube/v3/liveChat/messages", |
17 | liveChatId := liveStreamID, |
18 | part := "id,snippet,authorDetails", |
19 | +pageToken, |
20 | key := youTubeDataAPIKey()); |
21 | Map map = jsonDecodeMap(page); |
22 | //printStruct(map); |
23 | L<Map> items = cast map.get('items); |
24 | ret nu(YTChatMessages, |
25 | nextPageToken := getString(map, 'nextPageToken), |
26 | pollingIntervalMillis := getInt(map, 'pollingIntervalMillis), |
27 | messages := map(items, func(Map item) -> YTChatMessage { |
28 | Map snippet = (Map) item.get('snippet); |
29 | Map textMessageDetails = (Map) _get(snippet, 'textMessageDetails); |
30 | Map authorDetails = (Map) _get(item, 'authorDetails); |
31 | ret nu(YTChatMessage, |
32 | text := getString(textMessageDetails, 'messageText), |
33 | publishedAt := getString(snippet, 'publishedAt), |
34 | authorChannelId := getString(snippet, 'authorChannelId), |
35 | authorDisplayName := getString(authorDetails, 'displayName)); |
36 | })); |
37 | } |
Began life as a copy of #1009898
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1020354 |
Snippet name: | youTubeGetChatMessages [dev.] |
Eternal ID of this version: | #1020354/15 |
Text MD5: | d742bc1985dea079147e8f55f21bd159 |
Author: | stefan |
Category: | javax / networking |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-12-16 18:29:55 |
Source code size: | 1404 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 338 / 420 |
Version history: | 14 change(s) |
Referenced in: | [show references] |