twitter-openapi-python 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl
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_openapi_python/api/__init__.py +2 -0
- twitter_openapi_python/api/birdwatch_api.py +116 -0
- twitter_openapi_python/api/community_api.py +149 -0
- twitter_openapi_python/api/default_api.py +75 -0
- twitter_openapi_python/api/post_api.py +161 -0
- twitter_openapi_python/api/tweet_api.py +275 -21
- twitter_openapi_python/api/user_api.py +55 -1
- twitter_openapi_python/api/user_list_api.py +225 -22
- twitter_openapi_python/api/users_api.py +18 -0
- twitter_openapi_python/client.py +9 -1
- twitter_openapi_python/models/__init__.py +1 -0
- twitter_openapi_python/models/timeline.py +5 -0
- twitter_openapi_python/utils/__init__.py +7 -0
- twitter_openapi_python/utils/api.py +69 -8
- {twitter_openapi_python-0.1.0.dist-info → twitter_openapi_python-0.1.2.dist-info}/METADATA +2 -2
- twitter_openapi_python-0.1.2.dist-info/RECORD +29 -0
- twitter_openapi_python-0.1.0.dist-info/RECORD +0 -27
- {twitter_openapi_python-0.1.0.dist-info → twitter_openapi_python-0.1.2.dist-info}/WHEEL +0 -0
- {twitter_openapi_python-0.1.0.dist-info → twitter_openapi_python-0.1.2.dist-info}/licenses/LICENSE +0 -0
- {twitter_openapi_python-0.1.0.dist-info → twitter_openapi_python-0.1.2.dist-info}/licenses/LICENSE.AGPL +0 -0
|
@@ -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
|
-
|
|
8
|
+
CommunityApiUtilsData,
|
|
9
9
|
TimelineApiUtilsResponse,
|
|
10
10
|
TweetApiUtilsData,
|
|
11
11
|
TwitterApiUtilsResponse,
|
|
12
|
+
UserApiUtilsData,
|
|
12
13
|
)
|
|
13
14
|
from twitter_openapi_python.utils import (
|
|
14
|
-
|
|
15
|
-
entries_cursor,
|
|
15
|
+
community_entries_converter,
|
|
16
16
|
error_check,
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
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(
|
|
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,262 @@ 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
|
+
)
|
|
639
|
+
|
|
640
|
+
def get_bookmark_search_timeline(
|
|
641
|
+
self,
|
|
642
|
+
raw_query: str,
|
|
643
|
+
cursor: Optional[str] = None,
|
|
644
|
+
count: Optional[int] = None,
|
|
645
|
+
extra_param: Optional[ParamType] = None,
|
|
646
|
+
) -> ResponseType:
|
|
647
|
+
"""Search the account's bookmarks."""
|
|
648
|
+
param: ParamType = {"rawQuery": raw_query}
|
|
649
|
+
if cursor is not None:
|
|
650
|
+
param["cursor"] = cursor
|
|
651
|
+
if count is not None:
|
|
652
|
+
param["count"] = count
|
|
653
|
+
if extra_param is not None:
|
|
654
|
+
param.update(extra_param)
|
|
655
|
+
|
|
656
|
+
response = self.request(
|
|
657
|
+
apiFn=self.api.get_bookmark_search_timeline_with_http_info,
|
|
658
|
+
convertFn=lambda e: error_check(
|
|
659
|
+
e.data.search_by_raw_query.bookmarks_search_timeline.timeline, e.errors
|
|
660
|
+
).instructions,
|
|
661
|
+
key="BookmarkSearchTimeline",
|
|
662
|
+
param=param,
|
|
663
|
+
)
|
|
664
|
+
return response
|
|
665
|
+
|
|
666
|
+
def get_explore_sidebar(
|
|
667
|
+
self,
|
|
668
|
+
extra_param: Optional[ParamType] = None,
|
|
669
|
+
) -> TrendResponseType:
|
|
670
|
+
"""Trends of the explore sidebar."""
|
|
671
|
+
param: ParamType = {}
|
|
672
|
+
if extra_param is not None:
|
|
673
|
+
param.update(extra_param)
|
|
674
|
+
|
|
675
|
+
return timeline_request(
|
|
676
|
+
self.api.get_explore_sidebar_with_http_info,
|
|
677
|
+
self.flag["ExploreSidebar"],
|
|
678
|
+
self.ct,
|
|
679
|
+
lambda e: error_check(e.data.explore_sidebar.timeline, e.errors).instructions,
|
|
680
|
+
param,
|
|
681
|
+
trend_entries_converter,
|
|
682
|
+
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any, Callable, Optional, TypeVar
|
|
1
|
+
from typing import Any, Callable, Dict, List, Optional, TypeVar
|
|
2
2
|
|
|
3
3
|
import twitter_openapi_python_generated as twitter
|
|
4
4
|
import twitter_openapi_python_generated.models as models
|
|
@@ -7,6 +7,7 @@ from x_client_transaction import ClientTransaction
|
|
|
7
7
|
from twitter_openapi_python.models import TwitterApiUtilsResponse, UserApiUtilsData
|
|
8
8
|
from twitter_openapi_python.utils import (
|
|
9
9
|
build_response,
|
|
10
|
+
data_request,
|
|
10
11
|
error_check,
|
|
11
12
|
get_kwargs,
|
|
12
13
|
user_or_null_converter,
|
|
@@ -78,3 +79,56 @@ class UserApiUtils:
|
|
|
78
79
|
key="UserByRestId",
|
|
79
80
|
param=param,
|
|
80
81
|
)
|
|
82
|
+
|
|
83
|
+
def get_viewer_badge_counts(
|
|
84
|
+
self,
|
|
85
|
+
extra_param: Optional[ParamType] = None,
|
|
86
|
+
) -> TwitterApiUtilsResponse[models.BadgeCounts]:
|
|
87
|
+
"""Unread counts (notifications, DMs, XChat) of the authenticated account."""
|
|
88
|
+
param: ParamType = {}
|
|
89
|
+
if extra_param is not None:
|
|
90
|
+
param.update(extra_param)
|
|
91
|
+
return data_request(
|
|
92
|
+
self.api.get_viewer_badge_counts_with_http_info,
|
|
93
|
+
self.flag["ViewerBadgeCounts"],
|
|
94
|
+
self.ct,
|
|
95
|
+
lambda e: error_check(e.data, e.errors).viewer_v2.user_results.result.badge_counts,
|
|
96
|
+
param,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
def get_fetch_draft_tweets(
|
|
100
|
+
self,
|
|
101
|
+
ascending: Optional[bool] = None,
|
|
102
|
+
extra_param: Optional[ParamType] = None,
|
|
103
|
+
) -> TwitterApiUtilsResponse[List[models.DraftTweet]]:
|
|
104
|
+
param: ParamType = {}
|
|
105
|
+
if ascending is not None:
|
|
106
|
+
param["ascending"] = ascending
|
|
107
|
+
if extra_param is not None:
|
|
108
|
+
param.update(extra_param)
|
|
109
|
+
return data_request(
|
|
110
|
+
self.api.get_fetch_draft_tweets_with_http_info,
|
|
111
|
+
self.flag["FetchDraftTweets"],
|
|
112
|
+
self.ct,
|
|
113
|
+
lambda e: error_check(e.data, e.errors).viewer.draft_list.response_data,
|
|
114
|
+
param,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
def get_fetch_scheduled_tweets(
|
|
118
|
+
self,
|
|
119
|
+
ascending: Optional[bool] = None,
|
|
120
|
+
extra_param: Optional[ParamType] = None,
|
|
121
|
+
) -> TwitterApiUtilsResponse[List[Dict[str, Any]]]:
|
|
122
|
+
"""Items are untyped: no scheduled post has been recorded yet."""
|
|
123
|
+
param: ParamType = {}
|
|
124
|
+
if ascending is not None:
|
|
125
|
+
param["ascending"] = ascending
|
|
126
|
+
if extra_param is not None:
|
|
127
|
+
param.update(extra_param)
|
|
128
|
+
return data_request(
|
|
129
|
+
self.api.get_fetch_scheduled_tweets_with_http_info,
|
|
130
|
+
self.flag["FetchScheduledTweets"],
|
|
131
|
+
self.ct,
|
|
132
|
+
lambda e: error_check(e.data, e.errors).viewer.scheduled_tweet_list,
|
|
133
|
+
param,
|
|
134
|
+
)
|
|
@@ -5,23 +5,22 @@ 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,
|
|
9
8
|
TimelineApiUtilsResponse,
|
|
10
9
|
TwitterApiUtilsResponse,
|
|
11
10
|
UserApiUtilsData,
|
|
12
11
|
)
|
|
13
12
|
from twitter_openapi_python.utils import (
|
|
14
|
-
|
|
15
|
-
entries_cursor,
|
|
13
|
+
data_request,
|
|
16
14
|
error_check,
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
list_entries_converter,
|
|
16
|
+
timeline_request,
|
|
19
17
|
user_entries_converter,
|
|
20
18
|
user_result_converter,
|
|
21
19
|
)
|
|
22
20
|
|
|
23
21
|
T = TypeVar("T")
|
|
24
22
|
ResponseType = TwitterApiUtilsResponse[TimelineApiUtilsResponse[UserApiUtilsData]]
|
|
23
|
+
ListResponseType = TwitterApiUtilsResponse[TimelineApiUtilsResponse[models.TwitterList]]
|
|
25
24
|
ApiFnType = Callable[..., twitter.ApiResponse[T]]
|
|
26
25
|
ParamType = dict[str, Any]
|
|
27
26
|
|
|
@@ -42,25 +41,15 @@ class UserListApiUtils:
|
|
|
42
41
|
key: str,
|
|
43
42
|
param: ParamType,
|
|
44
43
|
) -> ResponseType:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
raw = ApiUtilsRaw(
|
|
53
|
-
instruction=instruction,
|
|
54
|
-
entry=entry,
|
|
55
|
-
)
|
|
56
|
-
data = TimelineApiUtilsResponse[UserApiUtilsData](
|
|
57
|
-
raw=raw,
|
|
58
|
-
cursor=entries_cursor(entry),
|
|
59
|
-
data=user,
|
|
44
|
+
return timeline_request(
|
|
45
|
+
apiFn,
|
|
46
|
+
self.flag[key],
|
|
47
|
+
self.ct,
|
|
48
|
+
convertFn,
|
|
49
|
+
param,
|
|
50
|
+
lambda entry: user_result_converter(user_entries_converter(entry)),
|
|
60
51
|
)
|
|
61
52
|
|
|
62
|
-
return build_response(response=res, data=data)
|
|
63
|
-
|
|
64
53
|
def get_followers(
|
|
65
54
|
self,
|
|
66
55
|
user_id: str,
|
|
@@ -169,3 +158,217 @@ class UserListApiUtils:
|
|
|
169
158
|
key="Retweeters",
|
|
170
159
|
param=param,
|
|
171
160
|
)
|
|
161
|
+
|
|
162
|
+
def get_blue_verified_followers(
|
|
163
|
+
self,
|
|
164
|
+
user_id: str,
|
|
165
|
+
cursor: Optional[str] = None,
|
|
166
|
+
count: Optional[int] = None,
|
|
167
|
+
extra_param: Optional[ParamType] = None,
|
|
168
|
+
) -> ResponseType:
|
|
169
|
+
param: ParamType = {"userId": user_id}
|
|
170
|
+
if cursor is not None:
|
|
171
|
+
param["cursor"] = cursor
|
|
172
|
+
if count is not None:
|
|
173
|
+
param["count"] = count
|
|
174
|
+
if extra_param is not None:
|
|
175
|
+
param.update(extra_param)
|
|
176
|
+
return self.request(
|
|
177
|
+
apiFn=self.api.get_blue_verified_followers_with_http_info,
|
|
178
|
+
convertFn=lambda e: error_check(e.data.user, e.errors).result.timeline.timeline.instructions,
|
|
179
|
+
key="BlueVerifiedFollowers",
|
|
180
|
+
param=param,
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
def get_list_members(
|
|
184
|
+
self,
|
|
185
|
+
list_id: str,
|
|
186
|
+
cursor: Optional[str] = None,
|
|
187
|
+
count: Optional[int] = None,
|
|
188
|
+
extra_param: Optional[ParamType] = None,
|
|
189
|
+
) -> ResponseType:
|
|
190
|
+
param: ParamType = {"listId": list_id}
|
|
191
|
+
if cursor is not None:
|
|
192
|
+
param["cursor"] = cursor
|
|
193
|
+
if count is not None:
|
|
194
|
+
param["count"] = count
|
|
195
|
+
if extra_param is not None:
|
|
196
|
+
param.update(extra_param)
|
|
197
|
+
return self.request(
|
|
198
|
+
apiFn=self.api.get_list_members_with_http_info,
|
|
199
|
+
convertFn=lambda e: error_check(e.data.list.members_timeline.timeline, e.errors).instructions,
|
|
200
|
+
key="ListMembers",
|
|
201
|
+
param=param,
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
def get_list_subscribers(
|
|
205
|
+
self,
|
|
206
|
+
list_id: str,
|
|
207
|
+
cursor: Optional[str] = None,
|
|
208
|
+
count: Optional[int] = None,
|
|
209
|
+
extra_param: Optional[ParamType] = None,
|
|
210
|
+
) -> ResponseType:
|
|
211
|
+
param: ParamType = {"listId": list_id}
|
|
212
|
+
if cursor is not None:
|
|
213
|
+
param["cursor"] = cursor
|
|
214
|
+
if count is not None:
|
|
215
|
+
param["count"] = count
|
|
216
|
+
if extra_param is not None:
|
|
217
|
+
param.update(extra_param)
|
|
218
|
+
return self.request(
|
|
219
|
+
apiFn=self.api.get_list_subscribers_with_http_info,
|
|
220
|
+
convertFn=lambda e: error_check(e.data.list.subscribers_timeline.timeline, e.errors).instructions,
|
|
221
|
+
key="ListSubscribers",
|
|
222
|
+
param=param,
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
def get_list_creation_recommended_users(
|
|
226
|
+
self,
|
|
227
|
+
list_id: str,
|
|
228
|
+
count: Optional[int] = None,
|
|
229
|
+
extra_param: Optional[ParamType] = None,
|
|
230
|
+
) -> ResponseType:
|
|
231
|
+
"""Empty unless list_id is one of the authenticated account's lists."""
|
|
232
|
+
param: ParamType = {"listId": list_id}
|
|
233
|
+
if count is not None:
|
|
234
|
+
param["count"] = count
|
|
235
|
+
if extra_param is not None:
|
|
236
|
+
param.update(extra_param)
|
|
237
|
+
return self.request(
|
|
238
|
+
apiFn=self.api.get_list_creation_recommended_users_with_http_info,
|
|
239
|
+
convertFn=lambda e: t.instructions if (t := e.data.list.recommended_users.timeline) else [],
|
|
240
|
+
key="ListCreationRecommendedUsers",
|
|
241
|
+
param=param,
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
def get_list_edit_recommended_users(
|
|
245
|
+
self,
|
|
246
|
+
list_id: str,
|
|
247
|
+
count: Optional[int] = None,
|
|
248
|
+
extra_param: Optional[ParamType] = None,
|
|
249
|
+
) -> ResponseType:
|
|
250
|
+
"""Empty unless list_id is one of the authenticated account's lists."""
|
|
251
|
+
param: ParamType = {"listId": list_id}
|
|
252
|
+
if count is not None:
|
|
253
|
+
param["count"] = count
|
|
254
|
+
if extra_param is not None:
|
|
255
|
+
param.update(extra_param)
|
|
256
|
+
return self.request(
|
|
257
|
+
apiFn=self.api.get_list_edit_recommended_users_with_http_info,
|
|
258
|
+
convertFn=lambda e: t.instructions if (t := e.data.list.recommended_users.timeline) else [],
|
|
259
|
+
key="ListEditRecommendedUsers",
|
|
260
|
+
param=param,
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
def get_list_ownerships(
|
|
264
|
+
self,
|
|
265
|
+
user_id: str,
|
|
266
|
+
is_list_member_target_user_id: Optional[str] = None,
|
|
267
|
+
cursor: Optional[str] = None,
|
|
268
|
+
count: Optional[int] = None,
|
|
269
|
+
extra_param: Optional[ParamType] = None,
|
|
270
|
+
) -> ListResponseType:
|
|
271
|
+
"""Lists owned by user_id; is_list_member_target_user_id marks the lists that user is a member of."""
|
|
272
|
+
param: ParamType = {"userId": user_id}
|
|
273
|
+
if is_list_member_target_user_id is not None:
|
|
274
|
+
param["isListMemberTargetUserId"] = is_list_member_target_user_id
|
|
275
|
+
if cursor is not None:
|
|
276
|
+
param["cursor"] = cursor
|
|
277
|
+
if count is not None:
|
|
278
|
+
param["count"] = count
|
|
279
|
+
if extra_param is not None:
|
|
280
|
+
param.update(extra_param)
|
|
281
|
+
return timeline_request(
|
|
282
|
+
self.api.get_list_ownerships_with_http_info,
|
|
283
|
+
self.flag["ListOwnerships"],
|
|
284
|
+
self.ct,
|
|
285
|
+
lambda e: error_check(error_check(e.data.user, e.errors).result.timeline.timeline, e.errors).instructions,
|
|
286
|
+
param,
|
|
287
|
+
list_entries_converter,
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
def get_list_by_rest_id(
|
|
291
|
+
self,
|
|
292
|
+
list_id: str,
|
|
293
|
+
extra_param: Optional[ParamType] = None,
|
|
294
|
+
) -> TwitterApiUtilsResponse[models.TwitterList]:
|
|
295
|
+
param: ParamType = {"listId": list_id}
|
|
296
|
+
if extra_param is not None:
|
|
297
|
+
param.update(extra_param)
|
|
298
|
+
return data_request(
|
|
299
|
+
self.api.get_list_by_rest_id_with_http_info,
|
|
300
|
+
self.flag["ListByRestId"],
|
|
301
|
+
self.ct,
|
|
302
|
+
lambda e: error_check(e.data, e.errors).list,
|
|
303
|
+
param,
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
def get_list_search_timeline(
|
|
307
|
+
self,
|
|
308
|
+
raw_query: str,
|
|
309
|
+
cursor: Optional[str] = None,
|
|
310
|
+
count: Optional[int] = None,
|
|
311
|
+
extra_param: Optional[ParamType] = None,
|
|
312
|
+
) -> ListResponseType:
|
|
313
|
+
param: ParamType = {"rawQuery": raw_query}
|
|
314
|
+
if cursor is not None:
|
|
315
|
+
param["cursor"] = cursor
|
|
316
|
+
if count is not None:
|
|
317
|
+
param["count"] = count
|
|
318
|
+
if extra_param is not None:
|
|
319
|
+
param.update(extra_param)
|
|
320
|
+
return timeline_request(
|
|
321
|
+
self.api.get_list_search_timeline_with_http_info,
|
|
322
|
+
self.flag["ListSearchTimeline"],
|
|
323
|
+
self.ct,
|
|
324
|
+
lambda e: error_check(e.data.search_by_raw_query.list_search_timeline.timeline, e.errors).instructions,
|
|
325
|
+
param,
|
|
326
|
+
list_entries_converter,
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
def get_combined_lists(
|
|
330
|
+
self,
|
|
331
|
+
user_id: str,
|
|
332
|
+
cursor: Optional[str] = None,
|
|
333
|
+
count: Optional[int] = None,
|
|
334
|
+
extra_param: Optional[ParamType] = None,
|
|
335
|
+
) -> ListResponseType:
|
|
336
|
+
"""Lists a user owns or follows."""
|
|
337
|
+
param: ParamType = {"userId": user_id}
|
|
338
|
+
if cursor is not None:
|
|
339
|
+
param["cursor"] = cursor
|
|
340
|
+
if count is not None:
|
|
341
|
+
param["count"] = count
|
|
342
|
+
if extra_param is not None:
|
|
343
|
+
param.update(extra_param)
|
|
344
|
+
return timeline_request(
|
|
345
|
+
self.api.get_combined_lists_with_http_info,
|
|
346
|
+
self.flag["CombinedLists"],
|
|
347
|
+
self.ct,
|
|
348
|
+
lambda e: error_check(error_check(e.data.user, e.errors).result.timeline.timeline, e.errors).instructions,
|
|
349
|
+
param,
|
|
350
|
+
list_entries_converter,
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
def get_lists_management_page_timeline(
|
|
354
|
+
self,
|
|
355
|
+
cursor: Optional[str] = None,
|
|
356
|
+
count: Optional[int] = None,
|
|
357
|
+
extra_param: Optional[ParamType] = None,
|
|
358
|
+
) -> ListResponseType:
|
|
359
|
+
"""The account's lists management page."""
|
|
360
|
+
param: ParamType = {}
|
|
361
|
+
if cursor is not None:
|
|
362
|
+
param["cursor"] = cursor
|
|
363
|
+
if count is not None:
|
|
364
|
+
param["count"] = count
|
|
365
|
+
if extra_param is not None:
|
|
366
|
+
param.update(extra_param)
|
|
367
|
+
return timeline_request(
|
|
368
|
+
self.api.get_lists_management_page_timeline_with_http_info,
|
|
369
|
+
self.flag["ListsManagementPageTimeline"],
|
|
370
|
+
self.ct,
|
|
371
|
+
lambda e: error_check(e.data.viewer.list_management_timeline.timeline, e.errors).instructions,
|
|
372
|
+
param,
|
|
373
|
+
list_entries_converter,
|
|
374
|
+
)
|