twitter-openapi-python 0.0.45__tar.gz → 0.1.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 (30) hide show
  1. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/PKG-INFO +2 -2
  2. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/pyproject.toml +2 -2
  3. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/pyproject.toml.orig +2 -2
  4. twitter_openapi_python-0.1.1/twitter_openapi_python/api/post_api.py +327 -0
  5. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/api/tweet_api.py +231 -21
  6. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/api/user_api.py +55 -1
  7. twitter_openapi_python-0.1.1/twitter_openapi_python/api/user_list_api.py +304 -0
  8. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/client.py +1 -1
  9. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/models/__init__.py +1 -0
  10. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/models/timeline.py +7 -2
  11. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/utils/__init__.py +7 -0
  12. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/utils/api.py +70 -9
  13. twitter_openapi_python-0.0.45/twitter_openapi_python/api/post_api.py +0 -166
  14. twitter_openapi_python-0.0.45/twitter_openapi_python/api/user_list_api.py +0 -171
  15. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/LICENSE +0 -0
  16. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/LICENSE.AGPL +0 -0
  17. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/README.md +0 -0
  18. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/__init__.py +0 -0
  19. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/api/__init__.py +0 -0
  20. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/api/default_api.py +0 -0
  21. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/api/initial_state_api.py +0 -0
  22. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/api/users_api.py +0 -0
  23. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/api/v11_get_api.py +0 -0
  24. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/api/v11_post_api.py +0 -0
  25. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/models/base.py +0 -0
  26. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/models/header.py +0 -0
  27. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/models/initial_state.py +0 -0
  28. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/models/response.py +0 -0
  29. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/py.typed +0 -0
  30. {twitter_openapi_python-0.0.45 → twitter_openapi_python-0.1.1}/twitter_openapi_python/tid.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: twitter_openapi_python
3
- Version: 0.0.45
3
+ Version: 0.1.1
4
4
  Summary: Twitter OpenAPI
5
5
  Keywords: twitter,api,python,scraper
6
6
  Author: fa0311
@@ -8,7 +8,7 @@ Author-email: fa0311 <yuki@yuki0311.com>
8
8
  License-Expression: LicenseRef-Custom OR AGPL-3.0-or-later
9
9
  License-File: LICENSE
10
10
  License-File: LICENSE.AGPL
11
- Requires-Dist: twitter-openapi-python-generated==0.0.35
11
+ Requires-Dist: twitter-openapi-python-generated==0.1.1
12
12
  Requires-Dist: pydantic>=2.6
13
13
  Requires-Dist: requests>=2.31.0,<3.0.0
14
14
  Requires-Dist: urllib3>=2.1.0,<3.0.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "twitter_openapi_python"
3
- version = "0.0.45"
3
+ version = "0.1.1"
4
4
  description = "Twitter OpenAPI"
5
5
  readme = "README.md"
6
6
  license = "LicenseRef-Custom OR AGPL-3.0-or-later"
@@ -16,7 +16,7 @@ keywords = [
16
16
  ]
17
17
  requires-python = ">=3.10"
