redfox-python-sdk 0.2.0__tar.gz → 0.2.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 (25) hide show
  1. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/PKG-INFO +1 -1
  2. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox/__init__.py +1 -1
  3. redfox-python-sdk-0.2.1/redfox/endpoints/bilibili.py +123 -0
  4. redfox-python-sdk-0.2.1/redfox/endpoints/doubao_video.py +74 -0
  5. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox/endpoints/gpt_image.py +16 -10
  6. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox/endpoints/wechat.py +27 -17
  7. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox/endpoints/xiaohongshu.py +57 -34
  8. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox_python_sdk.egg-info/PKG-INFO +1 -1
  9. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/setup.py +1 -1
  10. redfox-python-sdk-0.2.0/redfox/endpoints/bilibili.py +0 -95
  11. redfox-python-sdk-0.2.0/redfox/endpoints/doubao_video.py +0 -59
  12. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/README.md +0 -0
  13. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox/client.py +0 -0
  14. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox/endpoints/__init__.py +0 -0
  15. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox/endpoints/ai_search.py +0 -0
  16. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox/endpoints/doubao_image.py +0 -0
  17. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox/endpoints/douyin.py +0 -0
  18. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox/endpoints/tiktok.py +0 -0
  19. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox/endpoints/toutiao.py +0 -0
  20. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox/exceptions.py +0 -0
  21. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox_python_sdk.egg-info/SOURCES.txt +0 -0
  22. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox_python_sdk.egg-info/dependency_links.txt +0 -0
  23. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox_python_sdk.egg-info/requires.txt +0 -0
  24. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/redfox_python_sdk.egg-info/top_level.txt +0 -0
  25. {redfox-python-sdk-0.2.0 → redfox-python-sdk-0.2.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: redfox-python-sdk
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: RedFox 红狐数据平台 Python SDK
5
5
  Home-page: https://redfox.hk
6
6
  Author: RedFox
@@ -3,5 +3,5 @@
3
3
  from .client import RedFoxClient
4
4
  from .exceptions import RedFoxAPIError, RedFoxAuthError, RedFoxRateLimitError
5
5
 
6
- __version__ = "0.2.0"
6
+ __version__ = "0.2.1"
7
7
  __all__ = ["RedFoxClient", "RedFoxAPIError", "RedFoxAuthError", "RedFoxRateLimitError"]
@@ -0,0 +1,123 @@
1
+ """哔哩哔哩平台 API 端点"""
2
+
3
+ from typing import Optional, Dict, Any
4
+
5
+
6
+ class BilibiliAPI:
7
+ """
8
+ 哔哩哔哩平台 API 集合
9
+
10
+ 包含 B 站账号查询、作品搜索、作品详情等接口。
11
+ """
12
+
13
+ def __init__(self, client):
14
+ self._client = client
15
+
16
+ def get_account(self, mid: str) -> dict:
17
+ """
18
+ 获取哔哩哔哩账号信息(优质库)
19
+
20
+ :param mid: 账号 MID(B 站用户唯一 ID,必填)
21
+ :return: 账号信息字典
22
+ """
23
+ return self._client.post(
24
+ "/story/api/bili/data/accountDetail", data={"mid": mid}
25
+ )
26
+
27
+ def get_work(
28
+ self,
29
+ bvid: str = None,
30
+ work_url: str = None,
31
+ ) -> dict:
32
+ """
33
+ 获取哔哩哔哩作品内容详情(优质库)
34
+
35
+ bvid 和 work_url 至少传一个。
36
+
37
+ :param bvid: 作品 BV 号
38
+ :param work_url: 作品链接,支持 bilibili.com/video/BV1xxx 或 b23.tv 格式
39
+ :return: 作品详情字典
40
+ """
41
+ data: Dict[str, Any] = {}
42
+ if bvid:
43
+ data["bvId"] = bvid
44
+ if work_url:
45
+ data["workUrl"] = work_url
46
+ return self._client.post("/story/api/bili/data/workDetail", data=data)
47
+
48
+ def search_users(
49
+ self,
50
+ keyword: str,
51
+ page: int = 1,
52
+ page_size: int = None,
53
+ order: str = None,
54
+ ) -> dict:
55
+ """
56
+ 搜索关键词获取哔哩哔哩账号(优质库)
57
+
58
+ :param keyword: 搜索关键词(必填)
59
+ :param page: 页码,从 1 开始(必填)
60
+ :param page_size: 每页条数,默认 10,最大 50
61
+ :param order: 排序:follower=粉丝数 / like=获赞数,默认相关性
62
+ :return: 搜索结果字典
63
+ """
64
+ data: Dict[str, Any] = {"keyword": keyword, "page": str(page)}
65
+ if page_size is not None:
66
+ data["pageSize"] = page_size
67
+ if order is not None:
68
+ data["order"] = order
69
+ return self._client.post("/story/api/bili/data/accountSearch", data=data)
70
+
71
+ def search_articles(
72
+ self,
73
+ keyword: str,
74
+ page: int = 1,
75
+ page_size: int = None,
76
+ order: str = None,
77
+ ) -> dict:
78
+ """
79
+ 搜索关键词获取哔哩哔哩作品(优质库)
80
+
81
+ :param keyword: 搜索关键词(必填)
82
+ :param page: 页码,从 1 开始(必填)
83
+ :param page_size: 每页条数,默认 10,最大 50
84
+ :param order: 排序:time=发布时间 / play=播放数 / like=点赞数 / comment=评论数 / favorite=收藏数,默认 time
85
+ :return: 搜索结果字典
86
+ """
87
+ data: Dict[str, Any] = {"keyword": keyword, "page": str(page)}
88
+ if page_size is not None:
89
+ data["pageSize"] = page_size
90
+ if order is not None:
91
+ data["order"] = order
92
+ return self._client.post("/story/api/bili/data/workSearch", data=data)
93
+
94
+ def get_user_works(
95
+ self,
96
+ mid: str = None,
97
+ account_url: str = None,
98
+ page: int = 1,
99
+ page_size: int = None,
100
+ order: str = None,
101
+ ) -> dict:
102
+ """
103
+ 获取哔哩哔哩账号作品列表(优质库)
104
+
105
+ mid 和 account_url 至少传一个。
106
+
107
+ :param mid: 账号 MID
108
+ :param account_url: 主页链接,如 https://space.bilibili.com/946974
109
+ :param page: 页码,默认 1
110
+ :param page_size: 每页条数,默认 10,最大 50
111
+ :param order: 排序:time=发布时间 / play=播放数 / like=点赞数,默认 time
112
+ :return: 作品列表字典
113
+ """
114
+ data: Dict[str, Any] = {"page": str(page)}
115
+ if mid:
116
+ data["mid"] = mid
117
+ if account_url:
118
+ data["accountUrl"] = account_url
119
+ if page_size is not None:
120
+ data["pageSize"] = page_size
121
+ if order is not None:
122
+ data["order"] = order
123
+ return self._client.post("/story/api/bili/data/accountWorkList", data=data)
@@ -0,0 +1,74 @@
1
+ """豆包视频生成 API 端点(Seedance 2.0)"""
2
+
3
+ from typing import Optional, Dict, Any, List
4
+
5
+
6
+ class DoubaoVideoAPI:
7
+ """
8
+ 豆包视频生成 API 集合(Seedance 2.0)
9
+
10
+ 包含视频生成任务提交与结果查询接口。
11
+ """
12
+
13
+ def __init__(self, client):
14
+ self._client = client
15
+
16
+ def submit(
17
+ self,
18
+ content: List[Dict[str, Any]],
19
+ model: str = None,
20
+ resolution: str = "720p",
21
+ ratio: str = "adaptive",
22
+ duration: int = 5,
23
+ seed: int = -1,
24
+ watermark: bool = False,
25
+ generate_audio: bool = True,
26
+ return_last_frame: bool = False,
27
+ ) -> dict:
28
+ """
29
+ 提交视频生成任务(Seedance 2.0)
30
+
31
+ content 是一个列表,每个元素是一个字典,支持以下 type:
32
+ - text: {"type": "text", "text": "描述文字"}
33
+ - image_url: {"type": "image_url", "imageUrl": "图片URL", "imageRole": "first_frame/reference_image"}
34
+ - video_url: {"type": "video_url", "videoUrl": "视频URL", "videoRole": "reference_video"}
35
+ - audio_url: {"type": "audio_url", "audioUrl": "音频URL", "audioRole": "reference_audio"}
36
+
37
+ :param content: 输入内容列表(必填),每项包含 type 及对应字段
38
+ :param model: 模型名称,如 "doubao-seedance-2-0-260128"
39
+ :param resolution: 视频分辨率:480p/720p/1080p(Seedance 2.0 fast 不支持 1080p)
40
+ :param ratio: 宽高比:adaptive/16:9/4:3/1:1/3:4/9:16/21:9
41
+ :param duration: 视频时长(秒),[4,15] 或 -1(智能)
42
+ :param seed: 随机种子,-1 为随机,范围 [-1, 2^32-1]
43
+ :param watermark: 是否添加水印
44
+ :param generate_audio: 是否生成同步音频(仅 Seedance 2.0 系列)
45
+ :param return_last_frame: 是否返回尾帧图像(用于连续视频生成)
46
+ :return: 含 taskId 的字典
47
+ """
48
+ data: Dict[str, Any] = {
49
+ "content": content,
50
+ "resolution": resolution,
51
+ "ratio": ratio,
52
+ "duration": duration,
53
+ "seed": seed,
54
+ "watermark": watermark,
55
+ "generateAudio": generate_audio,
56
+ "returnLastFrame": return_last_frame,
57
+ }
58
+ if model is not None:
59
+ data["model"] = model
60
+ return self._client.post(
61
+ "/story/api/parseWork/videoGen/submit", data=data
62
+ )
63
+
64
+ def result(self, task_id: str) -> dict:
65
+ """
66
+ 查询视频生成任务结果
67
+
68
+ :param task_id: 任务 ID(submit 接口返回)
69
+ :return: 视频生成结果字典
70
+ """
71
+ return self._client.post(
72
+ "/story/api/parseWork/videoGen/result",
73
+ data={"taskId": task_id},
74
+ )
@@ -24,6 +24,7 @@ class GPTImageAPI:
24
24
  output_compression: int = None,
25
25
  model_name: str = "gpt-image-2",
26
26
  operation: str = "generate",
27
+ input_fidelity: str = None,
27
28
  images: List[Dict[str, str]] = None,
28
29
  ) -> dict:
