feat(twitter): keyword for webapi

This commit is contained in:
DIYgod
2024-03-19 21:51:01 +08:00
parent 52edc7e393
commit 2b6c84c829
4 changed files with 32 additions and 7 deletions
+1 -3
View File
@@ -123,10 +123,8 @@ const getSearch = async (keywords: string, params?: Record<string, any>) =>
...params,
rawQuery: keywords,
count: 20,
querySource: 'typed_query',
product: 'Latest',
withDownvotePerspective: false,
withReactionsMetadata: false,
withReactionsPerspective: false,
},
['search_by_raw_query', 'search_timeline', 'timeline']
)
@@ -8,6 +8,7 @@ const graphQLEndpointsPlain = [
'/graphql/TOU4gQw8wXIqpSzA4TYKgg/UserMedia',
'/graphql/B8I_QCljDBVfin21TTWMqA/Likes',
'/graphql/tD8zKvQzwY3kdx5yz6YmOw/UserByRestId',
'/graphql/flaR-PUMshxFWZWPNpq4zA/SearchTimeline',
];
const gqlMap = Object.fromEntries(graphQLEndpointsPlain.map((endpoint) => [endpoint.split('/')[3].replace(/V2$|Query$|QueryV2$/, ''), endpoint]));
@@ -83,6 +84,28 @@ const gqlFeatures = {
longform_notetweets_inline_media_enabled: true,
responsive_web_enhance_cards_enabled: false,
},
SearchTimeline: {
responsive_web_graphql_exclude_directive_enabled: true,
verified_phone_label_enabled: false,
creator_subscriptions_tweet_preview_api_enabled: true,
responsive_web_graphql_timeline_navigation_enabled: true,
responsive_web_graphql_skip_user_profile_image_extensions_enabled: false,
c9s_tweet_anatomy_moderator_badge_enabled: true,
tweetypie_unmention_optimization_enabled: true,
responsive_web_edit_tweet_api_enabled: true,
graphql_is_translatable_rweb_tweet_is_translatable_enabled: true,
view_counts_everywhere_api_enabled: true,
longform_notetweets_consumption_enabled: true,
responsive_web_twitter_article_tweet_consumption_enabled: true,
tweet_awards_web_tipping_enabled: false,
freedom_of_speech_not_reach_fetch_enabled: true,
standardized_nudges_misinfo: true,
tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled: true,
rweb_video_timestamps_enabled: true,
longform_notetweets_rich_text_read_enabled: true,
longform_notetweets_inline_media_enabled: true,
responsive_web_enhance_cards_enabled: false,
},
};
const timelineParams = {
+4
View File
@@ -17,6 +17,10 @@ export const route: Route = {
name: 'TWITTER_PASSWORD',
description: '',
},
{
name: 'TWITTER_COOKIE',
description: '',
},
],
requirePuppeteer: false,
antiCrawler: false,
+4 -4
View File
@@ -47,13 +47,13 @@ async function handler(ctx) {
await api.init();
const userInfo = await api.getUser(id);
const data = await api.getUserMedia(id, params);
const profileImageUrl = userInfo.profile_image_url || userInfo.profile_image_url_https;
const profileImageUrl = userInfo?.profile_image_url || userInfo?.profile_image_url_https;
return {
title: `Twitter @${userInfo.name}`,
link: `https://twitter.com/${userInfo.screen_name}/media`,
title: `Twitter @${userInfo?.name}`,
link: `https://twitter.com/${userInfo?.screen_name}/media`,
image: profileImageUrl.replace(/_normal.jpg$/, '.jpg'),
description: userInfo.description,
description: userInfo?.description,
item: utils.ProcessFeed(ctx, {
data,
}),