Skip to content

Commit 60102c5

Browse files
committed
Adapted to the new interface of API version V5.2.3
1 parent 97aa7a0 commit 60102c5

15 files changed

+240
-21
lines changed

dist/tikhub-1.12.4.tar.gz

-46 KB
Binary file not shown.

dist/tikhub-1.12.5-py3-none-any.whl

-67.7 KB
Binary file not shown.

dist/tikhub-1.12.5.tar.gz

-46 KB
Binary file not shown.

dist/tikhub-1.12.6-py3-none-any.whl

-67.7 KB
Binary file not shown.

dist/tikhub-1.12.6.tar.gz

-46 KB
Binary file not shown.

dist/tikhub-1.12.9.tar.gz

47.8 KB
Binary file not shown.

tikhub/api/v1/endpoints/bilibili/__init__.py

Whitespace-only changes.

tikhub/api/v1/endpoints/bilibili/web/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Import API SDK Client class
2+
from tikhub.http_client.api_client import APIClient
3+
4+
5+
class BilibiliWeb:
6+
7+
# Initialize
8+
def __init__(self, client: APIClient):
9+
self.client = client
10+
11+
# Fetch single video data | 获取单个视频详情信息
12+
async def fetch_one_video(self, bv_id: str):
13+
endpoint = "/api/v1/bilibili/web/fetch_one_video"
14+
data = await self.client.fetch_get_json(f"{endpoint}?bv_id={bv_id}")
15+
return data
16+
17+
# Fetch video playurl | 获取视频流地址
18+
async def fetch_video_playurl(self, bv_id: str, cid: str):
19+
endpoint = "/api/v1/bilibili/web/fetch_video_playurl"
20+
data = await self.client.fetch_get_json(f"{endpoint}?bv_id={bv_id}&cid={cid}")
21+
return data
22+
23+
# Fetch user post videos | 获取用户发布视频作品数据
24+
async def fetch_user_post_videos(self, uid: str, pn: int = 1):
25+
endpoint = "/api/v1/bilibili/web/fetch_user_post_videos"
26+
data = await self.client.fetch_get_json(f"{endpoint}?uid={uid}&pn={pn}")
27+
return data
28+
29+
# Fetch collection folders | 获取用户所有收藏夹信息
30+
async def fetch_collect_folders(self, uid: str):
31+
endpoint = "/api/v1/bilibili/web/fetch_collect_folders"
32+
data = await self.client.fetch_get_json(f"{endpoint}?uid={uid}")
33+
return data
34+
35+
# Fetch videos from collection folder | 获取指定收藏夹内视频数据
36+
async def fetch_user_collection_videos(self, folder_id: str, pn: int = 1):
37+
endpoint = "/api/v1/bilibili/web/fetch_user_collection_videos"
38+
data = await self.client.fetch_get_json(f"{endpoint}?folder_id={folder_id}&pn={pn}")
39+
return data
40+
41+
# Fetch user profile | 获取指定用户的信息
42+
async def fetch_user_profile(self, uid: str):
43+
endpoint = "/api/v1/bilibili/web/fetch_user_profile"
44+
data = await self.client.fetch_get_json(f"{endpoint}?uid={uid}")
45+
return data
46+
47+
# Fetch comprehensive popular videos | 获取综合热门视频信息
48+
async def fetch_com_popular(self, pn: int = 1):
49+
endpoint = "/api/v1/bilibili/web/fetch_com_popular"
50+
data = await self.client.fetch_get_json(f"{endpoint}?pn={pn}")
51+
return data
52+
53+
# Fetch video comments | 获取指定视频的评论
54+
async def fetch_video_comments(self, bv_id: str, pn: int = 1):
55+
endpoint = "/api/v1/bilibili/web/fetch_video_comments"
56+
data = await self.client.fetch_get_json(f"{endpoint}?bv_id={bv_id}&pn={pn}")
57+
return data
58+
59+
# Fetch comment reply | 获取视频下指定评论的回复
60+
async def fetch_comment_reply(self, bv_id: str, rpid: str, pn: int = 1):
61+
endpoint = "/api/v1/bilibili/web/fetch_comment_reply"
62+
data = await self.client.fetch_get_json(f"{endpoint}?bv_id={bv_id}&pn={pn}&rpid={rpid}")
63+
return data
64+
65+
# Fetch user dynamics | 获取指定用户动态
66+
async def fetch_user_dynamic(self, uid: str, offset: str = ""):
67+
endpoint = "/api/v1/bilibili/web/fetch_user_dynamic"
68+
data = await self.client.fetch_get_json(f"{endpoint}?uid={uid}&offset={offset}")
69+
return data
70+
71+
# Fetch video danmaku | 获取视频实时弹幕
72+
async def fetch_video_danmaku(self, cid: str):
73+
endpoint = "/api/v1/bilibili/web/fetch_video_danmaku"
74+
data = await self.client.fetch_get_json(f"{endpoint}?cid={cid}")
75+
return data
76+
77+
# Fetch live room details | 获取指定直播间信息
78+
async def fetch_live_room_detail(self, room_id: str):
79+
endpoint = "/api/v1/bilibili/web/fetch_live_room_detail"
80+
data = await self.client.fetch_get_json(f"{endpoint}?room_id={room_id}")
81+
return data
82+
83+
# Fetch live room videos | 获取指定直播间视频流
84+
async def fetch_live_videos(self, room_id: str):
85+
endpoint = "/api/v1/bilibili/web/fetch_live_videos"
86+
data = await self.client.fetch_get_json(f"{endpoint}?room_id={room_id}")
87+
return data
88+
89+
# Fetch live streamers in area | 获取指定分区正在直播的主播
90+
async def fetch_live_streamers(self, area_id: str, pn: int = 1):
91+
endpoint = "/api/v1/bilibili/web/fetch_live_streamers"
92+
data = await self.client.fetch_get_json(f"{endpoint}?area_id={area_id}&pn={pn}")
93+
return data
94+
95+
# Fetch all live areas | 获取所有直播分区列表
96+
async def fetch_all_live_areas(self):
97+
endpoint = "/api/v1/bilibili/web/fetch_all_live_areas"
98+
data = await self.client.fetch_get_json(endpoint)
99+
return data
100+
101+
# Convert bv_id to aid | 通过bv号获得视频aid号
102+
async def bv_to_aid(self, bv_id: str):
103+
endpoint = "/api/v1/bilibili/web/bv_to_aid"
104+
data = await self.client.fetch_get_json(f"{endpoint}?bv_id={bv_id}")
105+
return data
106+
107+
# Fetch video parts by bv_id | 通过bv号获得视频分p信息
108+
async def fetch_video_parts(self, bv_id: str):
109+
endpoint = "/api/v1/bilibili/web/fetch_video_parts"
110+
data = await self.client.fetch_get_json(f"{endpoint}?bv_id={bv_id}")
111+
return data

