Skip to content

Commit

Permalink
新增Major类型
Browse files Browse the repository at this point in the history
  • Loading branch information
Polyisoprene committed Jul 20, 2023
1 parent fadd0f0 commit fa82b00
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
25 changes: 22 additions & 3 deletions dynamicadaptor/Majors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import List, Optional,Union

from pydantic import BaseModel, Json

Expand All @@ -7,7 +7,7 @@
class DrawItem(BaseModel):
height: int
width: int
src: str
url: str


class Draw(BaseModel):
Expand Down Expand Up @@ -131,14 +131,32 @@ class UgcSeason(BaseModel):
class MNone(BaseModel):
tips:str

class Emoji(BaseModel):
icon_url: Optional[str]
text: Optional[str]
type: Union[int, str, None]
class RichTextNodes(BaseModel):
type:str
text:str
orig_text: Optional[str]
emoji: Optional[Emoji]

class Summary(BaseModel):
text:str
rich_text_nodes:List[RichTextNodes]

class OPUS(BaseModel):
pics:Optional[List[DrawItem]]
summary:Summary
title:str
# class MajorDetail(Enum):
# """
# 类型 动态类型 示例动态
# draw 图片 741262186696933397
# archive 视频 739851131027456201
# live_rcmd 直播
# ugc_season 合集 755703296984875092
# article 专栏 720929682647679043
# article 专栏 819930757423169558
# common 装扮 活动等 551309621391003098/743181895357956118
# music 音乐 692040384055869478
# pgc 电影/电视剧等 633983562923638785
Expand All @@ -161,4 +179,5 @@ class Major(BaseModel):
courses: Optional[Courses]
live: Optional[Live]
ugc_season: Optional[UgcSeason]
opus:Optional[OPUS]
none:Optional[MNone]
12 changes: 6 additions & 6 deletions tests/web_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import asyncio

async def run():
# dyn_id = "75570329698487509"
url = "https://api.bilibili.com/x/polymer/web-dynamic/v1/detail?timezone_offset=-480&id=779490646924722209&features=itemOpusStyle"
dyn_id = "698569146564083856"
url = f"https://api.bilibili.com/x/polymer/web-dynamic/v1/detail?timezone_offset=-480&id={dyn_id}&features=itemOpusStyle"
headers = {
"referer": "https://t.bilibili.com/779490646924722209",
"origin":"https://t.bilibili.com"
"referer": f"https://t.bilibili.com/{dyn_id}",
"origin":"https://t.bilibili.com",
"User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
}
res = httpx.get(url, headers=headers).json()
# print(res)
result = await formate_message("web", res["data"]["item"])
print(result.forward.additional)
print(result.major.opus)

if __name__ == "__main__":

Expand Down

0 comments on commit fa82b00

Please sign in to comment.