twitter-cli 0.4.1__tar.gz → 0.4.3__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.4.1 → twitter_cli-0.4.3}/PKG-INFO +1 -1
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/pyproject.toml +1 -1
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/tests/test_client.py +29 -14
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/twitter_cli/client.py +19 -32
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/uv.lock +1 -1
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/.github/workflows/ci.yml +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/.github/workflows/publish-clawhub.yml +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/.github/workflows/publish.yml +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/.gitignore +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/LICENSE +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/README.md +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/SKILL.md +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/config.yaml +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/tests/conftest.py +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/tests/test_cli.py +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/tests/test_config.py +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/tests/test_config_normalization.py +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/tests/test_filter.py +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/tests/test_serialization.py +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/twitter_cli/__init__.py +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/twitter_cli/auth.py +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/twitter_cli/cli.py +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/twitter_cli/config.py +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/twitter_cli/constants.py +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/twitter_cli/filter.py +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/twitter_cli/formatter.py +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/twitter_cli/models.py +0 -0
- {twitter_cli-0.4.1 → twitter_cli-0.4.3}/twitter_cli/serialization.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: twitter-cli
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.3
|
|
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
|
|
@@ -176,6 +176,23 @@ class TestBuildGraphqlUrl:
|
|
|
176
176
|
url = _build_graphql_url("x", "Op", {}, {}, {"toggle": True})
|
|
177
177
|
assert "fieldToggles=" in url
|
|
178
178
|
|
|
179
|
+
def test_false_features_omitted_from_url(self):
|
|
180
|
+
"""False-valued features should be omitted to keep URL short (avoid 414)."""
|
|
181
|
+
features = {"enabled_flag": True, "disabled_flag": False, "another_enabled": True}
|
|
182
|
+
url = _build_graphql_url("q", "Op", {}, features)
|
|
183
|
+
assert "enabled_flag" in url
|
|
184
|
+
assert "another_enabled" in url
|
|
185
|
+
assert "disabled_flag" not in url
|
|
186
|
+
|
|
187
|
+
def test_url_length_with_full_features(self):
|
|
188
|
+
"""URL with full FEATURES dict should stay under 8000 chars (server limit)."""
|
|
189
|
+
url = _build_graphql_url(
|
|
190
|
+
"abc123", "SearchTimeline",
|
|
191
|
+
{"rawQuery": "AI agent", "querySource": "typed_query", "product": "Latest", "count": 50},
|
|
192
|
+
FEATURES,
|
|
193
|
+
)
|
|
194
|
+
assert len(url) < 8000, f"URL too long: {len(url)} chars"
|
|
195
|
+
|
|
179
196
|
|
|
180
197
|
# ── _best_chrome_target ──────────────────────────────────────────────────
|
|
181
198
|
|
|
@@ -196,30 +213,28 @@ class TestBestChromeTarget:
|
|
|
196
213
|
# ── _update_features_from_html ───────────────────────────────────────────
|
|
197
214
|
|
|
198
215
|
class TestUpdateFeaturesFromHtml:
|
|
199
|
-
def
|
|
200
|
-
|
|
216
|
+
def test_updates_existing_feature_flags(self):
|
|
217
|
+
"""Should update existing FEATURES keys, not add new ones."""
|
|
201
218
|
original = dict(FEATURES)
|
|
202
219
|
try:
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
"
|
|
207
|
-
''
|
|
220
|
+
# Use a key that exists in FEATURES
|
|
221
|
+
existing_key = list(FEATURES.keys())[0]
|
|
222
|
+
original_value = FEATURES[existing_key]
|
|
223
|
+
opposite = "false" if original_value else "true"
|
|
224
|
+
html = '"%s":{"value":%s}' % (existing_key, opposite)
|
|
208
225
|
_update_features_from_html(html)
|
|
209
|
-
assert FEATURES[
|
|
210
|
-
assert FEATURES["responsive_web_another_feature"] is False
|
|
211
|
-
assert FEATURES["rweb_some_flag"] is True
|
|
226
|
+
assert FEATURES[existing_key] != original_value
|
|
212
227
|
finally:
|
|
213
|
-
# Restore original state
|
|
214
228
|
FEATURES.clear()
|
|
215
229
|
FEATURES.update(original)
|
|
216
230
|
|
|
217
|
-
def
|
|
231
|
+
def test_does_not_add_new_keys(self):
|
|
232
|
+
"""Should never add keys not already in FEATURES (prevents URL bloat)."""
|
|
218
233
|
original = dict(FEATURES)
|
|
219
234
|
try:
|
|
220
|
-
html = '"
|
|
235
|
+
html = '"responsive_web_brand_new_feature":{"value":true}'
|
|
221
236
|
_update_features_from_html(html)
|
|
222
|
-
assert "
|
|
237
|
+
assert "responsive_web_brand_new_feature" not in FEATURES
|
|
223
238
|
finally:
|
|
224
239
|
FEATURES.clear()
|
|
225
240
|
FEATURES.update(original)
|
|
@@ -53,43 +53,24 @@ TWITTER_OPENAPI_URL = (
|
|
|
53
53
|
"main/src/config/placeholder.json"
|
|
54
54
|
)
|
|
55
55
|
|
|
56
|
+
# Essential features only — keep this list SMALL to avoid 414/431 URI Too Long.
|
|
57
|
+
# Twitter's API defaults missing features to False, so we only need True-valued ones
|
|
58
|
+
# that affect tweet data we actually consume. Each additional key adds ~60 chars to URL.
|
|
56
59
|
_DEFAULT_FEATURES = {
|
|
57
|
-
"rweb_video_screen_enabled": False,
|
|
58
|
-
"profile_label_improvements_pcf_label_in_post_enabled": True,
|
|
59
|
-
"responsive_web_profile_redirect_enabled": False,
|
|
60
|
-
"rweb_tipjar_consumption_enabled": False,
|
|
61
|
-
"verified_phone_label_enabled": False,
|
|
62
60
|
"creator_subscriptions_tweet_preview_api_enabled": True,
|
|
63
|
-
"responsive_web_graphql_timeline_navigation_enabled": True,
|
|
64
|
-
"responsive_web_graphql_skip_user_profile_image_extensions_enabled": False,
|
|
65
|
-
"premium_content_api_read_enabled": False,
|
|
66
61
|
"communities_web_enable_tweet_community_results_fetch": True,
|
|
67
62
|
"c9s_tweet_anatomy_moderator_badge_enabled": True,
|
|
68
|
-
"responsive_web_grok_analyze_button_fetch_trends_enabled": False,
|
|
69
|
-
"responsive_web_grok_analyze_post_followups_enabled": True,
|
|
70
|
-
"responsive_web_jetfuel_frame": True,
|
|
71
|
-
"responsive_web_grok_share_attachment_enabled": True,
|
|
72
|
-
"responsive_web_grok_annotations_enabled": True,
|
|
73
63
|
"articles_preview_enabled": True,
|
|
74
64
|
"responsive_web_edit_tweet_api_enabled": True,
|
|
75
65
|
"graphql_is_translatable_rweb_tweet_is_translatable_enabled": True,
|
|
76
66
|
"view_counts_everywhere_api_enabled": True,
|
|
77
67
|
"longform_notetweets_consumption_enabled": True,
|
|
78
68
|
"responsive_web_twitter_article_tweet_consumption_enabled": True,
|
|
79
|
-
"tweet_awards_web_tipping_enabled": False,
|
|
80
|
-
"content_disclosure_indicator_enabled": True,
|
|
81
|
-
"content_disclosure_ai_generated_indicator_enabled": True,
|
|
82
|
-
"responsive_web_grok_show_grok_translated_post": True,
|
|
83
|
-
"responsive_web_grok_analysis_button_from_backend": True,
|
|
84
|
-
"post_ctas_fetch_enabled": True,
|
|
85
|
-
"freedom_of_speech_not_reach_fetch_enabled": True,
|
|
86
|
-
"standardized_nudges_misinfo": True,
|
|
87
69
|
"tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled": True,
|
|
88
70
|
"longform_notetweets_rich_text_read_enabled": True,
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"responsive_web_grok_community_note_auto_translation_is_enabled": False,
|
|
71
|
+
"freedom_of_speech_not_reach_fetch_enabled": True,
|
|
72
|
+
"standardized_nudges_misinfo": True,
|
|
73
|
+
"responsive_web_graphql_timeline_navigation_enabled": True,
|
|
93
74
|
"responsive_web_enhance_cards_enabled": False,
|
|
94
75
|
}
|
|
95
76
|
|
|
@@ -164,12 +145,18 @@ def _url_fetch(url, headers=None):
|
|
|
164
145
|
|
|
165
146
|
def _build_graphql_url(query_id, operation_name, variables, features, field_toggles=None):
|
|
166
147
|
# type: (str, str, Dict[str, Any], Dict[str, Any], Optional[Dict[str, Any]]) -> str
|
|
167
|
-
"""Build GraphQL GET URL with encoded variables/features/fieldToggles.
|
|
148
|
+
"""Build GraphQL GET URL with encoded variables/features/fieldToggles.
|
|
149
|
+
|
|
150
|
+
Only includes True-valued feature flags in the URL to avoid 414 URI Too Long.
|
|
151
|
+
Twitter's API defaults missing features to False.
|
|
152
|
+
"""
|
|
153
|
+
# Compact features: omit False values to keep URL under server limits
|
|
154
|
+
compact_features = {k: v for k, v in features.items() if v is not False}
|
|
168
155
|
url = "https://x.com/i/api/graphql/%s/%s?variables=%s&features=%s" % (
|
|
169
156
|
query_id,
|
|
170
157
|
operation_name,
|
|
171
158
|
urllib.parse.quote(json.dumps(variables, separators=(",", ":"))),
|
|
172
|
-
urllib.parse.quote(json.dumps(
|
|
159
|
+
urllib.parse.quote(json.dumps(compact_features, separators=(",", ":"))),
|
|
173
160
|
)
|
|
174
161
|
if field_toggles:
|
|
175
162
|
url += "&fieldToggles=%s" % urllib.parse.quote(
|
|
@@ -220,11 +207,9 @@ def _update_features_from_html(html):
|
|
|
220
207
|
|
|
221
208
|
Twitter embeds feature switch config in inline scripts on the homepage.
|
|
222
209
|
We parse these to keep FEATURES in sync with the current frontend.
|
|
210
|
+
Only UPDATES existing keys — never adds new ones to avoid URL bloat.
|
|
223
211
|
"""
|
|
224
212
|
try:
|
|
225
|
-
# Look for feature flags in inline script content
|
|
226
|
-
# Pattern: "featureSwitch":{"...":{"value":true/false},...}
|
|
227
|
-
# Also try: features:{key:!0, key2:!1, ...} in JS bundles
|
|
228
213
|
feature_pattern = re.compile(
|
|
229
214
|
r'"([a-z][a-z0-9_]+)":\s*\{\s*"value"\s*:\s*(true|false)',
|
|
230
215
|
re.IGNORECASE,
|
|
@@ -233,8 +218,10 @@ def _update_features_from_html(html):
|
|
|
233
218
|
for match in feature_pattern.finditer(html):
|
|
234
219
|
key = match.group(1)
|
|
235
220
|
value = match.group(2).lower() == "true"
|
|
236
|
-
# Only update keys
|
|
237
|
-
|
|
221
|
+
# Only update keys already in FEATURES — never add new ones
|
|
222
|
+
# Adding new keys inflates URL length, causing 414/431 errors
|
|
223
|
+
if key in FEATURES and FEATURES[key] != value:
|
|
224
|
+
logger.debug("Feature flag updated: %s = %s -> %s", key, FEATURES[key], value)
|
|
238
225
|
FEATURES[key] = value
|
|
239
226
|
found += 1
|
|
240
227
|
if found:
|
|
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
|