29
30
  """
@@ -38,23 +39,28 @@ class GPTImageAPI:
38
39
  :param output_compression: 输出压缩比,0~100
39
40
  :param model_name: 模型名称,默认 gpt-image-2
40
41
  :param operation: 操作类型,generate(文生图)/ edit(图生图)
42
+ :param input_fidelity: 输入图保真度,编辑模式(operation=edit)支持 high/low
41
43
  :param images: 图片编辑输入图列表,operation=edit 时必填
42
44
  :return: 包含 taskId 的字典
43
45
  """
46
+ parameters: Dict[str, Any] = {
47
+ "modelName": model_name,
48
+ "n": n,
49
+ "size": size,
50
+ "quality": quality,
51
+ "background": background,
52
+ "outputFormat": output_format,
53
+ }
54
+ if output_compression is not None:
55
+ parameters["outputCompression"] = output_compression
56
+ if input_fidelity is not None:
57
+ parameters["inputFidelity"] = input_fidelity
58
+
44
59
  data: Dict[str, Any] = {
45
60
  "prompt": prompt,
46
61
  "operation": operation,
47
- "parameters": {
48
- "modelName": model_name,
49
- "n": n,
50
- "size": size,
51
- "quality": quality,
52
- "background": background,
53
- "outputFormat": output_format,
54
- },
62
+ "parameters": parameters,
55
63
  }