tikhub/api/v1/endpoints/douyin/app/douyin_app_v3.py

+6
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ async def fetch_user_following_list(self, sec_user_id: str, max_time: str = '0',
193193
data = await self.client.fetch_get_json(f"{endpoint}?sec_user_id={sec_user_id}&max_time={max_time}&count={count}")
194194
return data
195195

196+
# 抖音APP注册设备 (Douyin App Register Device)
197+
async def register_device(self, proxy: str = ''):
198+
endpoint = f"/api/v1/douyin/app/v3/register_device"
199+
data = await self.client.fetch_post_json(f"{endpoint}?proxy={proxy}")
200+
return data
201+
196202

197203
if __name__ == "__main__":
198204
import asyncio

tikhub/api/v1/endpoints/douyin/web/douyin_web.py

+14
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,20 @@ async def fetch_user_following_list(self, sec_user_id: str, max_time: str = '0',
518518
data = await self.client.fetch_get_json(f"{endpoint}?sec_user_id={sec_user_id}&max_time={max_time}&count={count}")
519519
return data
520520

521+
# 搜索话题 (Search Challenge)
522+
async def fetch_search_challenge(self, keyword: str, cursor: int = 0, count: int = 30, cookie: str = ''):
523+
"""
524+
搜索话题 (Search Challenge)
525+
:param keyword: 关键词 | Keyword
526+
:param cursor: 游标 | Cursor
527+
:param count: 数量 | Number
528+
:param cookie: 用户网页版抖音Cookie | Your web version of Douyin Cookie
529+
:return: 话题数据 | Challenge data
530+
"""
531+
endpoint = "/api/v1/douyin/web/fetch_search_challenge"
532+
data = await self.client.fetch_get_json(f"{endpoint}?keyword={keyword}&cursor={cursor}&count={count}&cookie={cookie}")
533+
return data
534+
521535

522536
if __name__ == "__main__":
523537
import asyncio

tikhub/api/v1/endpoints/tiktok/app/tiktok_app_v3.py

+6
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,12 @@ async def fetch_home_feed(self):
262262
data = await self.client.fetch_get_json(endpoint)
263263
return data
264264

265+
# TikTok APP注册设备信息 | Register device information
266+
async def register_device_info(self, proxy: str = ''):
267+
endpoint = "/api/v1/tiktok/app/v3/register_device_info"
268+
data = await self.client.fetch_get_json(f"{endpoint}?proxy={proxy}")
269+
return data
270+
265271

266272
if __name__ == "__main__":
267273
import asyncio

tikhub/api/v1/endpoints/twitter/web/twitter_web.py

+102-20
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,132 @@ def __init__(self, client: APIClient):
1111
self.client = client
1212

1313
# Fetch tweet detail | 获取推文详情
14-
async def fetch_tweet_detail(self, focalTweetId: str):
14+
async def fetch_tweet_detail(self, tweet_id: str):
1515
endpoint = "/api/v1/twitter/web/fetch_tweet_detail"
16-
data = await self.client.fetch_get_json(f"{endpoint}?focalTweetId={focalTweetId}")
16+
data = await self.client.fetch_get_json(f"{endpoint}?tweet_id={tweet_id}")
1717
return data
1818

1919
# Fetch user profile | 获取用户资料
20-
async def fetch_user_profile(self, screen_name: str):
20+
async def fetch_user_profile(self, screen_name: str = None, rest_id: int = None):
2121
endpoint = "/api/v1/twitter/web/fetch_user_profile"
22-
data = await self.client.fetch_get_json(f"{endpoint}?screen_name={screen_name}")
22+
params = []
23+
if screen_name:
24+
params.append(f"screen_name={screen_name}")
25+
if rest_id:
26+
params.append(f"rest_id={rest_id}")
27+
query = "&".join(params)
28+
data = await self.client.fetch_get_json(f"{endpoint}?{query}")
2329
return data
2430

2531
# Fetch user post tweet | 获取用户发帖
26-
async def fetch_user_post_tweet(self, userId: str, count: int = 20, cursor: str = None):
32+
async def fetch_user_post_tweet(self, screen_name: str = None, rest_id: int = None, cursor: str = None):
2733
endpoint = "/api/v1/twitter/web/fetch_user_post_tweet"
28-
data = await self.client.fetch_get_json(f"{endpoint}?userId={userId}&count={count}&cursor={cursor}")
34+
params = []
35+
if screen_name:
36+
params.append(f"screen_name={screen_name}")
37+
if rest_id:
38+
params.append(f"rest_id={rest_id}")
39+
if cursor:
40+
params.append(f"cursor={cursor}")
41+
query = "&".join(params)
42+
data = await self.client.fetch_get_json(f"{endpoint}?{query}")
2943
return data
3044

31-
# SearchTimeline | 搜索时间线
32-
async def fetch_search_timeline(self, rawQuery: str, count: int = 20, product: str = 'Top', cursor: str = None):
45+
# Fetch search timeline | 搜索
46+
async def fetch_search_timeline(self, keyword: str, search_type: str = "Top", cursor: str = None):
3347
endpoint = "/api/v1/twitter/web/fetch_search_timeline"
34-
data = await self.client.fetch_get_json(f"{endpoint}?rawQuery={rawQuery}&count={count}&product={product}&cursor={cursor}")
48+
params = [f"keyword={keyword}", f"search_type={search_type}"]
49+
if cursor:
50+
params.append(f"cursor={cursor}")
51+
query = "&".join(params)
52+
data = await self.client.fetch_get_json(f"{endpoint}?{query}")
3553
return data
3654

37-
# Post Comments | 获取评论
38-
async def fetch_post_comments(self, tweetId: str, rankingModel: str = 'Relevance', cursor: str = None):
55+
# Fetch post comments | 获取评论
56+
async def fetch_post_comments(self, tweet_id: str, cursor: str = None):
3957
endpoint = "/api/v1/twitter/web/fetch_post_comments"
40-
data = await self.client.fetch_get_json(f"{endpoint}?tweetId={tweetId}&rankingModel={rankingModel}&cursor={cursor}")
58+
params = [f"tweet_id={tweet_id}"]
59+
if cursor:
60+
params.append(f"cursor={cursor}")
61+
query = "&".join(params)
62+
data = await self.client.fetch_get_json(f"{endpoint}?{query}")
63+
return data
64+
65+
# Fetch latest post comments | 获取最新的推文评论
66+
async def fetch_latest_post_comments(self, tweet_id: str, cursor: str = None):
67+
endpoint = "/api/v1/twitter/web/fetch_latest_post_comments"
68+
params = [f"tweet_id={tweet_id}"]
69+
if cursor:
70+
params.append(f"cursor={cursor}")
71+
query = "&".join(params)
72+
data = await self.client.fetch_get_json(f"{endpoint}?{query}")
4173
return data
4274

4375
# Fetch user tweet replies | 获取用户推文回复
44-
async def fetch_user_tweet_replies(self, userId: str, count: int = 20, cursor: str = None):
76+
async def fetch_user_tweet_replies(self, screen_name: str, cursor: str = None):
4577
endpoint = "/api/v1/twitter/web/fetch_user_tweet_replies"
46-
data = await self.client.fetch_get_json(f"{endpoint}?userId={userId}&count={count}&cursor={cursor}")
78+
params = [f"screen_name={screen_name}"]
79+
if cursor:
80+
params.append(f"cursor={cursor}")
81+
query = "&".join(params)
82+
data = await self.client.fetch_get_json(f"{endpoint}?{query}")
4783
return data
4884

49-
# UserHighlightsTweets | 获取用户高光推文
50-
async def fetch_user_highlights_tweets(self, userId: str, count: int = 20, cursor: str = None):
85+
# Fetch user highlights tweets | 获取用户高光推文
86+
async def fetch_user_highlights_tweets(self, user_id: str, count: int = 20, cursor: str = None):
5187
endpoint = "/api/v1/twitter/web/fetch_user_highlights_tweets"
52-
data = await self.client.fetch_get_json(f"{endpoint}?userId={userId}&count={count}&cursor={cursor}")
88+
params = [f"userId={user_id}", f"count={count}"]
89+
if cursor:
90+
params.append(f"cursor={cursor}")
91+
query = "&".join(params)
92+
data = await self.client.fetch_get_json(f"{endpoint}?{query}")
5393
return data
5494

55-
# UserMedia | 获取用户媒体
56-
async def fetch_user_media(self, userId: str, count: int = 20, cursor: str = None):
95+
# Fetch user media | 获取用户媒体
96+
async def fetch_user_media(self, screen_name: str = None, rest_id: int = None):
5797
endpoint = "/api/v1/twitter/web/fetch_user_media"
58-
data = await self.client.fetch_get_json(f"{endpoint}?userId={userId}&count={count}&cursor={cursor}")
98+
params = []
99+
if screen_name:
100+
params.append(f"screen_name={screen_name}")
101+
if rest_id:
102+
params.append(f"rest_id={rest_id}")
103+
query = "&".join(params)
104+
data = await self.client.fetch_get_json(f"{endpoint}?{query}")
105+
return data
106+
107+
# Fetch retweet user list | 转推用户列表
108+
async def fetch_retweet_user_list(self, tweet_id: str, cursor: str = None):
109+
endpoint = "/api/v1/twitter/web/fetch_retweet_user_list"
110+
params = [f"tweet_id={tweet_id}"]
111+
if cursor:
112+
params.append(f"cursor={cursor}")
113+
query = "&".join(params)
114+
data = await self.client.fetch_get_json(f"{endpoint}?{query}")
115+
return data
116+
117+
# Fetch trending | 趋势
118+
async def fetch_trending(self, country: str = "UnitedStates"):
119+
endpoint = "/api/v1/twitter/web/fetch_trending"
120+
data = await self.client.fetch_get_json(f"{endpoint}?country={country}")
121+
return data
122+
123+
# Fetch user followings | 用户关注
124+
async def fetch_user_followings(self, screen_name: str, cursor: str = None):
125+
endpoint = "/api/v1/twitter/web/fetch_user_followings"
126+
params = [f"screen_name={screen_name}"]
127+
if cursor:
128+
params.append(f"cursor={cursor}")
129+
query = "&".join(params)
130+
data = await self.client.fetch_get_json(f"{endpoint}?{query}")
131+
return data
132+
133+
# Fetch user followers | 用户粉丝
134+
async def fetch_user_followers(self, screen_name: str, cursor: str = None):
135+
endpoint = "/api/v1/twitter/web/fetch_user_followers"
136+
params = [f"screen_name={screen_name}"]
137+
if cursor:
138+
params.append(f"cursor={cursor}")
139+
query = "&".join(params)
140+
data = await self.client.fetch_get_json(f"{endpoint}?{query}")
59141
return data
60142

tikhub/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# tikhub/version.py
2-
version = "1.12.8"
2+
version = "1.12.9"

0 commit comments

Comments
 (0)