fix: update Likes queryId and response path (fixes #8)
- Update Likes fallback queryId: aeJWz7GtGNHHO2Z3GrjCWg -> dv5-II7_Bup_PHish7p6fw - Fix response path: data.user.result.timeline.timeline.instructions (Twitter renamed timeline_v2 to timeline; code now tries both) - Verified via Playwright: API returns 200 with correct tweet entries Fixes #8
This commit is contained in:
@@ -246,10 +246,20 @@ class TwitterClient:
|
|||||||
def fetch_user_likes(self, user_id, count=20):
|
def fetch_user_likes(self, user_id, count=20):
|
||||||
# type: (str, int) -> List[Tweet]
|
# type: (str, int) -> List[Tweet]
|
||||||
"""Fetch tweets liked by a user."""
|
"""Fetch tweets liked by a user."""
|
||||||
|
|
||||||
|
def get_likes_instructions(data):
|
||||||
|
# type: (Any) -> Any
|
||||||
|
# New path (2024+): data.user.result.timeline.timeline.instructions
|
||||||
|
instructions = _deep_get(data, "data", "user", "result", "timeline", "timeline", "instructions")
|
||||||
|
if instructions is None:
|
||||||
|
# Legacy path: data.user.result.timeline_v2.timeline.instructions
|
||||||
|
instructions = _deep_get(data, "data", "user", "result", "timeline_v2", "timeline", "instructions")
|
||||||
|
return instructions
|
||||||
|
|
||||||
return self._fetch_timeline(
|
return self._fetch_timeline(
|
||||||
"Likes",
|
"Likes",
|
||||||
count,
|
count,
|
||||||
lambda data: _deep_get(data, "data", "user", "result", "timeline_v2", "timeline", "instructions"),
|
get_likes_instructions,
|
||||||
extra_variables={
|
extra_variables={
|
||||||
"userId": user_id,
|
"userId": user_id,
|
||||||
"includePromotedContent": False,
|
"includePromotedContent": False,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ FALLBACK_QUERY_IDS = {
|
|||||||
"UserByScreenName": "qRednkZG-rn1P6b48NINmQ",
|
"UserByScreenName": "qRednkZG-rn1P6b48NINmQ",
|
||||||
"UserTweets": "E3opETHurmVJflFsUBVuUQ",
|
"UserTweets": "E3opETHurmVJflFsUBVuUQ",
|
||||||
"TweetDetail": "nBS-WpgA6ZG0CyNHD517JQ",
|
"TweetDetail": "nBS-WpgA6ZG0CyNHD517JQ",
|
||||||
"Likes": "aeJWz7GtGNHHO2Z3GrjCWg",
|
"Likes": "dv5-II7_Bup_PHish7p6fw",
|
||||||
"SearchTimeline": "MJpyQGqgklrVl_0X9gNy3A",
|
"SearchTimeline": "MJpyQGqgklrVl_0X9gNy3A",
|
||||||
"Bookmarks": "uzboyXSHSJrR-mGJqep0TQ",
|
"Bookmarks": "uzboyXSHSJrR-mGJqep0TQ",
|
||||||
"ListLatestTweetsTimeline": "ZBbXrl0FVnTqp7K6EAADog",
|
"ListLatestTweetsTimeline": "ZBbXrl0FVnTqp7K6EAADog",
|
||||||
|
|||||||
Reference in New Issue
Block a user