From 87d159d8c9bf1d0074e097c26dd8211fc20abe96 Mon Sep 17 00:00:00 2001 From: jonybang Date: Tue, 26 Dec 2023 01:09:41 +0000 Subject: [PATCH] add list-conversation tweets support for fetchListTweets --- src/timeline-list.ts | 14 ++++++++++---- src/timeline-v2.ts | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/timeline-list.ts b/src/timeline-list.ts index 3f4d2547..97054ebe 100644 --- a/src/timeline-list.ts +++ b/src/timeline-list.ts @@ -1,5 +1,5 @@ import { QueryTweetsResponse } from './timeline-v1'; -import { SearchEntryRaw, parseAndPush } from './timeline-v2'; +import {parseAndPush, TimelineEntryRaw} from './timeline-v2'; import { Tweet } from './tweets'; export interface ListTimeline { @@ -8,8 +8,8 @@ export interface ListTimeline { tweets_timeline?: { timeline?: { instructions?: { - entries?: SearchEntryRaw[]; - entry?: SearchEntryRaw; + entries?: TimelineEntryRaw[]; + entry?: TimelineEntryRaw; type?: string; }[]; }; @@ -43,12 +43,18 @@ export function parseListTimelineTweets( } const idStr = entry.entryId; - if (!idStr.startsWith('tweet')) { + if (!idStr.startsWith('tweet') && !idStr.startsWith('list-conversation')) { continue; } if (entryContent.itemContent) { parseAndPush(tweets, entryContent.itemContent, idStr); + } else if (entryContent.items) { + for (const contentItem of entryContent.items) { + if (contentItem.item && contentItem.item.itemContent && contentItem.entryId) { + parseAndPush(tweets, contentItem.item.itemContent, contentItem.entryId.split('tweet-')[1]); + } + } } } } diff --git a/src/timeline-v2.ts b/src/timeline-v2.ts index 332ab906..d3d57a36 100644 --- a/src/timeline-v2.ts +++ b/src/timeline-v2.ts @@ -37,8 +37,10 @@ export interface TimelineEntryRaw { cursorType?: string; value?: string; items?: { + entryId?: string; item?: { content?: TimelineEntryItemContentRaw; + itemContent?: SearchEntryItemContentRaw; }; }[]; itemContent?: TimelineEntryItemContentRaw;