twitter-cli 0.5.0__tar.gz → 0.5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/PKG-INFO +3 -3
  2. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/README.md +2 -2
  3. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/pyproject.toml +1 -1
  4. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/client.py +51 -22
  5. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/graphql.py +2 -2
  6. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/uv.lock +1 -1
  7. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/.github/workflows/ci.yml +0 -0
  8. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/.github/workflows/publish-clawhub.yml +0 -0
  9. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/.github/workflows/publish.yml +0 -0
  10. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/.gitignore +0 -0
  11. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/LICENSE +0 -0
  12. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/SCHEMA.md +0 -0
  13. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/SKILL.md +0 -0
  14. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/config.yaml +0 -0
  15. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/conftest.py +0 -0
  16. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/fixtures/followers_page.json +0 -0
  17. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/fixtures/home_timeline.json +0 -0
  18. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/fixtures/list_timeline.json +0 -0
  19. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/fixtures/search_timeline.json +0 -0
  20. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/fixtures/tweet_detail.json +0 -0
  21. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_auth.py +0 -0
  22. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_cli.py +0 -0
  23. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_client.py +0 -0
  24. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_config.py +0 -0
  25. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_config_normalization.py +0 -0
  26. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_filter.py +0 -0
  27. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_parser_fixtures.py +0 -0
  28. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_serialization.py +0 -0
  29. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_smoke.py +0 -0
  30. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/__init__.py +0 -0
  31. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/auth.py +0 -0
  32. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/cli.py +0 -0
  33. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/config.py +0 -0
  34. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/constants.py +0 -0
  35. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/exceptions.py +0 -0
  36. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/filter.py +0 -0
  37. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/formatter.py +0 -0
  38. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/models.py +0 -0
  39. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/output.py +0 -0
  40. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/parser.py +0 -0
  41. {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/serialization.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: twitter-cli
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Summary: A CLI for Twitter/X — feed, bookmarks, and user timeline in terminal
5
5
  Project-URL: Homepage, https://github.com/jackwener/twitter-cli
6
6
  Project-URL: Repository, https://github.com/jackwener/twitter-cli
@@ -40,7 +40,7 @@ A terminal-first CLI for Twitter/X: read timelines, bookmarks, and user profiles
40
40
 
41
41
  ## More Tools
42
42
 
43
- - [xhs-cli](https://github.com/jackwener/xhs-cli) — Xiaohongshu (小红书) CLI for notes and account workflows
43
+ - [xiaohongshu-cli](https://github.com/jackwener/xiaohongshu-cli) — Xiaohongshu (小红书) CLI for notes and account workflows
44
44
  - [bilibili-cli](https://github.com/jackwener/bilibili-cli) — Bilibili CLI for videos, users, search, and feeds
45
45
  - [discord-cli](https://github.com/jackwener/discord-cli) — Discord CLI for local-first sync, search, and export
46
46
  - [tg-cli](https://github.com/jackwener/tg-cli) — Telegram CLI for local-first sync, search, and export
@@ -501,4 +501,4 @@ clawhub install twitter-cli
501
501
  - [bilibili-cli](https://github.com/jackwener/bilibili-cli) — Bilibili 视频、用户、搜索与动态 CLI
502
502
  - [discord-cli](https://github.com/jackwener/discord-cli) — Discord 本地优先同步、检索与导出 CLI
503
503
  - [tg-cli](https://github.com/jackwener/tg-cli) — Telegram 本地优先同步、检索与导出 CLI
504
- - [xhs-cli](https://github.com/jackwener/xhs-cli) — 小红书笔记与账号工作流 CLI
504
+ - [xiaohongshu-cli](https://github.com/jackwener/xiaohongshu-cli) — 小红书笔记与账号工作流 CLI
@@ -8,7 +8,7 @@ A terminal-first CLI for Twitter/X: read timelines, bookmarks, and user profiles
8
8
 
9
9
  ## More Tools
10
10
 
11
- - [xhs-cli](https://github.com/jackwener/xhs-cli) — Xiaohongshu (小红书) CLI for notes and account workflows
11
+ - [xiaohongshu-cli](https://github.com/jackwener/xiaohongshu-cli) — Xiaohongshu (小红书) CLI for notes and account workflows
12
12
  - [bilibili-cli](https://github.com/jackwener/bilibili-cli) — Bilibili CLI for videos, users, search, and feeds
13
13
  - [discord-cli](https://github.com/jackwener/discord-cli) — Discord CLI for local-first sync, search, and export
14
14
  - [tg-cli](https://github.com/jackwener/tg-cli) — Telegram CLI for local-first sync, search, and export
@@ -469,4 +469,4 @@ clawhub install twitter-cli
469
469
  - [bilibili-cli](https://github.com/jackwener/bilibili-cli) — Bilibili 视频、用户、搜索与动态 CLI
470
470
  - [discord-cli](https://github.com/jackwener/discord-cli) — Discord 本地优先同步、检索与导出 CLI
471
471
  - [tg-cli](https://github.com/jackwener/tg-cli) — Telegram 本地优先同步、检索与导出 CLI
472
- - [xhs-cli](https://github.com/jackwener/xhs-cli) — 小红书笔记与账号工作流 CLI
472
+ - [xiaohongshu-cli](https://github.com/jackwener/xiaohongshu-cli) — 小红书笔记与账号工作流 CLI
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "twitter-cli"
7
- version = "0.5.0"
7
+ version = "0.5.1"
8
8
  description = "A CLI for Twitter/X — feed, bookmarks, and user timeline in terminal"
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -418,27 +418,56 @@ class TwitterClient:
418
418
 
419
419
  def fetch_me(self):
420
420
  # type: () -> UserProfile
421
- """Fetch the currently authenticated user's profile."""
421
+ """Fetch the currently authenticated user's profile.
422
+
423
+ Twitter's /account/multi/list.json endpoint changed its response format:
424
+ - Old: list of dicts with nested "user" objects (rich fields)
425
+ - New: {"users": [...]} with minimal fields (user_id, name, screen_name)
426
+
427
+ When the response only has minimal fields, we use the screen_name to
428
+ fetch the full profile via the GraphQL UserByScreenName endpoint.
429
+ """
422
430
  url = "https://x.com/i/api/1.1/account/multi/list.json"
423
431
  data = self._api_get(url)
424
- if isinstance(data, list) and data:
432
+
433
+ screen_name = None
434
+
435
+ # New format: {"users": [{"user_id": ..., "screen_name": ..., ...}]}
436
+ if isinstance(data, dict) and "users" in data:
437
+ users = data["users"]
438
+ if isinstance(users, list) and users:
439
+ user_data = users[0]
440
+ screen_name = user_data.get("screen_name")
441
+
442
+ # Old format: [{"user": {"id_str": ..., ...}}]
443
+ elif isinstance(data, list) and data:
425
444
  user_data = data[0].get("user", {})
426
445
  if user_data:
427
- return UserProfile(
428
- id=str(user_data.get("id_str", "")),
429
- name=user_data.get("name", ""),
430
- screen_name=user_data.get("screen_name", ""),
431
- bio=user_data.get("description", ""),
432
- location=user_data.get("location", ""),
433
- url=_deep_get(user_data, "entities", "url", "urls", 0, "expanded_url") or "",
434
- followers_count=_parse_int(user_data.get("followers_count"), 0),
435
- following_count=_parse_int(user_data.get("friends_count"), 0),
436
- tweets_count=_parse_int(user_data.get("statuses_count"), 0),
437
- likes_count=_parse_int(user_data.get("favourites_count"), 0),
438
- verified=bool(user_data.get("verified", False)),
439
- profile_image_url=user_data.get("profile_image_url_https", ""),
440
- created_at=user_data.get("created_at", ""),
441
- )
446
+ # Old format had rich fields — try to build profile directly
447
+ sn = user_data.get("screen_name", "")
448
+ if user_data.get("followers_count") is not None:
449
+ return UserProfile(
450
+ id=str(user_data.get("id_str", "")),
451
+ name=user_data.get("name", ""),
452
+ screen_name=sn,
453
+ bio=user_data.get("description", ""),
454
+ location=user_data.get("location", ""),
455
+ url=_deep_get(user_data, "entities", "url", "urls", 0, "expanded_url") or "",
456
+ followers_count=_parse_int(user_data.get("followers_count"), 0),
457
+ following_count=_parse_int(user_data.get("friends_count"), 0),
458
+ tweets_count=_parse_int(user_data.get("statuses_count"), 0),
459
+ likes_count=_parse_int(user_data.get("favourites_count"), 0),
460
+ verified=bool(user_data.get("verified", False)),
461
+ profile_image_url=user_data.get("profile_image_url_https", ""),
462
+ created_at=user_data.get("created_at", ""),
463
+ )
464
+ screen_name = sn
465
+
466
+ # Use screen_name to fetch full profile via GraphQL
467
+ if screen_name:
468
+ logger.info("Fetching full profile for @%s via GraphQL", screen_name)
469
+ return self.fetch_user(screen_name)
470
+
442
471
  raise TwitterAPIError(0, "Failed to fetch current user info")
443
472
 
444
473
  def quote_tweet(self, tweet_id, text):
@@ -625,9 +654,9 @@ class TwitterClient:
625
654
  try:
626
655
  return self._api_get(url)
627
656
  except TwitterAPIError as exc:
628
- # Fallback query IDs can go stale. Retry with live lookup if 404.
629
- if exc.status_code == 404 and using_fallback:
630
- logger.info("Retrying %s with live queryId after 404", operation_name)
657
+ # Fallback query IDs can go stale. Retry with live lookup if 404/422.
658
+ if exc.status_code in (404, 422) and using_fallback:
659
+ logger.info("Retrying %s with live queryId after %d", operation_name, exc.status_code)
631
660
  _invalidate_query_id(operation_name)
632
661
  refreshed_query_id = _resolve_query_id(operation_name, prefer_fallback=False, url_fetch_fn=_url_fetch)
633
662
  retry_url = _build_graphql_url(refreshed_query_id, operation_name, variables, features, field_toggles)
@@ -651,8 +680,8 @@ class TwitterClient:
651
680
  try:
652
681
  return _do_post(query_id)
653
682
  except TwitterAPIError as exc:
654
- if exc.status_code == 404 and using_fallback:
655
- logger.info("Retrying POST %s with live queryId after 404", operation_name)
683
+ if exc.status_code in (404, 422) and using_fallback:
684
+ logger.info("Retrying POST %s with live queryId after %d", operation_name, exc.status_code)
656
685
  _invalidate_query_id(operation_name)
657
686
  refreshed = _resolve_query_id(operation_name, prefer_fallback=False, url_fetch_fn=_url_fetch)
658
687
  return _do_post(refreshed)
@@ -33,8 +33,8 @@ FALLBACK_QUERY_IDS = {
33
33
  "SearchTimeline": "MJpyQGqgklrVl_0X9gNy3A",
34
34
  "Bookmarks": "uzboyXSHSJrR-mGJqep0TQ",
35
35
  "ListLatestTweetsTimeline": "ZBbXrl0FVnTqp7K6EAADog",
36
- "Followers": "t-BPOrMIduGUJWO_LxcvNQ",
37
- "Following": "iSicc7LrzWGBgDPL0tM_TQ",
36
+ "Followers": "IOh4aS6UdGWGJUYTqliQ7Q",
37
+ "Following": "zx6e-TLzRkeDO_a7p4b3JQ",
38
38
  "CreateTweet": "bDE2rBtZb3uyrczSZ_pI9g",
39
39
  "DeleteTweet": "VaenaVgh5q5ih7kvyVjgtg",
40
40
  "FavoriteTweet": "lI07N6Otwv1PhnEgXILM7A",
@@ -1010,7 +1010,7 @@ wheels = [
1010
1010
 
1011
1011
  [[package]]
1012
1012
  name = "twitter-cli"
1013
- version = "0.4.6"
1013
+ version = "0.5.0"
1014
1014
  source = { editable = "." }
1015
1015
  dependencies = [
1016
1016
  { name = "beautifulsoup4" },
File without changes
File without changes
File without changes
File without changes
File without changes