From a8ca573c702daf67c3fe712a6774caf531e2e7b6 Mon Sep 17 00:00:00 2001 From: jbelinchonm Date: Thu, 19 Oct 2023 12:42:06 +0200 Subject: [PATCH 1/7] New: add new ImagePost FeedItem model --- tiktokpy/models/feed.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tiktokpy/models/feed.py b/tiktokpy/models/feed.py index 6aa3852..0c6e572 100644 --- a/tiktokpy/models/feed.py +++ b/tiktokpy/models/feed.py @@ -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] = { @@ -93,6 +93,18 @@ class Config: def original_video_url(self) -> str: return f"https://api2.musical.ly/aweme/v1/playwm/?video_id={self.id}" +class ImageUrls(BaseModel): + urlList: List[HttpUrl] + +class ImageInfo(BaseModel): + imageHeight: int + imageWidth: int + imageURL: ImageUrls + +class ImagePostlInfo(BaseModel): + cover: ImageInfo + images: List[ImageInfo] + shareCover: ImageInfo class FeedItem(BaseModel): id: str @@ -102,6 +114,7 @@ class FeedItem(BaseModel): music: MusicInfo stats: StatisticsInfo video: VideoInfo + imagePost: ImagePostlInfo = None challenges: List[ChallengeInfo] = [] class Config: From 30987c5a3e1949279cc74421db4c93bbcd993313 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 19 Oct 2023 11:01:33 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tiktokpy/models/feed.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tiktokpy/models/feed.py b/tiktokpy/models/feed.py index 0c6e572..7bd6c51 100644 --- a/tiktokpy/models/feed.py +++ b/tiktokpy/models/feed.py @@ -93,19 +93,23 @@ class Config: def original_video_url(self) -> str: return f"https://api2.musical.ly/aweme/v1/playwm/?video_id={self.id}" + class ImageUrls(BaseModel): urlList: List[HttpUrl] + class ImageInfo(BaseModel): imageHeight: int imageWidth: int imageURL: ImageUrls + class ImagePostlInfo(BaseModel): cover: ImageInfo images: List[ImageInfo] shareCover: ImageInfo + class FeedItem(BaseModel): id: str desc: str From 2c5d91c69b66d4536d2819c20dabff11cb077045 Mon Sep 17 00:00:00 2001 From: jbelinchonm Date: Thu, 19 Oct 2023 13:07:42 +0200 Subject: [PATCH 3/7] Fix: Avoid mixcase property names. --- tiktokpy/models/feed.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tiktokpy/models/feed.py b/tiktokpy/models/feed.py index 7bd6c51..ebb7bb7 100644 --- a/tiktokpy/models/feed.py +++ b/tiktokpy/models/feed.py @@ -95,19 +95,33 @@ def original_video_url(self) -> str: class ImageUrls(BaseModel): - urlList: List[HttpUrl] + url_list: List[HttpUrl] + + class Config: + fields: ClassVar[dict] = { + "url_list": "urlList" + } + class ImageInfo(BaseModel): - imageHeight: int - imageWidth: int - imageURL: ImageUrls + 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] - shareCover: ImageInfo + class FeedItem(BaseModel): @@ -124,6 +138,7 @@ class FeedItem(BaseModel): class Config: fields: ClassVar[dict] = { "create_time": "createTime", + "image_post": "imagePost" } From a710d1905adad016c830f96ca16611df653ed280 Mon Sep 17 00:00:00 2001 From: jbelinchonm Date: Thu, 19 Oct 2023 13:12:43 +0200 Subject: [PATCH 4/7] Fix: another ugly mixedcase property --- tiktokpy/models/feed.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tiktokpy/models/feed.py b/tiktokpy/models/feed.py index ebb7bb7..760dfc3 100644 --- a/tiktokpy/models/feed.py +++ b/tiktokpy/models/feed.py @@ -117,13 +117,11 @@ class Config: } - class ImagePostlInfo(BaseModel): cover: ImageInfo images: List[ImageInfo] - class FeedItem(BaseModel): id: str desc: str @@ -132,7 +130,7 @@ class FeedItem(BaseModel): music: MusicInfo stats: StatisticsInfo video: VideoInfo - imagePost: ImagePostlInfo = None + image_post: ImagePostlInfo = None challenges: List[ChallengeInfo] = [] class Config: From add517fe05f6d478874f0349737444ca2e5bb97a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 19 Oct 2023 11:14:21 +0000 Subject: [PATCH 5/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tiktokpy/models/feed.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tiktokpy/models/feed.py b/tiktokpy/models/feed.py index 760dfc3..221c02d 100644 --- a/tiktokpy/models/feed.py +++ b/tiktokpy/models/feed.py @@ -98,10 +98,7 @@ class ImageUrls(BaseModel): url_list: List[HttpUrl] class Config: - fields: ClassVar[dict] = { - "url_list": "urlList" - } - + fields: ClassVar[dict] = {"url_list": "urlList"} class ImageInfo(BaseModel): @@ -111,9 +108,9 @@ class ImageInfo(BaseModel): class Config: fields: ClassVar[dict] = { - "image_url": "imageURL", + "image_url": "imageURL", "image_width": "imageWidth", - "image_height": "imageHeight" + "image_height": "imageHeight", } @@ -134,10 +131,7 @@ class FeedItem(BaseModel): challenges: List[ChallengeInfo] = [] class Config: - fields: ClassVar[dict] = { - "create_time": "createTime", - "image_post": "imagePost" - } + fields: ClassVar[dict] = {"create_time": "createTime", "image_post": "imagePost"} class FeedItems(BaseModel): From 2c4a3b24939a40a9e6d1f310fbaa75c755b34d3c Mon Sep 17 00:00:00 2001 From: jbelinchonm <7533238+jbelinchonm@users.noreply.github.com> Date: Tue, 21 Nov 2023 21:28:53 +0100 Subject: [PATCH 6/7] Update tiktokpy/models/feed.py Co-authored-by: Grigoriy Ivanov <82391045+Gr3gnov@users.noreply.github.com> --- tiktokpy/models/feed.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tiktokpy/models/feed.py b/tiktokpy/models/feed.py index 221c02d..a277c51 100644 --- a/tiktokpy/models/feed.py +++ b/tiktokpy/models/feed.py @@ -131,7 +131,10 @@ class FeedItem(BaseModel): challenges: List[ChallengeInfo] = [] class Config: - fields: ClassVar[dict] = {"create_time": "createTime", "image_post": "imagePost"} + fields: ClassVar[dict] = { + "create_time": "createTime", + "image_post": "imagePost", + } class FeedItems(BaseModel): From 1171973559f14797f7e7750334ac77fa2023bb7e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 21 Nov 2023 20:30:02 +0000 Subject: [PATCH 7/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tiktokpy/models/feed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiktokpy/models/feed.py b/tiktokpy/models/feed.py index a277c51..640f763 100644 --- a/tiktokpy/models/feed.py +++ b/tiktokpy/models/feed.py @@ -134,7 +134,7 @@ class Config: fields: ClassVar[dict] = { "create_time": "createTime", "image_post": "imagePost", - } + } class FeedItems(BaseModel):