From e338b5e4424e49ccdc3ef6bfac060edb51e8c20e Mon Sep 17 00:00:00 2001 From: Ayyub Alzahem <46811238+0aub@users.noreply.github.com> Date: Sun, 24 Jul 2022 21:55:07 +0300 Subject: [PATCH] Add files via upload --- tiktok_dl.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tiktok_dl.py b/tiktok_dl.py index b00f6e9..bee045f 100644 --- a/tiktok_dl.py +++ b/tiktok_dl.py @@ -190,12 +190,23 @@ def update_user(): path = "/api/user/detail/?uniqueId={}&msToken={}".format( USERNAME, PARAMS["msToken"] ) - # update secret user id in params dictionery with the extracted secUid from user detail api - response = tiktok_request(path, x_tt_params=None) - PARAMS["secUid"] = response["userInfo"]["user"]["secUid"] - # assign global user details object - global USER_DETAILS - USER_DETAILS = response["userInfo"] + # catch if the user input was invalid + try: + # update secret user id in params dictionery with the extracted secUid from user detail api + response = tiktok_request(path, x_tt_params=None) + PARAMS["secUid"] = response["userInfo"]["user"]["secUid"] + # assign global user details object + global USER_DETAILS + USER_DETAILS = response["userInfo"] + except: + raise Exception( + f""" + We could not find data about {USERNAME}. + Take a look to these tips and try again. + - Do not add @ in the beginning of the username + - This script does not accept private accounts yet + """ + ) # function to get all user posts ids