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:
jackwener
2026-03-11 17:08:14 +08:00
parent 60e1e7c580
commit 1de88ea2ed
2 changed files with 12 additions and 2 deletions

View File

@@ -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,