Skip to content

Commit

Permalink
fix: optional for pydantic validation
Browse files Browse the repository at this point in the history
  • Loading branch information
HFrost0 committed Jan 23, 2024
1 parent f344833 commit c4c2e6d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions bilix/sites/bilibili/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ async def get_up_info(client: httpx.AsyncClient, url_or_mid: str, pn=1, ps=30, o

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 @@ -299,7 +299,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 @@ -321,7 +321,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

0 comments on commit c4c2e6d

Please sign in to comment.