56
- if output_compression is not None:
57
- data["parameters"]["outputCompression"] = output_compression
58
64
  if images is not None:
59
65
  data["images"] = images
60
66
  return self._client.post("/story/api/parseWork/imageGen/submitSkill", data=data)
@@ -51,26 +51,26 @@ class WechatAPI:
51
51
 
52
52
  # ─── 作品相关 ───────────────────────────────────────────
53
53
 
54
- def get_work(self, uuid: str) -> dict:
54
+ def get_work(self, work_uuid: str) -> dict:
55
55
  """
56
56
  根据作品 UUID 获取公众号作品(优质库)
57
57
 
58
- :param uuid: 作品 UUID
58
+ :param work_uuid: 作品 UUID(必填)
59
59
  :return: 作品详情字典
60
60
  """
61
61
  return self._client.post(
62
- "/story/api/gzhData/queryWork", data={"uuid": uuid}
62
+ "/story/api/gzhData/queryWork", data={"workUuid": work_uuid}
63
63
  )
64
64
 
65
- def get_article_detail(self, article_url: str) -> dict:
65
+ def get_article_detail(self, url: str) -> dict:
66
66
  """
67
67
  根据作品地址获取公众号文章(优质库)
68
68
 
69
- :param article_url: 文章链接
69
+ :param url: 文章链接(必填)
70
70
  :return: 文章详情字典
71
71
  """
