Skip to content

Commit

Permalink
Merge branch 'master' into 1.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	bilix/sites/bilibili/informer.py
  • Loading branch information
HFrost0 committed Jan 27, 2024
2 parents fb442c3 + 282ad45 commit 6aee084
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
30 changes: 16 additions & 14 deletions bilix/sites/bilibili/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ async def get_list_info(client: httpx.AsyncClient, url_or_sid: str, ):
meta = json.loads(res.text)
mid = meta['data']['meta']['mid']
params = {'mid': mid, 'series_id': sid, 'ps': meta['data']['meta']['total']}
list_res, up_res = await asyncio.gather(
list_res, up_info = await asyncio.gather(
req_retry(client, 'https://api.bilibili.com/x/series/archives', params=params),
req_retry(client, f'https://api.bilibili.com/x/space/acc/info?mid={mid}'))
list_info, up_info = json.loads(list_res.text), json.loads(up_res.text)
list_name, up_name = meta['data']['meta']['name'], up_info['data']['name']
get_up_info(client, str(mid)),
)
list_info = json.loads(list_res.text)
list_name = meta['data']['meta']['name']
up_name = up_info.get('name', '')
bvids = [i['bvid'] for i in list_info['data']['archives']]
return list_name, up_name, bvids

Expand Down Expand Up @@ -211,14 +213,14 @@ async def get_up_info(client: httpx.AsyncClient, url_or_mid: str):

class Media(BaseModel):
base_url: str
backup_url: List[str] = None
size: int = None
width: int = None
height: int = None
suffix: str = None
quality: str = None
codec: str = None
segment_base: dict = None
backup_url: Optional[List[str]] = None
size: Optional[int] = None
width: Optional[int] = None
height: Optional[int] = None
suffix: Optional[str] = None
quality: Optional[str] = None
codec: Optional[str] = None
segment_base: Optional[dict] = None

@property
def urls(self):
Expand Down Expand Up @@ -328,7 +330,7 @@ class Status(BaseModel):
reply: int = Field(description="回复数")
favorite: int = Field(description="收藏数")
share: int = Field(description="分享数")
follow: int = Field(default=None, description="追剧数/追番数")
follow: Optional[int] = Field(default=None, description="追剧数/追番数")

@field_validator('view', mode="before")
@classmethod
Expand All @@ -350,7 +352,7 @@ class VideoInfo(BaseModel):
pages: List[Page] # [[p_name, p_url], ...]
img_url: str
status: Status
bvid: str = None
bvid: Optional[str] = None
dash: Optional[Dash] = None
other: Optional[List[Media]] = None # durl resource: flv, mp4.

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"aiofiles>=0.8.0",
Expand Down

0 comments on commit 6aee084

Please sign in to comment.