From 1de88ea2ed450f9cf013fd5be00a1d695bb255d0 Mon Sep 17 00:00:00 2001 From: jackwener Date: Wed, 11 Mar 2026 17:08:14 +0800 Subject: [PATCH] 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 --- twitter_cli/client.py | 12 +++++++++++- twitter_cli/graphql.py | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/twitter_cli/client.py b/twitter_cli/client.py index d1639ed..7512f3c 100644 --- a/twitter_cli/client.py +++ b/twitter_cli/client.py @@ -246,10 +246,20 @@ class TwitterClient: def fetch_user_likes(self, user_id, count=20): # type: (str, int) -> List[Tweet] """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( "Likes", count, - lambda data: _deep_get(data, "data", "user", "result", "timeline_v2", "timeline", "instructions"), + get_likes_instructions, extra_variables={ "userId": user_id, "includePromotedContent": False, diff --git a/twitter_cli/graphql.py b/twitter_cli/graphql.py index 50f7fcd..a019460 100644 --- a/twitter_cli/graphql.py +++ b/twitter_cli/graphql.py @@ -29,7 +29,7 @@ FALLBACK_QUERY_IDS = { "UserByScreenName": "qRednkZG-rn1P6b48NINmQ", "UserTweets": "E3opETHurmVJflFsUBVuUQ", "TweetDetail": "nBS-WpgA6ZG0CyNHD517JQ", - "Likes": "aeJWz7GtGNHHO2Z3GrjCWg", + "Likes": "dv5-II7_Bup_PHish7p6fw", "SearchTimeline": "MJpyQGqgklrVl_0X9gNy3A", "Bookmarks": "uzboyXSHSJrR-mGJqep0TQ", "ListLatestTweetsTimeline": "ZBbXrl0FVnTqp7K6EAADog",