72
72
  return self._client.post(
73
- "/story/api/gzhData/queryArticleDetail", data={"articleUrl": article_url}
73
+ "/story/api/gzhData/queryArticleDetail", data={"url": url}
74
74
  )
75
75
 
76
76
  def search_articles(
@@ -96,25 +96,35 @@ class WechatAPI:
96
96
 
97
97
  def get_user_works(
98
98
  self,
99
- account: str = None,
99
+ account: str,
100
100
  account_name: str = None,
101
101
  offset: int = 0,
102
+ sort_type: str = None,
103
+ publish_time_start: str = None,
104
+ publish_time_end: str = None,
102
105
  ) -> dict:
103
106
  """
104
107
  获取公众号账号作品列表(优质库)
105
108
 
106
- :param account: 公众号微信号
107
- :param account_name: 公众号名称
108
- :param offset: 偏移量,从 0 开始
109
+ :param account: 公众号微信号(必填)
110
+ :param account_name: 公众号名称(可选)
111
+ :param offset: 偏移量,从 0 开始,每页 +20
112
+ :param sort_type: 排序方式:_0=默认,_2=最新,_4=最热
113
+ :param publish_time_start: 发布时间起始,最早 2026-04-01,不传默认 2026-04-01
114
+ :param publish_time_end: 发布时间结束,不传默认当前时间
109
115
  :return: 作品列表字典
110
116
  """
111
- data: Dict[str, Any] = {}
112
- if account:
113
- data["account"] = account
117
+ data: Dict[str, Any] = {"account": account}
114
118
  if account_name:
115
119
  data["accountName"] = account_name
116
120
  if offset is not None:
117
121
  data["offset"] = offset
122
+ if sort_type is not None:
123
+ data["sortType"] = sort_type
124
+ if publish_time_start is not None:
125
+ data["publishTimeStart"] = publish_time_start
126
+ if publish_time_end is not None:
127
+ data["publishTimeEnd"] = publish_time_end
118
128
  return self._client.post("/story/api/gzhData/queryWorkList", data=data)
119
129
 
120
130
  # ─── AI 作品 ────────────────────────────────────────────
@@ -131,10 +141,10 @@ class WechatAPI:
131
141
  搜索关键词获取公众号 AI 创作作品(优质库)
132
142
 
133
143
  :param keyword: 搜索关键词(必填)
134
- :param page_num: 页码,默认 1
135
- :param page_size: 每页条数,默认 20
136
- :param start_time: 开始时间
137
- :param end_time: 结束时间
144
+ :param page_num: 页码,默认 1(必填)
145
+ :param page_size: 每页条数,默认 20(必填)
146
+ :param start_time: 开始时间,格式 "2026-06-01 00:00:00"
147
+ :param end_time: 结束时间,格式 "2026-06-01 23:59:59"
138
148
  :return: 搜索结果字典
139
149
  """
140
150
  data: Dict[str, Any] = {
@@ -7,7 +7,7 @@ class XiaohongshuAPI:
7
7
  """
8
8
  小红书平台 API 集合
9
9
 
10
- 包含小红书账号查询、作品详情、关键词搜索等接口。
10
+ 包含小红书账号查询、作品搜索、笔记详情等接口。
11
11
  """
12
12
 
13
13
  def __init__(self, client):
@@ -15,23 +15,6 @@ class XiaohongshuAPI:
15
15
 
16
16
  # ─── 账号相关 ───────────────────────────────────────────
17
17
 
18
- def get_account(
19
- self,
20
- account_id: str,
21
- user_id: str = None,
22
- ) -> dict:
23
- """
24
- 获取小红书账号信息(优质库)
25
-
26
- :param account_id: 小红书号(必填)
27
- :param user_id: 用户 ID,可从主页链接提取
28
- :return: 账号信息字典
29
- """
30
- data: Dict[str, Any] = {"accountId": account_id}
31
- if user_id is not None:
32
- data["userId"] = user_id
33
- return self._client.post("/story/api/xhsUser/queryAccountDetail", data=data)
34
-
35
18
  def search_users(
36
19
  self,
37
20
  keyword: str,
@@ -42,7 +25,7 @@ class XiaohongshuAPI:
42
25
  搜索关键词获取小红书账号(优质库)
43
26
 
44
27
  :param keyword: 搜索关键词(必填)
45
- :param offset: 分页偏移量,从 0 开始
28
+ :param offset: 偏移量
46
29
  :param sort_type: 排序方式
47
30
  :return: 搜索结果字典
48
31
  """
@@ -51,22 +34,31 @@ class XiaohongshuAPI:
51
34
  data["offset"] = offset
52
35
  if sort_type is not None:
53
36
  data["sortType"] = sort_type
54
- return self._client.post("/story/api/xhsUser/searchUser", data=data)
55
-
56
- # ─── 作品相关 ───────────────────────────────────────────
37
+ return self._client.post(
38
+ "/story/api/redBookData/searchUser", data=data
39
+ )
57
40
 
58
- def get_work(self, note_id: str) -> dict:
41
+ def get_account(
42
+ self,
43
+ account_id: str,
44
+ user_id: str = None,
45
+ ) -> dict:
59
46
  """
60
- 获取小红书作品内容详情(优质库)
47
+ 获取小红书账号信息(优质库)
61
48
 
62
- :param note_id: 笔记 ID
63
- :return: 作品详情字典
49
+ :param account_id: 小红书号(必填)
50
+ :param user_id: 用户 ID(可选)
51
+ :return: 账号信息字典
64
52
  """
53
+ data: Dict[str, Any] = {"accountId": account_id}
54
+ if user_id is not None:
55
+ data["userId"] = user_id
65
56
  return self._client.post(
66
- "/story/api/xhsUser/queryWorkDetail",
67
- data={"noteId": note_id},
57
+ "/story/api/redBookData/queryUser", data=data
68
58
  )
69
59
 
60
+ # ─── 作品相关 ───────────────────────────────────────────
61
+
70
62
  def search_articles(
71
63
  self,
72
64
  keyword: str,
@@ -77,7 +69,7 @@ class XiaohongshuAPI:
77
69
  搜索关键词获取小红书作品(优质库)
78
70
 
79
71
  :param keyword: 搜索关键词(必填)
80
- :param offset: 分页偏移量,从 0 开始
72
+ :param offset: 偏移量
81
73
  :param sort_type: 排序方式
82
74
  :return: 搜索结果字典
83
75
  """
@@ -86,7 +78,32 @@ class XiaohongshuAPI:
86
78
  data["offset"] = offset
87
79
  if sort_type is not None:
88
80
  data["sortType"] = sort_type
89
- return self._client.post("/story/api/xhsUser/searchArticle", data=data)
81
+ return self._client.post(
82
+ "/story/api/redBookData/searchArticle", data=data
83
+ )
84
+
85
+ def get_work(
86
+ self,
87
+ work_id: str = None,
88
+ work_link: str = None,
89
+ ) -> dict:
90
+ """
91
+ 获取小红书作品内容详情(优质库)
92
+
93
+ work_id 和 work_link 至少传一个。
94
+
95
+ :param work_id: 作品 ID
96
+ :param work_link: 作品链接,如 https://www.xiaohongshu.com/explore/xxx
97
+ :return: 作品详情字典
98
+ """
99
+ data: Dict[str, Any] = {}
100
+ if work_id:
101
+ data["workId"] = work_id
102
+ if work_link:
103
+ data["workLink"] = work_link
104
+ return self._client.post(
105
+ "/story/api/redBookData/queryWork", data=data
106
+ )
90
107
 
91
108
  # ─── AI 作品 ────────────────────────────────────────────
92
109
 
@@ -97,15 +114,17 @@ class XiaohongshuAPI:
97
114
  page_size: int = 20,
98
115
  start_time: str = None,
99
116
  end_time: str = None,
117
+ source: str = None,
100
118
  ) -> dict:
101
119
  """
102
- 搜索关键词获取小红书 AI 作品(优质库)
120
+ 搜索关键词获取小红书 AI 创作作品(优质库)
103
121
 
104
122
  :param keyword: 搜索关键词(必填)
105
123
  :param page_num: 页码,默认 1
106
124
  :param page_size: 每页条数,默认 20
107
- :param start_time: 开始时间
108
- :param end_time: 结束时间
125
+ :param start_time: 起始时间,格式 "2026-06-01 00:00:00"
126
+ :param end_time: 结束时间,格式 "2026-06-02 00:00:00"
127
+ :param source: 来源平台(可选)
109
128
  :return: 搜索结果字典
110
129
  """
111
130
  data: Dict[str, Any] = {
@@ -117,4 +136,8 @@ class XiaohongshuAPI:
117
136
  data["startTime"] = start_time
118
137
  if end_time is not None:
119
138
  data["endTime"] = end_time
120
- return self._client.post("/story/api/parseWork/queryXhsAiMsgs", data=data)
139
+ if source is not None:
140
+ data["source"] = source
141
+ return self._client.post(
142
+ "/story/api/parseWork/queryAiMsgs", data=data
143
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: redfox-python-sdk
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: RedFox 红狐数据平台 Python SDK
5
5
  Home-page: https://redfox.hk
6
6
  Author: RedFox
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="redfox-python-sdk",
5
- version="0.2.0",
5
+ version="0.2.1",
6
6
  description="RedFox 红狐数据平台 Python SDK",
7
7
  long_description=open("README.md", encoding="utf-8").read(),
8
8
  long_description_content_type="text/markdown",
@@ -1,95 +0,0 @@
1
- """哔哩哔哩平台 API 端点"""
2
-
3
- from typing import Optional, Dict, Any
4
-
5
-
6
- class BilibiliAPI:
7
- """
8
- 哔哩哔哩平台 API 集合
9
-
10
- 包含 B 站账号查询、作品搜索、作品详情等接口。
11
- """
12
-
13
- def __init__(self, client):
14
- self._client = client
15
-
16
- def get_account(self, mid: str) -> dict:
17
- """
18
- 获取哔哩哔哩账号信息(优质库)
19
-
20
- :param mid: 账号 MID(B 站用户唯一 ID,必填)
21
- :return: 账号信息字典
22
- """
23
- return self._client.post(
24
- "/story/api/bili/data/accountDetail", data={"mid": mid}
25
- )
26
-
27
- def get_work(self, bvid: str) -> dict:
28
- """
29
- 获取哔哩哔哩作品内容详情(优质库)
30
-
31
- :param bvid: 作品 BV ID
32
- :return: 作品详情字典
33
- """
34
- return self._client.post(
35
- "/story/api/bili/data/workDetail", data={"bvid": bvid}
36
- )
37
-
38
- def search_users(
39
- self,
40
- keyword: str,
41
- page_num: int = 1,
42
- order: str = None,
43
- ) -> dict:
44
- """
45
- 搜索关键词获取哔哩哔哩账号(优质库)
46
-
47
- :param keyword: 搜索关键词(必填)
48
- :param page_num: 页码,默认 1
49
- :param order: 排序方式
50
- :return: 搜索结果字典
51
- """
52
- data: Dict[str, Any] = {"keyword": keyword, "page": str(page_num)}
53
- if order is not None:
54
- data["order"] = order
55
- return self._client.post("/story/api/bili/data/accountSearch", data=data)
56
-
57
- def search_articles(
58
- self,
59
- keyword: str,
60
- page_num: int = 1,
61
- order: str = None,
62
- ) -> dict:
63
- """
64
- 搜索关键词获取哔哩哔哩作品(优质库)
65
-
66
- :param keyword: 搜索关键词(必填)
67
- :param page_num: 页码,默认 1
68
- :param order: 排序方式
69
- :return: 搜索结果字典
70
- """
71
- data: Dict[str, Any] = {"keyword": keyword, "page": str(page_num)}
72
- if order is not None:
73
- data["order"] = order
74
- return self._client.post("/story/api/bili/data/workSearch", data=data)
75
-
76
- def get_user_works(
77
- self,
78
- mid: str,
79
- page_num: int = 1,
80
- page_size: int = 30,
81
- ) -> dict:
82
- """
83
- 获取哔哩哔哩账号作品列表(优质库)
84
-
85
- :param mid: 账号 MID(必填)
86
- :param page_num: 页码,默认 1
87
- :param page_size: 每页条数,默认 30
88
- :return: 作品列表字典
89
- """
90
- data: Dict[str, Any] = {
91
- "mid": mid,
92
- "page": str(page_num),
93
- "pageSize": str(page_size),
94
- }
95
- return self._client.post("/story/api/bili/data/accountWorkList", data=data)
@@ -1,59 +0,0 @@
1
- """豆包视频生成工具 API 端点"""
2
-
3
- from typing import Optional, Dict, Any
4
-
5
-
6
- class DoubaoVideoAPI:
7
- """
8
- 豆包视频生成工具 API 集合
9
-
10
- 基于 Seedance 2.0 模型,支持文生视频。
11
- """
12
-
13
- def __init__(self, client):
14
- self._client = client
15
-
16
- def submit(
17
- self,
18
- prompt: str,
19
- model: str = "doubao-seedance-2-0-250528",
20
- resolution: str = "720p",
21
- ratio: str = "16:9",
22
- duration: int = 5,
23
- seed: int = None,
24
- generate_audio: bool = True,
25
- ) -> dict:
26
- """
27
- 提交 Seedance 2.0 视频生成任务
28
-
29
- :param prompt: 视频生成提示词(必填)
30
- :param model: 模型名称
31
- :param resolution: 分辨率,如 720p
32
- :param ratio: 宽高比,如 16:9
33
- :param duration: 时长(秒),如 5
34
- :param seed: 随机种子
35
- :param generate_audio: 是否生成音频
36
- :return: 包含 taskId 的字典
37
- """
38
- data: Dict[str, Any] = {
39
- "prompt": prompt,
40
- "model": model,
41
- "resolution": resolution,
42
- "ratio": ratio,
43
- "duration": duration,
44
- "generateAudio": generate_audio,
45
- }
46
- if seed is not None:
47
- data["seed"] = seed
48
- return self._client.post("/story/api/parseWork/videoGen/submit", data=data)
49
-
50
- def result(self, task_id: str) -> dict:
51
- """
52
- 查询 Seedance 2.0 视频生成任务结果
53
-
54
- :param task_id: 任务 ID(由 submit 接口返回)
55
- :return: 任务结果字典,包含 status/videoUrl/failReason 等
56
- """
57
- return self._client.post(
58
- "/story/api/parseWork/videoGen/result", data={"taskId": task_id}
59
- )