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.
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/PKG-INFO +3 -3
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/README.md +2 -2
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/pyproject.toml +1 -1
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/client.py +51 -22
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/graphql.py +2 -2
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/uv.lock +1 -1
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/.github/workflows/ci.yml +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/.github/workflows/publish-clawhub.yml +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/.github/workflows/publish.yml +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/.gitignore +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/LICENSE +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/SCHEMA.md +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/SKILL.md +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/config.yaml +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/conftest.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/fixtures/followers_page.json +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/fixtures/home_timeline.json +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/fixtures/list_timeline.json +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/fixtures/search_timeline.json +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/fixtures/tweet_detail.json +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_auth.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_cli.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_client.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_config.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_config_normalization.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_filter.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_parser_fixtures.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_serialization.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/tests/test_smoke.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/__init__.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/auth.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/cli.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/config.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/constants.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/exceptions.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/filter.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/formatter.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/models.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/output.py +0 -0
- {twitter_cli-0.5.0 → twitter_cli-0.5.1}/twitter_cli/parser.py +0 -0
- {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.
|
|
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
|
-
- [
|
|
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
|
-
- [
|
|
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
|
-
- [
|
|
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
|
-
- [
|
|
472
|
+
- [xiaohongshu-cli](https://github.com/jackwener/xiaohongshu-cli) — 小红书笔记与账号工作流 CLI
|
|
@@ -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
|
-
|
|
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
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
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
|
|
630
|
-
logger.info("Retrying %s with live queryId after
|
|
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
|
|
655
|
-
logger.info("Retrying POST %s with live queryId after
|
|
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": "
|
|
37
|
-
"Following": "
|
|
36
|
+
"Followers": "IOh4aS6UdGWGJUYTqliQ7Q",
|
|
37
|
+
"Following": "zx6e-TLzRkeDO_a7p4b3JQ",
|
|
38
38
|
"CreateTweet": "bDE2rBtZb3uyrczSZ_pI9g",
|
|
39
39
|
"DeleteTweet": "VaenaVgh5q5ih7kvyVjgtg",
|
|
40
40
|
"FavoriteTweet": "lI07N6Otwv1PhnEgXILM7A",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|