feat(twitter): add twitter getHomeLatestTimeline (#16549)
This commit is contained in:
parent
5fd5b80fdc
commit
df5c044ed8
|
|
@ -18,6 +18,7 @@ let api: {
|
|||
getSearch: ApiItem;
|
||||
getList: ApiItem;
|
||||
getHomeTimeline: ApiItem;
|
||||
getHomeLatestTimeline: ApiItem;
|
||||
} = {
|
||||
init: () => {
|
||||
throw new ConfigNotFoundError('Twitter API is not configured');
|
||||
|
|
@ -31,6 +32,7 @@ let api: {
|
|||
getSearch: () => null,
|
||||
getList: () => null,
|
||||
getHomeTimeline: () => null,
|
||||
getHomeLatestTimeline: () => null,
|
||||
};
|
||||
|
||||
if (enableWebApi) {
|
||||
|
|
|
|||
|
|
@ -184,6 +184,23 @@ const getHomeTimeline = async (id: string, params?: Record<string, any>) =>
|
|||
)
|
||||
);
|
||||
|
||||
const getHomeLatestTimeline = async (id: string, params?: Record<string, any>) =>
|
||||
gatherLegacyFromData(
|
||||
await paginationTweets(
|
||||
'HomeLatestTimeline',
|
||||
undefined,
|
||||
{
|
||||
...params,
|
||||
count: 20,
|
||||
includePromotedContent: true,
|
||||
latestControlAvailable: true,
|
||||
requestContext: 'launch',
|
||||
withCommunity: true,
|
||||
},
|
||||
['home', 'home_timeline_urt']
|
||||
)
|
||||
);
|
||||
|
||||
export default {
|
||||
getUser,
|
||||
getUserTweets,
|
||||
|
|
@ -194,5 +211,6 @@ export default {
|
|||
getSearch,
|
||||
getList,
|
||||
getHomeTimeline,
|
||||
getHomeLatestTimeline,
|
||||
init: () => {},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ const graphQLEndpointsPlain = [
|
|||
'/graphql/eS7LO5Jy3xgmd3dbL044EA/UserTweets',
|
||||
'/graphql/k5XapwcSikNsEsILW5FvgA/UserByScreenName',
|
||||
'/graphql/k3YiLNE_MAy5J-NANLERdg/HomeTimeline',
|
||||
'/graphql/DiTkXJgLqBBxCs7zaYsbtA/HomeLatestTimeline',
|
||||
'/graphql/3GeIaLmNhTm1YsUmxR57tg/UserTweetsAndReplies',
|
||||
'/graphql/TOU4gQw8wXIqpSzA4TYKgg/UserMedia',
|
||||
'/graphql/B8I_QCljDBVfin21TTWMqA/Likes',
|
||||
|
|
@ -87,6 +88,7 @@ const gqlFeatures = {
|
|||
SearchTimeline: gqlFeatureFeed,
|
||||
ListLatestTweetsTimeline: gqlFeatureFeed,
|
||||
HomeTimeline: gqlFeatureFeed,
|
||||
HomeLatestTimeline: TweetDetailFeatures,
|
||||
TweetDetail: TweetDetailFeatures,
|
||||
Likes: gqlFeatureFeed,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
import { Route } from '@/types';
|
||||
import utils from './utils';
|
||||
import api from './api';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/home_latest/:routeParams?',
|
||||
categories: ['social-media'],
|
||||
example: '/twitter/home_latest',
|
||||
features: {
|
||||
requireConfig: [
|
||||
{
|
||||
name: 'TWITTER_USERNAME',
|
||||
description: 'Please see above for details.',
|
||||
},
|
||||
{
|
||||
name: 'TWITTER_PASSWORD',
|
||||
description: 'Please see above for details.',
|
||||
},
|
||||
{
|
||||
name: 'TWITTER_AUTH_TOKEN',
|
||||
description: 'Please see above for details.',
|
||||
},
|
||||
],
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
name: 'Home latest timeline',
|
||||
maintainers: ['DIYgod', 'CaoMeiYouRen'],
|
||||
handler,
|
||||
radar: [
|
||||
{
|
||||
source: ['x.com/home'],
|
||||
target: '/home_latest',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
// For compatibility
|
||||
const { count, include_rts } = utils.parseRouteParams(ctx.req.param('routeParams'));
|
||||
const params = count ? { count } : {};
|
||||
|
||||
await api.init();
|
||||
let data = await api.getHomeLatestTimeline('', params);
|
||||
if (!include_rts) {
|
||||
data = utils.excludeRetweet(data);
|
||||
}
|
||||
|
||||
return {
|
||||
title: `Twitter following timeline`,
|
||||
link: `https://x.com/home`,
|
||||
// description: userInfo?.description,
|
||||
item: utils.ProcessFeed(ctx, {
|
||||
data,
|
||||
}),
|
||||
};
|
||||
}
|
||||
Loading…
Reference in New Issue