feat(twitter): add UserMedia support and enhance pagination logic
This commit is contained in:
@@ -84,21 +84,10 @@ const getUserTweetsAndReplies = (id: string, params?: Record<string, any>) =>
|
||||
);
|
||||
|
||||
const getUserMedia = (id: string, params?: Record<string, any>) =>
|
||||
cacheTryGet(id, params, async (id, params = {}) => {
|
||||
const cursorSource = await paginationTweets('UserMedia', id, {
|
||||
...params,
|
||||
count: 20,
|
||||
includePromotedContent: false,
|
||||
withClientEventToken: false,
|
||||
withBirdwatchNotes: false,
|
||||
withVoice: true,
|
||||
withV2Timeline: true,
|
||||
});
|
||||
const cursor = cursorSource.find((i) => i.content?.cursorType === 'Top').content.value;
|
||||
return gatherLegacyFromData(
|
||||
cacheTryGet(id, params, async (id, params = {}) =>
|
||||
gatherLegacyFromData(
|
||||
await paginationTweets('UserMedia', id, {
|
||||
...params,
|
||||
cursor,
|
||||
count: 20,
|
||||
includePromotedContent: false,
|
||||
withClientEventToken: false,
|
||||
@@ -106,8 +95,8 @@ const getUserMedia = (id: string, params?: Record<string, any>) =>
|
||||
withVoice: true,
|
||||
withV2Timeline: true,
|
||||
})
|
||||
);
|
||||
});
|
||||
)
|
||||
);
|
||||
|
||||
const getUserLikes = (id: string, params?: Record<string, any>) =>
|
||||
cacheTryGet(id, params, async (id, params = {}) =>
|
||||
|
||||
@@ -15,7 +15,7 @@ const graphQLEndpointsPlain = [
|
||||
|
||||
const gqlMap = Object.fromEntries(graphQLEndpointsPlain.map((endpoint) => [endpoint.split('/')[3].replace(/V2$|Query$|QueryV2$/, ''), endpoint]));
|
||||
|
||||
const thirdPartySupportedAPI = ['UserByScreenName', 'UserByRestId', 'UserTweets', 'UserTweetsAndReplies', 'ListLatestTweetsTimeline', 'SearchTimeline'];
|
||||
const thirdPartySupportedAPI = ['UserByScreenName', 'UserByRestId', 'UserTweets', 'UserTweetsAndReplies', 'ListLatestTweetsTimeline', 'SearchTimeline', 'UserMedia'];
|
||||
|
||||
const gqlFeatureUser = {
|
||||
hidden_profile_subscriptions_enabled: true,
|
||||
|
||||
@@ -270,8 +270,9 @@ export const paginationTweets = async (endpoint: string, userId: number | undefi
|
||||
|
||||
const moduleItems = instructions.find((i) => i.type === 'TimelineAddToModule')?.moduleItems;
|
||||
const entries = instructions.find((i) => i.type === 'TimelineAddEntries')?.entries;
|
||||
const gridEntries = entries.find((i) => i.entryId === 'profile-grid-0')?.content?.items;
|
||||
|
||||
return moduleItems || entries || [];
|
||||
return gridEntries || moduleItems || entries || [];
|
||||
};
|
||||
|
||||
export function gatherLegacyFromData(entries: any[], filterNested?: string[], userId?: number | string) {
|
||||
|
||||
Reference in New Issue
Block a user