From 3d8bda787ec6b42faff4bd7fa22ed2d733247daa Mon Sep 17 00:00:00 2001 From: David Teather <34144122+davidteather@users.noreply.github.com> Date: Wed, 23 Dec 2020 11:16:31 -0500 Subject: [PATCH 1/2] Fix non-latin-1 on getUserObject & getSecuid --- TikTokApi/tiktok.py | 8 ++++---- setup.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/TikTokApi/tiktok.py b/TikTokApi/tiktok.py index 77f6cf15..9a93873e 100644 --- a/TikTokApi/tiktok.py +++ b/TikTokApi/tiktok.py @@ -1102,11 +1102,11 @@ def getUser(self, username, **kwargs) -> dict: did, ) = self.__process_kwargs__(kwargs) r = requests.get( - "https://tiktok.com/@{}?lang=en".format(username), + "https://tiktok.com/@{}?lang=en".format(quote(username)), headers={ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "authority": "www.tiktok.com", - "path": "/{}".format(username), + "path": "/@{}".format(quote(username)), "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Host": "www.tiktok.com", @@ -1484,11 +1484,11 @@ def get_music_title(self, id, **kwargs): def get_secUid(self, username, **kwargs): r = requests.get( - "https://tiktok.com/@{}?lang=en".format(username), + "https://tiktok.com/@{}?lang=en".format(quote(username)), headers={ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "authority": "www.tiktok.com", - "path": "/{}".format(username), + "path": "/@{}".format(quote(username)), "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Host": "www.tiktok.com", diff --git a/setup.py b/setup.py index cd127137..6ea12fd9 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name="TikTokApi", packages=["TikTokApi"], - version="3.8.6", + version="3.8.7", license="MIT", description="The Unofficial TikTok API Wrapper in Python 3.", author="David Teather", From 7165a4c7aab3955f92d59cf2e2efd6d3e56f6b8b Mon Sep 17 00:00:00 2001 From: David Teather <34144122+davidteather@users.noreply.github.com> Date: Wed, 23 Dec 2020 11:26:11 -0500 Subject: [PATCH 2/2] Fix default base --- TikTokApi/tiktok.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TikTokApi/tiktok.py b/TikTokApi/tiktok.py index 9a93873e..f5a7770a 100644 --- a/TikTokApi/tiktok.py +++ b/TikTokApi/tiktok.py @@ -548,7 +548,7 @@ def userPage( ) = self.__process_kwargs__(kwargs) kwargs["custom_did"] = did - api_url = "https://m.tiktok.com/api/item_list/?{}&count={}&id={}&type=1&secUid={}" "&minCursor={}&maxCursor={}&sourceType=8&appId=1233®ion={}&language={}".format( + api_url = BASE_URL + "api/item_list/?{}&count={}&id={}&type=1&secUid={}" "&minCursor={}&maxCursor={}&sourceType=8&appId=1233®ion={}&language={}".format( self.__add_new_params__(), page_size, str(userID),