Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Commit 5195fbe

Browse files
committed
🔥 Remove comments API for Bilibili
1 parent 4a53355 commit 5195fbe

File tree

6 files changed

+1
-131
lines changed

6 files changed

+1
-131
lines changed
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
# flake8:noqa:F401
2-
from .base import (
3-
BaseBilibiliEndpoint,
4-
CommentSortType,
5-
CommentType,
6-
TimelineType,
7-
VideoFormatType,
8-
VideoQualityType,
9-
)
2+
from .base import BaseBilibiliEndpoint, TimelineType, VideoFormatType, VideoQualityType
103
from .v2 import BilibiliEndpointV2, SearchType
114
from .v3 import BilibiliEndpointV3

hibiapi/api/bilibili/api/base.py

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,6 @@ class TimelineType(str, Enum):
2222
"""番剧"""
2323

2424

25-
@enum_auto_doc
26-
class CommentSortType(IntEnum):
27-
"""评论排序类型"""
28-
29-
LIKES = 2
30-
"""按点赞"""
31-
HOT = 1
32-
"""按热评"""
33-
TIME = 0
34-
"""按时间"""
35-
36-
37-
@enum_auto_doc
38-
class CommentType(IntEnum):
39-
"""评论来源类型"""
40-
41-
VIDEO = 1
42-
"""视频"""
43-
ARTICLE = 12
44-
"""文章"""
45-
DYNAMIC_PICTURE = 11
46-
"""含图片的动态"""
47-
DYNAMIC_TEXT = 17
48-
"""不含图片的动态"""
49-
AUDIO = 14
50-
"""音乐"""
51-
AUDIO_LIST = 19
52-
"""歌单"""
53-
54-
5525
@enum_auto_doc
5626
class VideoQualityType(IntEnum):
5727
"""视频质量类型"""
@@ -283,28 +253,6 @@ async def season_recommend(self, *, season_id: int):
283253
},
284254
)
285255

286-
async def comments(
287-
self,
288-
*,
289-
type: CommentType,
290-
oid: int,
291-
sort: CommentSortType = CommentSortType.TIME,
292-
page: int = 1,
293-
pagesize: int = 20,
294-
):
295-
return await self.request(
296-
"x/v2/reply",
297-
"api",
298-
sign=False,
299-
params={
300-
"type": type,
301-
"oid": oid,
302-
"sort": sort,
303-
"pn": page,
304-
"ps": pagesize,
305-
},
306-
)
307-
308256
async def timeline(self, *, type: TimelineType = TimelineType.GLOBAL):
309257
return await self.request(
310258
"web_api/timeline_{type}",

hibiapi/api/bilibili/api/v2.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
from hibiapi.api.bilibili.api.base import (
77
BaseBilibiliEndpoint,
8-
CommentSortType,
9-
CommentType,
108
TimelineType,
119
VideoFormatType,
1210
VideoQualityType,
@@ -78,33 +76,6 @@ async def source(self, *, episode_id: int):
7876
async def seasonrecommend(self, *, season_id: int): # NOTE: not same with origin
7977
return await self.base.season_recommend(season_id=season_id)
8078

81-
@process_keyerror
82-
async def comments(
83-
self,
84-
*,
85-
aid: Optional[int] = None,
86-
season_id: Optional[int] = None,
87-
index: Optional[int] = None,
88-
sort: CommentSortType = CommentSortType.TIME,
89-
page: int = 1,
90-
pagesize: int = 20,
91-
): # NOTE: not same with origin
92-
if season_id is not None:
93-
assert index is not None, "parameter 'index' is required"
94-
season_info = await self.base.season_info(season_id=season_id)
95-
oid = season_info["result"]["episodes"][index - 1]["av_id"]
96-
elif aid is not None:
97-
oid = aid
98-
else:
99-
raise ClientSideException
100-
return await self.base.comments(
101-
oid=oid,
102-
sort=sort,
103-
type=CommentType.VIDEO,
104-
page=page,
105-
pagesize=pagesize,
106-
)
107-
10879
async def search(
10980
self,
11081
*,

hibiapi/api/bilibili/api/v3.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from hibiapi.api.bilibili.api.base import (
22
BaseBilibiliEndpoint,
3-
CommentSortType,
4-
CommentType,
53
TimelineType,
64
VideoFormatType,
75
VideoQualityType,
@@ -79,20 +77,3 @@ async def search_recommend(self, *, limit: int = 50):
7977

8078
async def search_suggestion(self, *, keyword: str):
8179
return await self.base.search_suggest(keyword=keyword)
82-
83-
async def comments(
84-
self,
85-
*,
86-
id: int,
87-
type: CommentType = CommentType.VIDEO,
88-
sort: CommentSortType = CommentSortType.TIME,
89-
page: int = 1,
90-
size: int = 20,
91-
):
92-
return await self.base.comments(
93-
oid=id,
94-
type=type,
95-
sort=sort,
96-
page=page,
97-
pagesize=size,
98-
)

test/test_bilibili_v2.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,6 @@ def test_seasonrecommend(client: TestClient):
4040
assert response.json()["code"] == 0
4141

4242

43-
def test_comments(client: TestClient):
44-
response = client.get("comments", params={"aid": 810872})
45-
assert response.status_code == 200
46-
assert response.json()["code"] == 0
47-
48-
49-
def test_season_comments(client: TestClient):
50-
response = client.get("comments", params={"season_id": 425, "index": 1})
51-
print(response.text)
52-
if response.status_code == 200:
53-
assert response.json()["code"] == 0
54-
elif response.status_code == 400:
55-
pytest.skip("Your region does not support getting comments from bangumi")
56-
else:
57-
raise AssertionError(f"{response.status_code=} is not expected")
58-
59-
6043
def test_search(client: TestClient):
6144
response = client.get("search", params={"keyword": "railgun"})
6245
assert response.status_code == 200

test/test_bilibili_v3.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,3 @@ def test_search_suggestion(client: TestClient):
8989
response = client.get("search_suggestion", params={"keyword": "paperclip"})
9090
assert response.status_code == 200
9191
assert response.json()["code"] == 0
92-
93-
94-
def test_comments(client: TestClient):
95-
response = client.get("comments", params={"id": 810872})
96-
assert response.status_code == 200
97-
assert response.json()["code"] == 0

0 commit comments

Comments
 (0)