diff --git a/hibiapi/api/bilibili/api/__init__.py b/hibiapi/api/bilibili/api/__init__.py index 5743866a..618bc135 100644 --- a/hibiapi/api/bilibili/api/__init__.py +++ b/hibiapi/api/bilibili/api/__init__.py @@ -1,11 +1,4 @@ # flake8:noqa:F401 -from .base import ( - BaseBilibiliEndpoint, - CommentSortType, - CommentType, - TimelineType, - VideoFormatType, - VideoQualityType, -) +from .base import BaseBilibiliEndpoint, TimelineType, VideoFormatType, VideoQualityType from .v2 import BilibiliEndpointV2, SearchType from .v3 import BilibiliEndpointV3 diff --git a/hibiapi/api/bilibili/api/base.py b/hibiapi/api/bilibili/api/base.py index ecbf2be9..b76c6dba 100644 --- a/hibiapi/api/bilibili/api/base.py +++ b/hibiapi/api/bilibili/api/base.py @@ -22,36 +22,6 @@ class TimelineType(str, Enum): """番剧""" -@enum_auto_doc -class CommentSortType(IntEnum): - """评论排序类型""" - - LIKES = 2 - """按点赞""" - HOT = 1 - """按热评""" - TIME = 0 - """按时间""" - - -@enum_auto_doc -class CommentType(IntEnum): - """评论来源类型""" - - VIDEO = 1 - """视频""" - ARTICLE = 12 - """文章""" - DYNAMIC_PICTURE = 11 - """含图片的动态""" - DYNAMIC_TEXT = 17 - """不含图片的动态""" - AUDIO = 14 - """音乐""" - AUDIO_LIST = 19 - """歌单""" - - @enum_auto_doc class VideoQualityType(IntEnum): """视频质量类型""" @@ -283,28 +253,6 @@ async def season_recommend(self, *, season_id: int): }, ) - async def comments( - self, - *, - type: CommentType, - oid: int, - sort: CommentSortType = CommentSortType.TIME, - page: int = 1, - pagesize: int = 20, - ): - return await self.request( - "x/v2/reply", - "api", - sign=False, - params={ - "type": type, - "oid": oid, - "sort": sort, - "pn": page, - "ps": pagesize, - }, - ) - async def timeline(self, *, type: TimelineType = TimelineType.GLOBAL): return await self.request( "web_api/timeline_{type}", diff --git a/hibiapi/api/bilibili/api/v2.py b/hibiapi/api/bilibili/api/v2.py index babb9e9e..898fcae6 100644 --- a/hibiapi/api/bilibili/api/v2.py +++ b/hibiapi/api/bilibili/api/v2.py @@ -5,8 +5,6 @@ from hibiapi.api.bilibili.api.base import ( BaseBilibiliEndpoint, - CommentSortType, - CommentType, TimelineType, VideoFormatType, VideoQualityType, @@ -78,33 +76,6 @@ async def source(self, *, episode_id: int): async def seasonrecommend(self, *, season_id: int): # NOTE: not same with origin return await self.base.season_recommend(season_id=season_id) - @process_keyerror - async def comments( - self, - *, - aid: Optional[int] = None, - season_id: Optional[int] = None, - index: Optional[int] = None, - sort: CommentSortType = CommentSortType.TIME, - page: int = 1, - pagesize: int = 20, - ): # NOTE: not same with origin - if season_id is not None: - assert index is not None, "parameter 'index' is required" - season_info = await self.base.season_info(season_id=season_id) - oid = season_info["result"]["episodes"][index - 1]["av_id"] - elif aid is not None: - oid = aid - else: - raise ClientSideException - return await self.base.comments( - oid=oid, - sort=sort, - type=CommentType.VIDEO, - page=page, - pagesize=pagesize, - ) - async def search( self, *, diff --git a/hibiapi/api/bilibili/api/v3.py b/hibiapi/api/bilibili/api/v3.py index 6316b527..ece57bf2 100644 --- a/hibiapi/api/bilibili/api/v3.py +++ b/hibiapi/api/bilibili/api/v3.py @@ -1,7 +1,5 @@ from hibiapi.api.bilibili.api.base import ( BaseBilibiliEndpoint, - CommentSortType, - CommentType, TimelineType, VideoFormatType, VideoQualityType, @@ -79,20 +77,3 @@ async def search_recommend(self, *, limit: int = 50): async def search_suggestion(self, *, keyword: str): return await self.base.search_suggest(keyword=keyword) - - async def comments( - self, - *, - id: int, - type: CommentType = CommentType.VIDEO, - sort: CommentSortType = CommentSortType.TIME, - page: int = 1, - size: int = 20, - ): - return await self.base.comments( - oid=id, - type=type, - sort=sort, - page=page, - pagesize=size, - ) diff --git a/test/test_bilibili_v2.py b/test/test_bilibili_v2.py index 5c88958d..cfae9616 100644 --- a/test/test_bilibili_v2.py +++ b/test/test_bilibili_v2.py @@ -40,23 +40,6 @@ def test_seasonrecommend(client: TestClient): assert response.json()["code"] == 0 -def test_comments(client: TestClient): - response = client.get("comments", params={"aid": 810872}) - assert response.status_code == 200 - assert response.json()["code"] == 0 - - -def test_season_comments(client: TestClient): - response = client.get("comments", params={"season_id": 425, "index": 1}) - print(response.text) - if response.status_code == 200: - assert response.json()["code"] == 0 - elif response.status_code == 400: - pytest.skip("Your region does not support getting comments from bangumi") - else: - raise AssertionError(f"{response.status_code=} is not expected") - - def test_search(client: TestClient): response = client.get("search", params={"keyword": "railgun"}) assert response.status_code == 200 diff --git a/test/test_bilibili_v3.py b/test/test_bilibili_v3.py index e1414097..54bf52e2 100644 --- a/test/test_bilibili_v3.py +++ b/test/test_bilibili_v3.py @@ -89,9 +89,3 @@ def test_search_suggestion(client: TestClient): response = client.get("search_suggestion", params={"keyword": "paperclip"}) assert response.status_code == 200 assert response.json()["code"] == 0 - - -def test_comments(client: TestClient): - response = client.get("comments", params={"id": 810872}) - assert response.status_code == 200 - assert response.json()["code"] == 0