18
18
  dependencies = [
19
- "twitter_openapi_python_generated==0.0.35",
19
+ "twitter_openapi_python_generated==0.1.1",
20
20
  "pydantic>=2.6",
21
21
  "requests>=2.31.0,<3.0.0",
22
22
  "urllib3>=2.1.0,<3.0.0",
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "twitter_openapi_python"
3
- version = "0.0.45"
3
+ version = "0.1.1"
4
4
  description = "Twitter OpenAPI"
5
5
  authors = [{ name = "fa0311", email = "yuki@yuki0311.com" }]
6
6
  readme = "README.md"
@@ -9,7 +9,7 @@ license-files = ["LICENSE", "LICENSE.AGPL"]
9
9
  keywords = ["twitter", "api", "python", "scraper"]
10
10
  requires-python = ">=3.10"
11
11
  dependencies = [
12
- "twitter_openapi_python_generated==0.0.35",
12
+ "twitter_openapi_python_generated==0.1.1",
13
13
  "pydantic>=2.6",
14
14
  "requests>=2.31.0,<3.0.0",
15
15
  "urllib3>=2.1.0,<3.0.0",
@@ -0,0 +1,327 @@
1
+ from typing import Any, Optional, TypeVar
2
+
3
+ import twitter_openapi_python_generated as twitter
4
+ import twitter_openapi_python_generated.models as models
5
+ from x_client_transaction import ClientTransaction
6
+
7
+ from twitter_openapi_python.models import TwitterApiUtilsResponse
8
+ from twitter_openapi_python.utils import build_response, non_nullable
9
+ from twitter_openapi_python.utils.api import get_headers
10
+
11
+ T = TypeVar("T")
12
+ ResponseType = TwitterApiUtilsResponse[T]
13
+ ParamType = dict[str, Any]
14
+
15
+
16
+ class PostApiUtils:
17
+ api: twitter.PostApi
18
+ flag: ParamType
19
+
20
+ def __init__(self, api: twitter.PostApi, flag: ParamType, ct: ClientTransaction):
21
+ self.api = api
22
+ self.flag = flag
23
+ self.ct = ct
24
+
25
+ def post_create_tweet(
26
+ self,
27
+ tweet_text: str,
28
+ media_ids: Optional[list[str]] = None,
29
+ tagged_users: Optional[list[list[str]]] = None,
30
+ in_reply_to_tweet_id: Optional[str] = None,
31
+ attachment_url: Optional[str] = None,
32
+ conversation_control: Optional[str] = None,
33
+ ) -> ResponseType[models.CreateTweetResponse]:
34
+ variables = non_nullable(
35
+ twitter.PostCreateTweetRequestVariables.from_dict(self.flag["CreateTweet"]["variables"])
36
+ )
37
+ features = non_nullable(twitter.PostCreateTweetRequestFeatures.from_dict(self.flag["CreateTweet"]["features"]))
38
+ variables.tweet_text = tweet_text
39
+ if media_ids:
40
+ tagged_or = tagged_users or []
41
+ variables.media.media_entities = [
42
+ twitter.PostCreateTweetRequestVariablesMediaMediaEntitiesInner(
43
+ media_id=media_id,
44
+ tagged_users=tagged_or[idx] if len(tagged_or) > idx else [],
45
+ )
46
+ for idx, media_id in enumerate(media_ids)
47
+ ]
48
+ variables.attachment_url = attachment_url
49
+ if conversation_control:
50
+ variables.conversation_control = twitter.PostCreateTweetRequestVariablesConversationControl(
51
+ mode=conversation_control
52
+ )
53
+
54
+ if in_reply_to_tweet_id:
55
+ variables.reply = twitter.PostCreateTweetRequestVariablesReply(
56
+ exclude_reply_user_ids=[],
57
+ in_reply_to_tweet_id=in_reply_to_tweet_id,
58
+ )
59
+
60
+ res = self.api.post_create_tweet_with_http_info(
61
+ path_query_id=self.flag["CreateTweet"]["queryId"],
62
+ post_create_tweet_request=twitter.PostCreateTweetRequest(
63
+ queryId=self.flag["CreateTweet"]["queryId"],
64
+ variables=variables,
65
+ features=features,
66
+ ),
67
+ _headers=get_headers(self.flag["CreateTweet"], self.ct),
68
+ )
69
+ return build_response(res, res.data)
70
+
71
+ def post_delete_tweet(
72
+ self,
73
+ tweet_id: str,
74
+ ) -> ResponseType[models.DeleteTweetResponse]:
75
+ variables = non_nullable(
76
+ twitter.PostCreateRetweetRequestVariables.from_dict(self.flag["DeleteTweet"]["variables"])
77
+ )
78
+ variables.tweet_id = tweet_id
79
+
80
+ res = self.api.post_delete_tweet_with_http_info(
81
+ path_query_id=self.flag["DeleteTweet"]["queryId"],
82
+ post_delete_tweet_request=twitter.PostDeleteTweetRequest(
83
+ queryId=self.flag["DeleteTweet"]["queryId"],
84
+ variables=variables,
85
+ ),
86
+ _headers=get_headers(self.flag["DeleteTweet"], self.ct),
87
+ )
88
+ return build_response(res, res.data)
89
+
90
+ def post_create_retweet(
91
+ self,
92
+ tweet_id: str,
93
+ ) -> ResponseType[models.CreateRetweetResponse]:
94
+ variables = non_nullable(
95
+ twitter.PostCreateRetweetRequestVariables.from_dict(self.flag["CreateRetweet"]["variables"])
96
+ )
97
+ variables.tweet_id = tweet_id
98
+
99
+ res = self.api.post_create_retweet_with_http_info(
100
+ path_query_id=self.flag["CreateRetweet"]["queryId"],
101
+ post_create_retweet_request=twitter.PostCreateRetweetRequest(
102
+ queryId=self.flag["CreateRetweet"]["queryId"],
103
+ variables=variables,
104
+ ),
105
+ _headers=get_headers(self.flag["CreateRetweet"], self.ct),
106
+ )
107
+ return build_response(res, res.data)
108
+
109
+ def post_delete_retweet(
110
+ self,
111
+ source_tweet_id: str,
112
+ ) -> ResponseType[models.DeleteRetweetResponse]:
113
+ variables = non_nullable(
114
+ twitter.PostDeleteRetweetRequestVariables.from_dict(self.flag["DeleteRetweet"]["variables"])
115
+ )
116
+ variables.source_tweet_id = source_tweet_id
117
+
118
+ res = self.api.post_delete_retweet_with_http_info(
119
+ path_query_id=self.flag["DeleteRetweet"]["queryId"],
120
+ post_delete_retweet_request=twitter.PostDeleteRetweetRequest(
121
+ queryId=self.flag["DeleteRetweet"]["queryId"],
122
+ variables=variables,
123
+ ),
124
+ _headers=get_headers(self.flag["DeleteRetweet"], self.ct),
125
+ )
126
+ return build_response(res, res.data)
127
+
128
+ # postFavoriteTweet
129
+ def post_favorite_tweet(
130
+ self,
131
+ tweet_id: str,
132
+ ) -> ResponseType[models.FavoriteTweetResponse]:
133
+ variables = non_nullable(
134
+ twitter.PostCreateBookmarkRequestVariables.from_dict(self.flag["FavoriteTweet"]["variables"])
135
+ )
136
+ variables.tweet_id = tweet_id
137
+
138
+ res = self.api.post_favorite_tweet_with_http_info(
139
+ path_query_id=self.flag["FavoriteTweet"]["queryId"],
140
+ post_favorite_tweet_request=twitter.PostFavoriteTweetRequest(
141
+ queryId=self.flag["FavoriteTweet"]["queryId"],
142
+ variables=variables,
143
+ ),
144
+ _headers=get_headers(self.flag["FavoriteTweet"], self.ct),
145
+ )
146
+ return build_response(res, res.data)
147
+
148
+ # postUnfavoriteTweet
149
+ def post_unfavorite_tweet(
150
+ self,
151
+ tweet_id: str,
152
+ ) -> ResponseType[models.UnfavoriteTweetResponse]:
153
+ variables = non_nullable(
154
+ twitter.PostCreateRetweetRequestVariables.from_dict(self.flag["UnfavoriteTweet"]["variables"])
155
+ )
156
+ variables.tweet_id = tweet_id
157
+
158
+ res = self.api.post_unfavorite_tweet_with_http_info(
159
+ path_query_id=self.flag["UnfavoriteTweet"]["queryId"],
160
+ post_unfavorite_tweet_request=twitter.PostUnfavoriteTweetRequest(
161
+ queryId=self.flag["UnfavoriteTweet"]["queryId"],
162
+ variables=variables,
163
+ ),
164
+ _headers=get_headers(self.flag["UnfavoriteTweet"], self.ct),
165
+ )
166
+ return build_response(res, res.data)
167
+
168
+ def post_create_bookmark(
169
+ self,
170
+ tweet_id: str,
171
+ ) -> ResponseType[models.CreateBookmarkResponse]:
172
+ variables = non_nullable(
173
+ twitter.PostCreateBookmarkRequestVariables.from_dict(self.flag["CreateBookmark"]["variables"])
174
+ )
175
+ variables.tweet_id = tweet_id
176
+
177
+ res = self.api.post_create_bookmark_with_http_info(
178
+ path_query_id=self.flag["CreateBookmark"]["queryId"],
179
+ post_create_bookmark_request=twitter.PostCreateBookmarkRequest(
180
+ queryId=self.flag["CreateBookmark"]["queryId"],
181
+ variables=variables,
182
+ ),
183
+ _headers=get_headers(self.flag["CreateBookmark"], self.ct),
184
+ )
185
+ return build_response(res, res.data)
186
+
187
+ def post_delete_bookmark(
188
+ self,
189
+ tweet_id: str,
190
+ ) -> ResponseType[models.DeleteBookmarkResponse]:
191
+ variables = non_nullable(
192
+ twitter.PostCreateBookmarkRequestVariables.from_dict(self.flag["DeleteBookmark"]["variables"])
193
+ )
194
+ variables.tweet_id = tweet_id
195
+
196
+ res = self.api.post_delete_bookmark_with_http_info(
197
+ path_query_id=self.flag["DeleteBookmark"]["queryId"],
198
+ post_delete_bookmark_request=twitter.PostDeleteBookmarkRequest(
199
+ queryId=self.flag["DeleteBookmark"]["queryId"],
200
+ variables=variables,
201
+ ),
202
+ _headers=get_headers(self.flag["DeleteBookmark"], self.ct),
203
+ )
204
+ return build_response(res, res.data)
205
+
206
+ def post_create_list(
207
+ self,
208
+ name: str,
209
+ description: str = "",
210
+ is_private: bool = False,
211
+ ) -> ResponseType[models.ListResponse]:
212
+ variables = non_nullable(twitter.PostCreateListRequestVariables.from_dict(self.flag["CreateList"]["variables"]))
213
+ features = non_nullable(twitter.PostCreateListRequestFeatures.from_dict(self.flag["CreateList"]["features"]))
214
+ variables.name = name
215
+ variables.description = description
216
+ variables.is_private = is_private
217
+
218
+ res = self.api.post_create_list_with_http_info(
219
+ path_query_id=self.flag["CreateList"]["queryId"],
220
+ post_create_list_request=twitter.PostCreateListRequest(
221
+ queryId=self.flag["CreateList"]["queryId"],
222
+ variables=variables,
223
+ features=features,
224
+ ),
225
+ _headers=get_headers(self.flag["CreateList"], self.ct),
226
+ )
227
+ return build_response(res, res.data)
228
+
229
+ def post_delete_list(
230
+ self,
231
+ list_id: str,
232
+ ) -> ResponseType[models.DeleteListResponse]:
233
+ variables = non_nullable(twitter.PostDeleteListRequestVariables.from_dict(self.flag["DeleteList"]["variables"]))
234
+ variables.list_id = list_id
235
+
236
+ res = self.api.post_delete_list_with_http_info(
237
+ path_query_id=self.flag["DeleteList"]["queryId"],
238
+ post_delete_list_request=twitter.PostDeleteListRequest(
239
+ queryId=self.flag["DeleteList"]["queryId"],
240
+ variables=variables,
241
+ ),
242
+ _headers=get_headers(self.flag["DeleteList"], self.ct),
243
+ )
244
+ return build_response(res, res.data)
245
+
246
+ def post_list_add_member(
247
+ self,
248
+ list_id: str,
249
+ user_id: str,
250
+ ) -> ResponseType[models.ListResponse]:
251
+ variables = non_nullable(
252
+ twitter.PostListAddMemberRequestVariables.from_dict(self.flag["ListAddMember"]["variables"])
253
+ )
254
+ features = non_nullable(twitter.PostCreateListRequestFeatures.from_dict(self.flag["ListAddMember"]["features"]))
255
+ variables.list_id = list_id
256
+ variables.user_id = user_id
257
+
258
+ res = self.api.post_list_add_member_with_http_info(
259
+ path_query_id=self.flag["ListAddMember"]["queryId"],
260
+ post_list_add_member_request=twitter.PostListAddMemberRequest(
261
+ queryId=self.flag["ListAddMember"]["queryId"],
262
+ variables=variables,
263
+ features=features,
264
+ ),
265
+ _headers=get_headers(self.flag["ListAddMember"], self.ct),
266
+ )
267
+ return build_response(res, res.data)
268
+
269
+ def post_list_remove_member(
270
+ self,
271
+ list_id: str,
272
+ user_id: str,
273
+ ) -> ResponseType[models.ListResponse]:
274
+ variables = non_nullable(
275
+ twitter.PostListAddMemberRequestVariables.from_dict(self.flag["ListRemoveMember"]["variables"])
276
+ )
277
+ features = non_nullable(
278
+ twitter.PostCreateListRequestFeatures.from_dict(self.flag["ListRemoveMember"]["features"])
279
+ )
280
+ variables.list_id = list_id
281
+ variables.user_id = user_id
282
+
283
+ res = self.api.post_list_remove_member_with_http_info(
284
+ path_query_id=self.flag["ListRemoveMember"]["queryId"],
285
+ post_list_remove_member_request=twitter.PostListRemoveMemberRequest(
286
+ queryId=self.flag["ListRemoveMember"]["queryId"],
287
+ variables=variables,
288
+ features=features,
289
+ ),
290
+ _headers=get_headers(self.flag["ListRemoveMember"], self.ct),
291
+ )
292
+ return build_response(res, res.data)
293
+
294
+ def post_create_draft_tweet(
295
+ self,
296
+ status: str,
297
+ ) -> ResponseType[models.CreateDraftTweetResponse]:
298
+ variables = non_nullable(
299
+ twitter.PostCreateDraftTweetRequestVariables.from_dict(self.flag["CreateDraftTweet"]["variables"])
300
+ )
301
+ variables.post_tweet_request.status = status
302
+
303
+ res = self.api.post_create_draft_tweet_with_http_info(
304
+ path_query_id=self.flag["CreateDraftTweet"]["queryId"],
305
+ post_create_draft_tweet_request=twitter.PostCreateDraftTweetRequest(
306
+ queryId=self.flag["CreateDraftTweet"]["queryId"],
307
+ variables=variables,
308
+ ),
309
+ _headers=get_headers(self.flag["CreateDraftTweet"], self.ct),
310
+ )
311
+ return build_response(res, res.data)
312
+
313
+ def post_delete_draft_tweets(
314
+ self,
315
+ draft_tweet_ids: list[str],
316
+ ) -> ResponseType[models.DeleteDraftTweetsResponse]:
317
+ variables = twitter.PostDeleteDraftTweetsRequestVariables(draft_tweet_ids=draft_tweet_ids)
318
+
319
+ res = self.api.post_delete_draft_tweets_with_http_info(
320
+ path_query_id=self.flag["DeleteDraftTweets"]["queryId"],
321
+ post_delete_draft_tweets_request=twitter.PostDeleteDraftTweetsRequest(
322
+ queryId=self.flag["DeleteDraftTweets"]["queryId"],
323
+ variables=variables,
324
+ ),
325
+ _headers=get_headers(self.flag["DeleteDraftTweets"], self.ct),
326
+ )
327
+ return build_response(res, res.data)
@@ -5,22 +5,29 @@ import twitter_openapi_python_generated.models as models
5
5
  from x_client_transaction import ClientTransaction
6
6
 
7
7
  from twitter_openapi_python.models import (
8
- ApiUtilsRaw,
8
+ CommunityApiUtilsData,
9
9
  TimelineApiUtilsResponse,
10
10
  TweetApiUtilsData,
11
11
  TwitterApiUtilsResponse,
12
+ UserApiUtilsData,
12
13
  )
13
14
  from twitter_openapi_python.utils import (
14
- build_response,
15
- entries_cursor,
15
+ community_entries_converter,
16
16
  error_check,
17
- get_kwargs,
18
- instruction_to_entry,
17
+ notification_entries_converter,
18
+ timeline_request,
19
+ trend_entries_converter,
19
20
  tweet_entries_converter,
21
+ user_entries_converter,
22
+ user_result_converter,
20
23
  )
21
24
 
22
25
  T = TypeVar("T")
23
26
  ResponseType = TwitterApiUtilsResponse[TimelineApiUtilsResponse[TweetApiUtilsData]]
27
+ UserResponseType = TwitterApiUtilsResponse[TimelineApiUtilsResponse[UserApiUtilsData]]
28
+ TrendResponseType = TwitterApiUtilsResponse[TimelineApiUtilsResponse[models.TimelineTrend]]
29
+ NotificationResponseType = TwitterApiUtilsResponse[TimelineApiUtilsResponse[models.TimelineNotification]]
30
+ CommunityResponseType = TwitterApiUtilsResponse[TimelineApiUtilsResponse[CommunityApiUtilsData]]
24
31
  ApiFnType = Callable[..., twitter.ApiResponse[T]]
25
32
  ParamType = dict[str, Any]
26
33
 
@@ -41,21 +48,7 @@ class TweetApiUtils:
41
48
  key: str,
42
49
  param: ParamType,
43
50
  ) -> ResponseType:
44
- args = get_kwargs(flag=self.flag[key], additional=param, ct=self.ct)
45
- res = apiFn(**args)
46
- instruction = convertFn(res.data)
47
- entry = instruction_to_entry(instruction)
48
- tweet_list = tweet_entries_converter(entry)
49
- raw = ApiUtilsRaw(
50
- instruction=instruction,
51
- entry=entry,
52
- )
53
- data = TimelineApiUtilsResponse[TweetApiUtilsData](
54
- raw=raw,
55
- cursor=entries_cursor(entry),
56
- data=tweet_list,
57
- )
58
- return build_response(res, data)
51
+ return timeline_request(apiFn, self.flag[key], self.ct, convertFn, param, tweet_entries_converter)
59
52
 
60
53
  def get_tweet_detail(
61
54
  self,
@@ -100,7 +93,9 @@ class TweetApiUtils:
100
93
 
101
94
  response = self.request(
102
95
  apiFn=self.api.get_search_timeline_with_http_info,
103
- convertFn=lambda e: error_check(e.data.search_by_raw_query, e.errors).search_timeline.timeline.instructions,
96
+ convertFn=lambda e: error_check(
97
+ error_check(e.data.search_by_raw_query, e.errors).search_timeline.timeline, e.errors
98
+ ).instructions,
104
99
  key="SearchTimeline",
105
100
  param=param,
106
101
  )
@@ -426,3 +421,218 @@ class TweetApiUtils:
426
421
  param=param,
427
422
  )
428
423
  return response
424
+
425
+ def get_user_highlights_tweets(
426
+ self,
427
+ user_id: str,
428
+ cursor: Optional[str] = None,
429
+ count: Optional[int] = None,
430
+ extra_param: Optional[ParamType] = None,
431
+ ) -> ResponseType:
432
+ param: ParamType = {"userId": user_id}
433
+ if cursor is not None:
434
+ param["cursor"] = cursor
435
+ if count is not None:
436
+ param["count"] = count
437
+ if extra_param is not None:
438
+ param.update(extra_param)
439
+
440
+ response = self.request(
441
+ apiFn=self.api.get_user_highlights_tweets_with_http_info,
442
+ convertFn=lambda e: error_check(e.data.user, e.errors).result.timeline.timeline.instructions,
443
+ key="UserHighlightsTweets",
444
+ param=param,
445
+ )
446
+ return response
447
+
448
+ def get_user_reposts_timeline(
449
+ self,
450
+ user_id: str,
451
+ cursor: Optional[str] = None,
452
+ count: Optional[int] = None,
453
+ extra_param: Optional[ParamType] = None,
454
+ ) -> ResponseType:
455
+ param: ParamType = {"userId": user_id}
456
+ if cursor is not None:
457
+ param["cursor"] = cursor
458
+ if count is not None:
459
+ param["count"] = count
460
+ if extra_param is not None:
461
+ param.update(extra_param)
462
+
463
+ response = self.request(
464
+ apiFn=self.api.get_user_reposts_timeline_with_http_info,
465
+ convertFn=lambda e: error_check(
466
+ error_check(e.data.user, e.errors).result.timeline.timeline, e.errors
467
+ ).instructions,
468
+ key="UserRepostsTimeline",
469
+ param=param,
470
+ )
471
+ return response
472
+
473
+ def get_user_super_follow_tweets(
474
+ self,
475
+ user_id: str,
476
+ cursor: Optional[str] = None,
477
+ count: Optional[int] = None,
478
+ extra_param: Optional[ParamType] = None,
479
+ ) -> ResponseType:
480
+ """Subscriber-only posts; without a subscription the timeline only carries a TimelineMessagePrompt."""
481
+ param: ParamType = {"userId": user_id}
482
+ if cursor is not None:
483
+ param["cursor"] = cursor
484
+ if count is not None:
485
+ param["count"] = count
486
+ if extra_param is not None:
487
+ param.update(extra_param)
488
+
489
+ response = self.request(
490
+ apiFn=self.api.get_user_super_follow_tweets_with_http_info,
491
+ convertFn=lambda e: error_check(
492
+ error_check(e.data.user, e.errors).result.timeline.timeline, e.errors
493
+ ).instructions,
494
+ key="UserSuperFollowTweets",
495
+ param=param,
496
+ )
497
+ return response
498
+
499
+ def get_explore_page(
500
+ self,
501
+ cursor: Optional[str] = None,
502
+ extra_param: Optional[ParamType] = None,
503
+ ) -> TrendResponseType:
504
+ """Trends of the first explore tab; the other tabs are GenericTimelineById timelines."""
505
+ param: ParamType = {}
506
+ if cursor is not None:
507
+ param["cursor"] = cursor
508
+ if extra_param is not None:
509
+ param.update(extra_param)
510
+
511
+ return timeline_request(
512
+ self.api.get_explore_page_with_http_info,
513
+ self.flag["ExplorePage"],
514
+ self.ct,
515
+ lambda e: error_check(e.data.explore_page.body.initial_timeline.timeline.timeline, e.errors).instructions,
516
+ param,
517
+ trend_entries_converter,
518
+ )
519
+
520
+ def get_generic_timeline_by_id(
521
+ self,
522
+ timeline_id: str,
523
+ cursor: Optional[str] = None,
524
+ count: Optional[int] = None,
525
+ extra_param: Optional[ParamType] = None,
526
+ ) -> TrendResponseType:
527
+ """Explore tab timelines (trending, news, sports, ...)."""
528
+ param: ParamType = {"timelineId": timeline_id}
529
+ if cursor is not None:
530
+ param["cursor"] = cursor
531
+ if count is not None:
532
+ param["count"] = count
533
+ if extra_param is not None:
534
+ param.update(extra_param)
535
+
536
+ return timeline_request(
537
+ self.api.get_generic_timeline_by_id_with_http_info,
538
+ self.flag["GenericTimelineById"],
539
+ self.ct,
540
+ lambda e: error_check(e.data.timeline.timeline, e.errors).instructions,
541
+ param,
542
+ trend_entries_converter,
543
+ )
544
+
545
+ def get_notifications_timeline(
546
+ self,
547
+ timeline_type: Optional[Literal["All", "Verified", "Mentions"]] = None,
548
+ cursor: Optional[str] = None,
549
+ count: Optional[int] = None,
550
+ extra_param: Optional[ParamType] = None,
551
+ ) -> NotificationResponseType:
552
+ """Notification items only; the tweets of the Mentions tab are in data.raw.entry (tweet_entries_converter)."""
553
+ param: ParamType = {}
554
+ if timeline_type is not None:
555
+ param["timeline_type"] = timeline_type
556
+ if cursor is not None:
557
+ param["cursor"] = cursor
558
+ if count is not None:
559
+ param["count"] = count
560
+ if extra_param is not None:
561
+ param.update(extra_param)
562
+
563
+ return timeline_request(
564
+ self.api.get_notifications_timeline_with_http_info,
565
+ self.flag["NotificationsTimeline"],
566
+ self.ct,
567
+ lambda e: error_check(
568
+ e.data.viewer_v2.user_results.result.notification_timeline.timeline, e.errors
569
+ ).instructions,
570
+ param,
571
+ notification_entries_converter,
572
+ )
573
+
574
+ def get_community_discovery_timeline(
575
+ self,
576
+ cursor: Optional[str] = None,
577
+ count: Optional[int] = None,
578
+ extra_param: Optional[ParamType] = None,
579
+ ) -> CommunityResponseType:
580
+ param: ParamType = {}
581
+ if cursor is not None:
582
+ param["cursor"] = cursor
583
+ if count is not None:
584
+ param["count"] = count
585
+ if extra_param is not None:
586
+ param.update(extra_param)
587
+
588
+ return timeline_request(
589
+ self.api.get_community_discovery_timeline_with_http_info,
590
+ self.flag["CommunityDiscoveryTimeline"],
591
+ self.ct,
592
+ lambda e: error_check(e.data.viewer.community_discovery_timeline.timeline, e.errors).instructions,
593
+ param,
594
+ community_entries_converter,
595
+ )
596
+
597
+ def get_community_about_timeline(
598
+ self,
599
+ community_id: str,
600
+ extra_param: Optional[ParamType] = None,
601
+ ) -> UserResponseType:
602
+ """Moderators and members of a community."""
603
+ param: ParamType = {"communityId": community_id}
604
+ if extra_param is not None:
605
+ param.update(extra_param)
606
+
607
+ return timeline_request(
608
+ self.api.get_community_about_timeline_with_http_info,
609
+ self.flag["CommunityAboutTimeline"],
610
+ self.ct,
611
+ lambda e: error_check(e.data.community_results.result.about_timeline.timeline, e.errors).instructions,
612
+ param,
613
+ lambda entry: user_result_converter(user_entries_converter(entry)),
614
+ )
615
+
616
+ def get_connect_tab_timeline(
617
+ self,
618
+ cursor: Optional[str] = None,
619
+ count: Optional[int] = None,
620
+ extra_param: Optional[ParamType] = None,
621
+ ) -> UserResponseType:
622
+ """Who to follow."""
623
+ param: ParamType = {}
624
+ if cursor is not None:
625
+ param["cursor"] = cursor
626
+ if count is not None:
627
+ param["count"] = count
628
+ if extra_param is not None:
629
+ param.update(extra_param)
630
+
631
+ return timeline_request(
632
+ self.api.get_connect_tab_timeline_with_http_info,
633
+ self.flag["ConnectTabTimeline"],
634
+ self.ct,
635
+ lambda e: error_check(e.data.connect_tab_timeline.timeline, e.errors).instructions,
636
+ param,
637
+ lambda entry: user_result_converter(user_entries_converter(entry)),
638
+ )