@the-convocation/twitter-scraper 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/api.d.ts +2 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +39 -43
- package/dist/api.js.map +1 -1
- package/dist/auth-user.d.ts +14 -0
- package/dist/auth-user.d.ts.map +1 -0
- package/dist/auth-user.js +204 -0
- package/dist/auth-user.js.map +1 -0
- package/dist/auth.d.ts +45 -28
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +62 -81
- package/dist/auth.js.map +1 -1
- package/dist/errors.d.ts +5 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +11 -0
- package/dist/errors.js.map +1 -0
- package/dist/profile.d.ts +3 -3
- package/dist/profile.d.ts.map +1 -1
- package/dist/profile.js +56 -67
- package/dist/profile.js.map +1 -1
- package/dist/requests.d.ts +9 -0
- package/dist/requests.d.ts.map +1 -0
- package/dist/requests.js +26 -0
- package/dist/requests.js.map +1 -0
- package/dist/scraper.d.ts +50 -4
- package/dist/scraper.d.ts.map +1 -1
- package/dist/scraper.js +88 -27
- package/dist/scraper.js.map +1 -1
- package/dist/search.d.ts +5 -5
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +46 -58
- package/dist/search.js.map +1 -1
- package/dist/timeline-async.d.ts.map +1 -1
- package/dist/timeline-async.js +34 -56
- package/dist/timeline-async.js.map +1 -1
- package/dist/timeline.d.ts +19 -1
- package/dist/timeline.d.ts.map +1 -1
- package/dist/timeline.js +157 -116
- package/dist/timeline.js.map +1 -1
- package/dist/trends.d.ts +2 -2
- package/dist/trends.d.ts.map +1 -1
- package/dist/trends.js +31 -42
- package/dist/trends.js.map +1 -1
- package/dist/tweets.d.ts +19 -5
- package/dist/tweets.d.ts.map +1 -1
- package/dist/tweets.js +54 -46
- package/dist/tweets.js.map +1 -1
- package/package.json +21 -13
package/dist/timeline.js
CHANGED
|
@@ -5,183 +5,225 @@ const profile_1 = require("./profile");
|
|
|
5
5
|
const reHashtag = /\B(\#\S+\b)/g;
|
|
6
6
|
const reTwitterUrl = /https:(\/\/t\.co\/([A-Za-z0-9]|[A-Za-z]){10})/g;
|
|
7
7
|
const reUsername = /\B(\@\S{1,15}\b)/g;
|
|
8
|
+
function isFieldDefined(key) {
|
|
9
|
+
return function (value) {
|
|
10
|
+
return isDefined(value[key]);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function isDefined(value) {
|
|
14
|
+
return value != null;
|
|
15
|
+
}
|
|
8
16
|
function parseTweet(timeline, id) {
|
|
9
|
-
|
|
10
|
-
const tweets = (_b = (_a = timeline.globalObjects) === null || _a === void 0 ? void 0 : _a.tweets) !== null && _b !== void 0 ? _b : {};
|
|
17
|
+
const tweets = timeline.globalObjects?.tweets ?? {};
|
|
11
18
|
const tweet = tweets[id];
|
|
12
|
-
if (tweet
|
|
13
|
-
return
|
|
19
|
+
if (tweet?.user_id_str == null) {
|
|
20
|
+
return {
|
|
21
|
+
success: false,
|
|
22
|
+
err: new Error(`Tweet "${id}" was not found in the timeline object.`),
|
|
23
|
+
};
|
|
14
24
|
}
|
|
15
|
-
const users =
|
|
25
|
+
const users = timeline.globalObjects?.users ?? {};
|
|
16
26
|
const user = users[tweet.user_id_str];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
if (user?.screen_name == null) {
|
|
28
|
+
return {
|
|
29
|
+
success: false,
|
|
30
|
+
err: new Error(`User "${tweet.user_id_str}" has no username data.`),
|
|
31
|
+
};
|
|
21
32
|
}
|
|
33
|
+
const hashtags = tweet.entities?.hashtags ?? [];
|
|
34
|
+
const mentions = tweet.entities?.user_mentions ?? [];
|
|
35
|
+
const media = tweet.extended_entities?.media ?? [];
|
|
36
|
+
const pinnedTweets = new Set(user.pinned_tweet_ids_str ?? []);
|
|
37
|
+
const urls = tweet.entities?.urls ?? [];
|
|
38
|
+
const { photos, videos, sensitiveContent } = parseMediaGroups(media);
|
|
22
39
|
const tw = {
|
|
23
40
|
id,
|
|
24
|
-
hashtags:
|
|
41
|
+
hashtags: hashtags
|
|
42
|
+
.filter(isFieldDefined('text'))
|
|
43
|
+
.map((hashtag) => hashtag.text),
|
|
25
44
|
likes: tweet.favorite_count,
|
|
26
|
-
|
|
27
|
-
|
|
45
|
+
mentions: mentions.filter(isFieldDefined('id_str')).map((mention) => ({
|
|
46
|
+
id: mention.id_str,
|
|
47
|
+
username: mention.screen_name,
|
|
48
|
+
name: mention.name,
|
|
49
|
+
})),
|
|
50
|
+
name: user.name,
|
|
51
|
+
permanentUrl: `https://twitter.com/${user.screen_name}/status/${id}`,
|
|
52
|
+
photos,
|
|
28
53
|
replies: tweet.reply_count,
|
|
29
54
|
retweets: tweet.retweet_count,
|
|
30
55
|
text: tweet.full_text,
|
|
31
|
-
urls:
|
|
56
|
+
urls: urls
|
|
57
|
+
.filter(isFieldDefined('expanded_url'))
|
|
58
|
+
.map((url) => url.expanded_url),
|
|
32
59
|
userId: tweet.user_id_str,
|
|
33
|
-
username,
|
|
34
|
-
videos
|
|
60
|
+
username: user.screen_name,
|
|
61
|
+
videos,
|
|
35
62
|
};
|
|
36
63
|
if (tweet.created_at != null) {
|
|
37
64
|
tw.timeParsed = new Date(Date.parse(tweet.created_at));
|
|
38
65
|
tw.timestamp = Math.floor(tw.timeParsed.valueOf() / 1000);
|
|
39
66
|
}
|
|
40
|
-
if (
|
|
67
|
+
if (tweet.place?.id != null) {
|
|
41
68
|
tw.place = tweet.place;
|
|
42
69
|
}
|
|
43
70
|
if (tweet.quoted_status_id_str != null) {
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
71
|
+
const quotedStatusResult = parseTweet(timeline, tweet.quoted_status_id_str);
|
|
72
|
+
if (quotedStatusResult.success) {
|
|
46
73
|
tw.isQuoted = true;
|
|
47
|
-
tw.quotedStatus =
|
|
74
|
+
tw.quotedStatus = quotedStatusResult.tweet;
|
|
48
75
|
}
|
|
49
76
|
}
|
|
50
77
|
if (tweet.in_reply_to_status_id_str != null) {
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
78
|
+
const replyStatusResult = parseTweet(timeline, tweet.in_reply_to_status_id_str);
|
|
79
|
+
if (replyStatusResult.success) {
|
|
53
80
|
tw.isReply = true;
|
|
54
|
-
tw.inReplyToStatus =
|
|
81
|
+
tw.inReplyToStatus = replyStatusResult.tweet;
|
|
55
82
|
}
|
|
56
83
|
}
|
|
57
84
|
if (tweet.retweeted_status_id_str != null) {
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
85
|
+
const retweetedStatusResult = parseTweet(timeline, tweet.retweeted_status_id_str);
|
|
86
|
+
if (retweetedStatusResult.success) {
|
|
60
87
|
tw.isRetweet = true;
|
|
61
|
-
tw.retweetedStatus =
|
|
88
|
+
tw.retweetedStatus = retweetedStatusResult.tweet;
|
|
62
89
|
}
|
|
63
90
|
}
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
91
|
+
const views = parseInt(tweet.ext_views?.count ?? '');
|
|
92
|
+
if (!isNaN(views)) {
|
|
93
|
+
tw.views = views;
|
|
94
|
+
}
|
|
95
|
+
if (pinnedTweets.has(tweet.conversation_id_str)) {
|
|
96
|
+
// TODO: Update tests so this can be assigned at the tweet declaration
|
|
97
|
+
tw.isPin = true;
|
|
70
98
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
99
|
+
if (sensitiveContent) {
|
|
100
|
+
// TODO: Update tests so this can be assigned at the tweet declaration
|
|
101
|
+
tw.sensitiveContent = true;
|
|
102
|
+
}
|
|
103
|
+
// HTML parsing with regex :)
|
|
104
|
+
let html = tweet.full_text ?? '';
|
|
105
|
+
const foundedMedia = [];
|
|
106
|
+
html = html.replace(reHashtag, linkHashtagHtml);
|
|
107
|
+
html = html.replace(reUsername, linkUsernameHtml);
|
|
108
|
+
html = html.replace(reTwitterUrl, unwrapTcoUrlHtml(tweet, foundedMedia));
|
|
109
|
+
for (const { url } of tw.photos) {
|
|
110
|
+
if (foundedMedia.indexOf(url) !== -1) {
|
|
111
|
+
continue;
|
|
75
112
|
}
|
|
113
|
+
html += `<br><img src="${url}"/>`;
|
|
76
114
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (m.media_url_https == null) {
|
|
115
|
+
for (const { preview: url } of tw.videos) {
|
|
116
|
+
if (foundedMedia.indexOf(url) !== -1) {
|
|
80
117
|
continue;
|
|
81
118
|
}
|
|
119
|
+
html += `<br><img src="${url}"/>`;
|
|
120
|
+
}
|
|
121
|
+
html = html.replace(/\n/g, '<br>');
|
|
122
|
+
tw.html = html;
|
|
123
|
+
return { success: true, tweet: tw };
|
|
124
|
+
}
|
|
125
|
+
exports.parseTweet = parseTweet;
|
|
126
|
+
function parseMediaGroups(media) {
|
|
127
|
+
const photos = [];
|
|
128
|
+
const videos = [];
|
|
129
|
+
let sensitiveContent = undefined;
|
|
130
|
+
for (const m of media
|
|
131
|
+
.filter(isFieldDefined('id_str'))
|
|
132
|
+
.filter(isFieldDefined('media_url_https'))) {
|
|
82
133
|
if (m.type === 'photo') {
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
else if (m.type === 'video' && m.id_str != null) {
|
|
86
|
-
const video = {
|
|
134
|
+
photos.push({
|
|
87
135
|
id: m.id_str,
|
|
88
|
-
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const bitrate = variant.bitrate;
|
|
94
|
-
if (bitrate != null && bitrate > maxBitrate && variant.url != null) {
|
|
95
|
-
let variantUrl = variant.url;
|
|
96
|
-
const stringStart = 0;
|
|
97
|
-
const tagSuffixIdx = variantUrl.indexOf('?tag=10');
|
|
98
|
-
if (tagSuffixIdx !== -1) {
|
|
99
|
-
variantUrl = variantUrl.substring(stringStart, tagSuffixIdx + 1);
|
|
100
|
-
}
|
|
101
|
-
video.url = variantUrl;
|
|
102
|
-
maxBitrate = bitrate;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
tw.photos.push(video.preview);
|
|
106
|
-
tw.videos.push(video);
|
|
136
|
+
url: m.media_url_https,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
else if (m.type === 'video') {
|
|
140
|
+
videos.push(parseVideo(m));
|
|
107
141
|
}
|
|
108
142
|
const sensitive = m.ext_sensitive_media_warning;
|
|
109
143
|
if (sensitive != null) {
|
|
110
|
-
|
|
144
|
+
sensitiveContent =
|
|
111
145
|
sensitive.adult_content ||
|
|
112
146
|
sensitive.graphic_violence ||
|
|
113
147
|
sensitive.other;
|
|
114
148
|
}
|
|
115
149
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
150
|
+
return { sensitiveContent, photos, videos };
|
|
151
|
+
}
|
|
152
|
+
function parseVideo(m) {
|
|
153
|
+
const video = {
|
|
154
|
+
id: m.id_str,
|
|
155
|
+
preview: m.media_url_https,
|
|
156
|
+
};
|
|
157
|
+
let maxBitrate = 0;
|
|
158
|
+
const variants = m.video_info?.variants ?? [];
|
|
159
|
+
for (const variant of variants) {
|
|
160
|
+
const bitrate = variant.bitrate;
|
|
161
|
+
if (bitrate != null && bitrate > maxBitrate && variant.url != null) {
|
|
162
|
+
let variantUrl = variant.url;
|
|
163
|
+
const stringStart = 0;
|
|
164
|
+
const tagSuffixIdx = variantUrl.indexOf('?tag=10');
|
|
165
|
+
if (tagSuffixIdx !== -1) {
|
|
166
|
+
variantUrl = variantUrl.substring(stringStart, tagSuffixIdx + 1);
|
|
167
|
+
}
|
|
168
|
+
video.url = variantUrl;
|
|
169
|
+
maxBitrate = bitrate;
|
|
120
170
|
}
|
|
121
171
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
for (const entity of (_b = (_a = tweet.entities) === null || _a === void 0 ? void 0 : _a.urls) !== null && _b !== void 0 ? _b : []) {
|
|
172
|
+
return video;
|
|
173
|
+
}
|
|
174
|
+
function linkHashtagHtml(hashtag) {
|
|
175
|
+
return `<a href="https://twitter.com/hashtag/${hashtag.replace('#', '')}">${hashtag}</a>`;
|
|
176
|
+
}
|
|
177
|
+
function linkUsernameHtml(username) {
|
|
178
|
+
return `<a href="https://twitter.com/${username[0].replace('@', '')}">${username[0]}</a>`;
|
|
179
|
+
}
|
|
180
|
+
function unwrapTcoUrlHtml(tweet, foundedMedia) {
|
|
181
|
+
return function (tco) {
|
|
182
|
+
for (const entity of tweet.entities?.urls ?? []) {
|
|
134
183
|
if (tco === entity.url && entity.expanded_url != null) {
|
|
135
184
|
return `<a href="${entity.expanded_url}">${tco}</a>`;
|
|
136
185
|
}
|
|
137
186
|
}
|
|
138
|
-
for (const entity of
|
|
187
|
+
for (const entity of tweet.extended_entities?.media ?? []) {
|
|
139
188
|
if (tco === entity.url && entity.media_url_https != null) {
|
|
140
189
|
foundedMedia.push(entity.media_url_https);
|
|
141
190
|
return `<br><a href="${tco}"><img src="${entity.media_url_https}"/></a>`;
|
|
142
191
|
}
|
|
143
192
|
}
|
|
144
193
|
return tco;
|
|
145
|
-
}
|
|
146
|
-
for (const url of tw.photos) {
|
|
147
|
-
if (foundedMedia.indexOf(url) !== -1) {
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
html += `<br><img src="${url}"/>`;
|
|
151
|
-
}
|
|
152
|
-
html = html.replace(/\n/g, '<br>');
|
|
153
|
-
tw.html = html;
|
|
154
|
-
return tw;
|
|
194
|
+
};
|
|
155
195
|
}
|
|
156
|
-
exports.parseTweet = parseTweet;
|
|
157
196
|
function parseTweets(timeline) {
|
|
158
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
159
197
|
let cursor;
|
|
160
198
|
let pinnedTweet;
|
|
161
199
|
let orderedTweets = [];
|
|
162
|
-
for (const instruction of
|
|
163
|
-
const
|
|
200
|
+
for (const instruction of timeline.timeline?.instructions ?? []) {
|
|
201
|
+
const { pinEntry, addEntries, replaceEntry } = instruction;
|
|
202
|
+
// Handle pin instruction
|
|
203
|
+
const pinnedTweetId = pinEntry?.entry?.content?.item?.content?.tweet?.id;
|
|
164
204
|
if (pinnedTweetId != null) {
|
|
165
|
-
const
|
|
166
|
-
if (
|
|
167
|
-
pinnedTweet = tweet;
|
|
205
|
+
const tweetResult = parseTweet(timeline, pinnedTweetId);
|
|
206
|
+
if (tweetResult.success) {
|
|
207
|
+
pinnedTweet = tweetResult.tweet;
|
|
168
208
|
}
|
|
169
209
|
}
|
|
170
|
-
|
|
171
|
-
|
|
210
|
+
// Handle add instructions
|
|
211
|
+
for (const { content } of addEntries?.entries ?? []) {
|
|
212
|
+
const tweetId = content?.item?.content?.tweet?.id;
|
|
172
213
|
if (tweetId != null) {
|
|
173
|
-
const
|
|
174
|
-
if (
|
|
175
|
-
orderedTweets.push(tweet);
|
|
214
|
+
const tweetResult = parseTweet(timeline, tweetId);
|
|
215
|
+
if (tweetResult.success) {
|
|
216
|
+
orderedTweets.push(tweetResult.tweet);
|
|
176
217
|
}
|
|
177
218
|
}
|
|
178
|
-
const operation =
|
|
179
|
-
if (
|
|
180
|
-
cursor =
|
|
219
|
+
const operation = content?.operation;
|
|
220
|
+
if (operation?.cursor?.cursorType === 'Bottom') {
|
|
221
|
+
cursor = operation?.cursor?.value;
|
|
181
222
|
}
|
|
182
223
|
}
|
|
183
|
-
|
|
184
|
-
|
|
224
|
+
// Handle replace instruction
|
|
225
|
+
const operation = replaceEntry?.entry?.content?.operation;
|
|
226
|
+
if (operation?.cursor?.cursorType === 'Bottom') {
|
|
185
227
|
cursor = operation.cursor.value;
|
|
186
228
|
}
|
|
187
229
|
}
|
|
@@ -195,9 +237,8 @@ function parseTweets(timeline) {
|
|
|
195
237
|
}
|
|
196
238
|
exports.parseTweets = parseTweets;
|
|
197
239
|
function parseUsers(timeline) {
|
|
198
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
199
240
|
const users = new Map();
|
|
200
|
-
const userObjects =
|
|
241
|
+
const userObjects = timeline.globalObjects?.users ?? {};
|
|
201
242
|
for (const id in userObjects) {
|
|
202
243
|
const legacy = userObjects[id];
|
|
203
244
|
if (legacy == null) {
|
|
@@ -208,20 +249,20 @@ function parseUsers(timeline) {
|
|
|
208
249
|
}
|
|
209
250
|
let cursor;
|
|
210
251
|
const orderedProfiles = [];
|
|
211
|
-
for (const instruction of
|
|
212
|
-
for (const entry of
|
|
213
|
-
const userId =
|
|
252
|
+
for (const instruction of timeline.timeline?.instructions ?? []) {
|
|
253
|
+
for (const entry of instruction.addEntries?.entries ?? []) {
|
|
254
|
+
const userId = entry.content?.item?.content?.user?.id;
|
|
214
255
|
const profile = users.get(userId);
|
|
215
256
|
if (profile != null) {
|
|
216
257
|
orderedProfiles.push(profile);
|
|
217
258
|
}
|
|
218
|
-
const operation =
|
|
219
|
-
if (
|
|
220
|
-
cursor =
|
|
259
|
+
const operation = entry.content?.operation;
|
|
260
|
+
if (operation?.cursor?.cursorType === 'Bottom') {
|
|
261
|
+
cursor = operation?.cursor?.value;
|
|
221
262
|
}
|
|
222
263
|
}
|
|
223
|
-
const operation =
|
|
224
|
-
if (
|
|
264
|
+
const operation = instruction.replaceEntry?.entry?.content?.operation;
|
|
265
|
+
if (operation?.cursor?.cursorType === 'Bottom') {
|
|
225
266
|
cursor = operation.cursor.value;
|
|
226
267
|
}
|
|
227
268
|
}
|
package/dist/timeline.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline.js","sourceRoot":"","sources":["../src/timeline.ts"],"names":[],"mappings":";;;AAAA,uCAAiE;
|
|
1
|
+
{"version":3,"file":"timeline.js","sourceRoot":"","sources":["../src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AM,eAAe,GAAc,EAAE,CAAC;IACtC,KAAK,MAAM,WAAW,IAAI,QAAQ,CAAC,QAAQ,EAAE,YAAY,IAAI,EAAE,EAAE;QAC/D,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,UAAU,EAAE,OAAO,IAAI,EAAE,EAAE;YACzD,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;YACtD,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAClC,IAAI,OAAO,IAAI,IAAI,EAAE;gBACnB,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aAC/B;YAED,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC;YAC3C,IAAI,SAAS,EAAE,MAAM,EAAE,UAAU,KAAK,QAAQ,EAAE;gBAC9C,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC;aACnC;SACF;QAED,MAAM,SAAS,GAAG,WAAW,CAAC,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC;QACtE,IAAI,SAAS,EAAE,MAAM,EAAE,UAAU,KAAK,QAAQ,EAAE;YAC9C,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC;SACjC;KACF;IAED,OAAO;QACL,QAAQ,EAAE,eAAe;QACzB,IAAI,EAAE,MAAM;KACb,CAAC;AACJ,CAAC;AAxCD,gCAwCC"}
|
package/dist/trends.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function getTrends(auth:
|
|
1
|
+
import { TwitterAuth } from './auth';
|
|
2
|
+
export declare function getTrends(auth: TwitterAuth): Promise<string[]>;
|
|
3
3
|
//# sourceMappingURL=trends.d.ts.map
|
package/dist/trends.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trends.d.ts","sourceRoot":"","sources":["../src/trends.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"trends.d.ts","sourceRoot":"","sources":["../src/trends.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGrC,wBAAsB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA0CpE"}
|
package/dist/trends.js
CHANGED
|
@@ -1,50 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getTrends = void 0;
|
|
13
4
|
const api_1 = require("./api");
|
|
14
|
-
function getTrends(auth) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
5
|
+
async function getTrends(auth) {
|
|
6
|
+
const params = new URLSearchParams();
|
|
7
|
+
(0, api_1.addApiParams)(params, false);
|
|
8
|
+
params.set('count', '20');
|
|
9
|
+
params.set('candidate_source', 'trends');
|
|
10
|
+
params.set('include_page_configuration', 'false');
|
|
11
|
+
params.set('entity_tokens', 'false');
|
|
12
|
+
const res = await (0, api_1.requestApi)(`https://api.twitter.com/2/guide.json?${params.toString()}`, auth);
|
|
13
|
+
if (!res.success) {
|
|
14
|
+
throw res.err;
|
|
15
|
+
}
|
|
16
|
+
const instructions = res.value.timeline?.instructions ?? [];
|
|
17
|
+
if (instructions.length < 2) {
|
|
18
|
+
throw new Error('No trend entries found.');
|
|
19
|
+
}
|
|
20
|
+
// Some of this is silly, but for now we're assuming we know nothing about the
|
|
21
|
+
// data, and that anything can be missing. Go has non-nilable strings and empty
|
|
22
|
+
// slices are nil, so it largely doesn't need to worry about this.
|
|
23
|
+
const entries = instructions[1].addEntries?.entries ?? [];
|
|
24
|
+
if (entries.length < 2) {
|
|
25
|
+
throw new Error('No trend entries found.');
|
|
26
|
+
}
|
|
27
|
+
const items = entries[1].content?.timelineModule?.items ?? [];
|
|
28
|
+
const trends = [];
|
|
29
|
+
for (const item of items) {
|
|
30
|
+
const trend = item.item?.clientEventInfo?.details?.guideDetails?.transparentGuideDetails
|
|
31
|
+
?.trendMetadata?.trendName;
|
|
32
|
+
if (trend != null) {
|
|
33
|
+
trends.push(trend);
|
|
26
34
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
throw new Error('No trend entries found.');
|
|
30
|
-
}
|
|
31
|
-
// Some of this is silly, but for now we're assuming we know nothing about the
|
|
32
|
-
// data, and that anything can be missing. Go has non-nilable strings and empty
|
|
33
|
-
// slices are nil, so it largely doesn't need to worry about this.
|
|
34
|
-
const entries = (_d = (_c = instructions[1].addEntries) === null || _c === void 0 ? void 0 : _c.entries) !== null && _d !== void 0 ? _d : [];
|
|
35
|
-
if (entries.length < 2) {
|
|
36
|
-
throw new Error('No trend entries found.');
|
|
37
|
-
}
|
|
38
|
-
const items = (_g = (_f = (_e = entries[1].content) === null || _e === void 0 ? void 0 : _e.timelineModule) === null || _f === void 0 ? void 0 : _f.items) !== null && _g !== void 0 ? _g : [];
|
|
39
|
-
const trends = [];
|
|
40
|
-
for (const item of items) {
|
|
41
|
-
const trend = (_o = (_m = (_l = (_k = (_j = (_h = item.item) === null || _h === void 0 ? void 0 : _h.clientEventInfo) === null || _j === void 0 ? void 0 : _j.details) === null || _k === void 0 ? void 0 : _k.guideDetails) === null || _l === void 0 ? void 0 : _l.transparentGuideDetails) === null || _m === void 0 ? void 0 : _m.trendMetadata) === null || _o === void 0 ? void 0 : _o.trendName;
|
|
42
|
-
if (trend != null) {
|
|
43
|
-
trends.push(trend);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return trends;
|
|
47
|
-
});
|
|
35
|
+
}
|
|
36
|
+
return trends;
|
|
48
37
|
}
|
|
49
38
|
exports.getTrends = getTrends;
|
|
50
39
|
//# sourceMappingURL=trends.js.map
|
package/dist/trends.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trends.js","sourceRoot":"","sources":["../src/trends.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"trends.js","sourceRoot":"","sources":["../src/trends.ts"],"names":[],"mappings":";;;AAAA,+BAAiD;AAI1C,KAAK,UAAU,SAAS,CAAC,IAAiB;IAC/C,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,IAAA,kBAAY,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAE5B,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC1B,MAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;IACzC,MAAM,CAAC,GAAG,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAC;IAClD,MAAM,CAAC,GAAG,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IAErC,MAAM,GAAG,GAAG,MAAM,IAAA,gBAAU,EAC1B,wCAAwC,MAAM,CAAC,QAAQ,EAAE,EAAE,EAC3D,IAAI,CACL,CAAC;IACF,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;QAChB,MAAM,GAAG,CAAC,GAAG,CAAC;KACf;IAED,MAAM,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,YAAY,IAAI,EAAE,CAAC;IAC5D,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC5C;IAED,8EAA8E;IAC9E,+EAA+E;IAC/E,kEAAkE;IAClE,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,OAAO,IAAI,EAAE,CAAC;IAC1D,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC5C;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC;IAC9D,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,KAAK,GACT,IAAI,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,uBAAuB;YACxE,EAAE,aAAa,EAAE,SAAS,CAAC;QAC/B,IAAI,KAAK,IAAI,IAAI,EAAE;YACjB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACpB;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA1CD,8BA0CC"}
|
package/dist/tweets.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TwitterAuth } from './auth';
|
|
2
2
|
import { QueryTweetsResponse } from './timeline';
|
|
3
|
+
export interface Mention {
|
|
4
|
+
id: string;
|
|
5
|
+
username?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Photo {
|
|
9
|
+
id: string;
|
|
10
|
+
url: string;
|
|
11
|
+
}
|
|
3
12
|
export interface Video {
|
|
4
13
|
id: string;
|
|
5
14
|
preview: string;
|
|
@@ -30,8 +39,10 @@ export interface Tweet {
|
|
|
30
39
|
isReply?: boolean;
|
|
31
40
|
isRetweet?: boolean;
|
|
32
41
|
likes?: number;
|
|
42
|
+
name?: string;
|
|
43
|
+
mentions: Mention[];
|
|
33
44
|
permanentUrl?: string;
|
|
34
|
-
photos:
|
|
45
|
+
photos: Photo[];
|
|
35
46
|
place?: PlaceRaw;
|
|
36
47
|
quotedStatus?: Tweet;
|
|
37
48
|
replies?: number;
|
|
@@ -44,9 +55,12 @@ export interface Tweet {
|
|
|
44
55
|
userId?: string;
|
|
45
56
|
username?: string;
|
|
46
57
|
videos: Video[];
|
|
58
|
+
views?: number;
|
|
47
59
|
sensitiveContent?: boolean;
|
|
48
60
|
}
|
|
49
|
-
export declare function fetchTweets(
|
|
50
|
-
export declare function getTweets(user: string, maxTweets: number, includeReplies: boolean, auth:
|
|
51
|
-
export declare function
|
|
61
|
+
export declare function fetchTweets(userId: string, maxTweets: number, includeReplies: boolean, cursor: string | undefined, auth: TwitterAuth): Promise<QueryTweetsResponse>;
|
|
62
|
+
export declare function getTweets(user: string, maxTweets: number, includeReplies: boolean, auth: TwitterAuth): AsyncGenerator<Tweet>;
|
|
63
|
+
export declare function getTweetsByUserId(userId: string, maxTweets: number, includeReplies: boolean, auth: TwitterAuth): AsyncGenerator<Tweet>;
|
|
64
|
+
export declare function getLatestTweet(user: string, includeReplies: boolean, includeRetweets: boolean, auth: TwitterAuth): Promise<Tweet | null>;
|
|
65
|
+
export declare function getTweet(id: string, includeReplies: boolean, auth: TwitterAuth): Promise<Tweet | null>;
|
|
52
66
|
//# sourceMappingURL=tweets.d.ts.map
|
package/dist/tweets.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tweets.d.ts","sourceRoot":"","sources":["../src/tweets.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"tweets.d.ts","sourceRoot":"","sources":["../src/tweets.ts"],"names":[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