@the-convocation/twitter-scraper
Advanced tools
Comparing version 0.9.2 to 0.9.3
@@ -9,4 +9,3 @@ "use strict"; | ||
const tweets = []; | ||
const instructions = timeline.data?.list?.tweets_timeline?.timeline | ||
?.instructions ?? []; | ||
const instructions = timeline.data?.list?.tweets_timeline?.timeline?.instructions ?? []; | ||
for (const instruction of instructions) { | ||
@@ -27,3 +26,4 @@ const entries = instruction.entries ?? []; | ||
const idStr = entry.entryId; | ||
if (!idStr.startsWith('tweet') && !idStr.startsWith('list-conversation')) { | ||
if (!idStr.startsWith('tweet') && | ||
!idStr.startsWith('list-conversation')) { | ||
continue; | ||
@@ -36,3 +36,5 @@ } | ||
for (const contentItem of entryContent.items) { | ||
if (contentItem.item && contentItem.item.itemContent && contentItem.entryId) { | ||
if (contentItem.item && | ||
contentItem.item.itemContent && | ||
contentItem.entryId) { | ||
(0, timeline_v2_1.parseAndPush)(tweets, contentItem.item.itemContent, contentItem.entryId.split('tweet-')[1]); | ||
@@ -39,0 +41,0 @@ } |
@@ -137,2 +137,3 @@ "use strict"; | ||
} | ||
const expectedEntryTypes = ['tweet', 'profile-conversation']; | ||
function parseTimelineTweetsV2(timeline) { | ||
@@ -149,2 +150,3 @@ let bottomCursor; | ||
continue; | ||
// Handle pagination | ||
if (entryContent.cursorType === 'Bottom') { | ||
@@ -159,8 +161,17 @@ bottomCursor = entryContent.value; | ||
const idStr = entry.entryId; | ||
if (!idStr.startsWith('tweet')) { | ||
if (!expectedEntryTypes.some((entryType) => idStr.startsWith(entryType))) { | ||
continue; | ||
} | ||
if (entryContent.itemContent) { | ||
// Typically TimelineTimelineTweet entries | ||
parseAndPush(tweets, entryContent.itemContent, idStr); | ||
} | ||
else if (entryContent.items) { | ||
// Typically TimelineTimelineModule entries | ||
for (const item of entryContent.items) { | ||
if (item.item?.itemContent) { | ||
parseAndPush(tweets, item.item.itemContent, idStr); | ||
} | ||
} | ||
} | ||
} | ||
@@ -175,5 +186,5 @@ } | ||
if (result.legacy) { | ||
result.legacy.id_str = entryId | ||
.replace('conversation-', '') | ||
.replace('tweet-', ''); | ||
result.legacy.id_str = | ||
result.rest_id ?? | ||
entryId.replace('conversation-', '').replace('tweet-', ''); | ||
} | ||
@@ -180,0 +191,0 @@ const tweetResult = parseResult(result); |
@@ -5,3 +5,3 @@ { | ||
"keywords": ["x", "twitter", "scraper"], | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"main": "dist/_module.js", | ||
@@ -8,0 +8,0 @@ "repository": "https://github.com/the-convocation/twitter-scraper.git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
243189
3351