-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New: add new ImagePost FeedItem model #330
base: master
Are you sure you want to change the base?
Changes from all commits
a8ca573
30987c5
2c5d91c
a710d19
add517f
2c4a3b2
1171973
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from typing import ClassVar, List | ||
from typing import ClassVar, List, Optional | ||
|
||
from pydantic import BaseModel, HttpUrl | ||
|
||
|
@@ -80,8 +80,8 @@ class VideoInfo(BaseModel): | |
duration: int | ||
ratio: str | ||
cover: HttpUrl | ||
play_addr: HttpUrl | ||
download_addr: HttpUrl | ||
play_addr: Optional[HttpUrl] | ||
download_addr: Optional[HttpUrl] | ||
|
||
class Config: | ||
fields: ClassVar[dict] = { | ||
|
@@ -94,6 +94,31 @@ def original_video_url(self) -> str: | |
return f"https://api2.musical.ly/aweme/v1/playwm/?video_id={self.id}" | ||
|
||
|
||
class ImageUrls(BaseModel): | ||
url_list: List[HttpUrl] | ||
|
||
class Config: | ||
fields: ClassVar[dict] = {"url_list": "urlList"} | ||
|
||
|
||
class ImageInfo(BaseModel): | ||
image_height: int | ||
image_width: int | ||
image_url: ImageUrls | ||
|
||
class Config: | ||
fields: ClassVar[dict] = { | ||
"image_url": "imageURL", | ||
"image_width": "imageWidth", | ||
"image_height": "imageHeight", | ||
} | ||
|
||
|
||
class ImagePostlInfo(BaseModel): | ||
cover: ImageInfo | ||
images: List[ImageInfo] | ||
|
||
|
||
class FeedItem(BaseModel): | ||
id: str | ||
desc: str | ||
|
@@ -102,11 +127,13 @@ class FeedItem(BaseModel): | |
music: MusicInfo | ||
stats: StatisticsInfo | ||
video: VideoInfo | ||
image_post: ImagePostlInfo = None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry late response. I made it optional as it is not a property that is returned when it is a standard video. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I now understand your comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. image_post: Optional[ImagePostlInfo] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you @Gr3gnov, I can not test it properly right now, I will try to push it tomorrow. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh! And I will probably rename that class to ImagePostInfo. |
||
challenges: List[ChallengeInfo] = [] | ||
|
||
class Config: | ||
fields: ClassVar[dict] = { | ||
"create_time": "createTime", | ||
"image_post": "imagePost", | ||
} | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
= None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I assume you would keep this line as it is, right?