-
-
Notifications
You must be signed in to change notification settings - Fork 456
add profile spotlights query #386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -99,6 +99,7 @@ def url(path): | |||||||||||||
| MODERATORS_SLICE_TIMELINE_QUERY = url('9KI_r8e-tgp3--N5SZYVjg/moderatorsSliceTimeline_Query') | ||||||||||||||
| COMMUNITY_TWEET_SEARCH_MODULE_QUERY = url('5341rmzzvdjqfmPKfoHUBw/CommunityTweetSearchModuleQuery') | ||||||||||||||
| TWEET_RESULTS_BY_REST_IDS = url('PTN9HhBAlpoCTHfspDgqLA/TweetResultsByRestIds') | ||||||||||||||
| PROFILE_SPOTLIGHTS = url('1sAf0uU4-B2ZLJGUX5O7LQ/ProfileSpotlightsQuery') | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| class GQLClient: | ||||||||||||||
|
|
@@ -682,6 +683,10 @@ async def tweet_results_by_rest_ids(self, tweet_ids): | |||||||||||||
| } | ||||||||||||||
| return await self.gql_get(Endpoint.TWEET_RESULTS_BY_REST_IDS, variables, TWEET_RESULTS_BY_REST_IDS_FEATURES) | ||||||||||||||
|
|
||||||||||||||
| async def profile_spotlights(self, screen_name): | ||||||||||||||
| variables = {'screen_name': screen_name} | ||||||||||||||
| return await self.gql_get(Endpoint.PROFILE_SPOTLIGHTS, variables) | ||||||||||||||
|
|
||||||||||||||
|
Comment on lines
+686
to
+689
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Pass USER_FEATURES and add a type hint for robustness. Some GQL endpoints require feature gates; align with user queries and add typing. Apply: -async def profile_spotlights(self, screen_name):
- variables = {'screen_name': screen_name}
- return await self.gql_get(Endpoint.PROFILE_SPOTLIGHTS, variables)
+async def profile_spotlights(self, screen_name: str):
+ variables = {'screen_name': screen_name}
+ return await self.gql_get(Endpoint.PROFILE_SPOTLIGHTS, variables, USER_FEATURES)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| #################### | ||||||||||||||
| # For guest client | ||||||||||||||
| #################### | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Rename param to screen_name and handle empty/error responses.
“display_name” is misleading (API expects screen_name). Also avoid IndexError when no result is present and surface API errors consistently.
Apply:
Run to ensure no callers rely on the old param name:
🏁 Script executed:
Length of output: 781
Rename parameter to screen_name and handle empty/error responses
Change the arg name and add explicit API-error / empty-result handling to avoid IndexError. Callers: twikit/user.py:528 calls self._client.get_profile_spotlights(self.screen_name) (positional) — safe to rename.
Location: twikit/client/client.py:4326-4329; caller: twikit/user.py:528.
📝 Committable suggestion
🤖 Prompt for AI Agents