I was testing this code and looked promising. The model did not implement ImagePost as a FeedItem, I included the basic classes so that both videos and imagePosts can be successfully handled by the model.
I have not dived in at all, the changes are basically:
Added a new property to the existing FeedItem class, when the item is a regular video, you do not receive the new property, so it is initialized to None.
When the item is ImagePost, it still has video property, but two required properties will be missing, so I made them Optional in the VideoInfo definition:
Lastly I realized that in the new imagePost data, properties with 'image type' values had a consistent structure (imagePost cover, shareCover and images). So I added imagePostInfo model and a new class for these properties:
+ 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]
I was testing this code and looked promising. The model did not implement ImagePost as a FeedItem, I included the basic classes so that both videos and imagePosts can be successfully handled by the model.
I have not dived in at all, the changes are basically:
Added a new property to the existing FeedItem class, when the item is a regular video, you do not receive the new property, so it is initialized to None.
When the item is ImagePost, it still has video property, but two required properties will be missing, so I made them Optional in the VideoInfo definition:
Lastly I realized that in the new imagePost data, properties with 'image type' values had a consistent structure (imagePost cover, shareCover and images). So I added imagePostInfo model and a new class for these properties: