@the-convocation/twitter-scraper 0.17.0 → 0.17.2

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.
@@ -303,12 +303,7 @@ class TwitterGuestAuth {
303
303
  headers.set("cookie", await this.getCookieString());
304
304
  }
305
305
  async getCookies() {
306
- const cookies = await Promise.all([
307
- this.jar.getCookies(this.getCookieJarUrl()),
308
- this.jar.getCookies("https://twitter.com"),
309
- this.jar.getCookies("https://x.com")
310
- ]);
311
- return cookies.flat();
306
+ return this.jar.getCookies(this.getCookieJarUrl());
312
307
  }
313
308
  async getCookieString() {
314
309
  const cookies = await this.getCookies();
@@ -326,7 +321,7 @@ class TwitterGuestAuth {
326
321
  }
327
322
  }
328
323
  getCookieJarUrl() {
329
- return typeof document !== "undefined" ? document.location.toString() : "https://twitter.com";
324
+ return typeof document !== "undefined" ? document.location.toString() : "https://x.com";
330
325
  }
331
326
  /**
332
327
  * Updates the authentication state with a new guest token from the Twitter API.
@@ -853,7 +848,7 @@ function parseProfile(legacy, isBlueVerified) {
853
848
  name: legacy.name,
854
849
  pinnedTweetIds: legacy.pinned_tweet_ids_str,
855
850
  tweetsCount: legacy.statuses_count,
856
- url: `https://twitter.com/${legacy.screen_name}`,
851
+ url: `https://x.com/${legacy.screen_name}`,
857
852
  userId: legacy.id_str,
858
853
  username: legacy.screen_name,
859
854
  isBlueVerified: isBlueVerified ?? false,
@@ -1016,7 +1011,7 @@ function parseMediaGroups(media) {
1016
1011
  url: m.media_url_https,
1017
1012
  alt_text: m.ext_alt_text
1018
1013
  });
1019
- } else if (m.type === "video") {
1014
+ } else if (m.type === "video" || m.type === "animated_gif") {
1020
1015
  videos.push(parseVideo(m));
1021
1016
  }
1022
1017
  const sensitive = m.ext_sensitive_media_warning;
@@ -1071,22 +1066,19 @@ function reconstructTweetHtml(tweet, photos, videos) {
1071
1066
  return html;
1072
1067
  }
1073
1068
  function linkHashtagHtml(hashtag) {
1074
- return `<a href="https://twitter.com/hashtag/${hashtag.replace(
1069
+ return `<a href="https://x.com/hashtag/${hashtag.replace(
1075
1070
  "#",
1076
1071
  ""
1077
1072
  )}">${hashtag}</a>`;
1078
1073
  }
1079
1074
  function linkCashtagHtml(cashtag) {
1080
- return `<a href="https://twitter.com/search?q=%24${cashtag.replace(
1075
+ return `<a href="https://x.com/search?q=%24${cashtag.replace(
1081
1076
  "$",
1082
1077
  ""
1083
1078
  )}">${cashtag}</a>`;
1084
1079
  }
1085
1080
  function linkUsernameHtml(username) {
1086
- return `<a href="https://twitter.com/${username.replace(
1087
- "@",
1088
- ""
1089
- )}">${username}</a>`;
1081
+ return `<a href="https://x.com/${username.replace("@", "")}">${username}</a>`;
1090
1082
  }
1091
1083
  function unwrapTcoUrlHtml(tweet, foundedMedia) {
1092
1084
  return function(tco) {
@@ -1155,7 +1147,7 @@ function parseLegacyTweet(coreUser, user, tweet, editControl) {
1155
1147
  name: mention.name
1156
1148
  })),
1157
1149
  name,
1158
- permanentUrl: `https://twitter.com/${username}/status/${tweetId}`,
1150
+ permanentUrl: `https://x.com/${username}/status/${tweetId}`,
1159
1151
  photos,
1160
1152
  replies: tweet.reply_count,
1161
1153
  retweets: tweet.retweet_count,
@@ -1535,7 +1527,7 @@ async function getSearchTimeline(query, maxItems, searchMode, auth, cursor) {
1535
1527
  params.set("fieldToggles", stringify(fieldToggles));
1536
1528
  params.set("variables", stringify(variables));
1537
1529
  const res = await requestApi(
1538
- `https://api.twitter.com/graphql/gkjsKepM6gl_HmFWoWKfgg/SearchTimeline?${params.toString()}`,
1530
+ `https://api.x.com/graphql/gkjsKepM6gl_HmFWoWKfgg/SearchTimeline?${params.toString()}`,
1539
1531
  auth
1540
1532
  );
1541
1533
  if (!res.success) {
@@ -1650,7 +1642,7 @@ async function getFollowingTimeline(userId, maxItems, auth, cursor) {
1650
1642
  params.set("features", stringify(features));
1651
1643
  params.set("variables", stringify(variables));
1652
1644
  const res = await requestApi(
1653
- `https://twitter.com/i/api/graphql/iSicc7LrzWGBgDPL0tM_TQ/Following?${params.toString()}`,
1645
+ `https://x.com/i/api/graphql/iSicc7LrzWGBgDPL0tM_TQ/Following?${params.toString()}`,
1654
1646
  auth
1655
1647
  );
1656
1648
  if (!res.success) {
@@ -1685,7 +1677,7 @@ async function getFollowersTimeline(userId, maxItems, auth, cursor) {
1685
1677
  params.set("features", stringify(features));
1686
1678
  params.set("variables", stringify(variables));
1687
1679
  const res = await requestApi(
1688
- `https://twitter.com/i/api/graphql/rRXFSG5vR6drKr5M37YOTw/Followers?${params.toString()}`,
1680
+ `https://x.com/i/api/graphql/rRXFSG5vR6drKr5M37YOTw/Followers?${params.toString()}`,
1689
1681
  auth
1690
1682
  );
1691
1683
  if (!res.success) {
@@ -1702,7 +1694,7 @@ async function getTrends(auth) {
1702
1694
  params.set("include_page_configuration", "false");
1703
1695
  params.set("entity_tokens", "false");
1704
1696
  const res = await requestApi(
1705
- `https://api.twitter.com/2/guide.json?${params.toString()}`,
1697
+ `https://api.x.com/2/guide.json?${params.toString()}`,
1706
1698
  auth
1707
1699
  );
1708
1700
  if (!res.success) {