avilash / TikTokAPI-Python

TikTok API Python Wrapper
http://avilashkumar.com/TikTokAPI-Python/
MIT License
443 stars 114 forks source link

The api randomly does not let me get data from the getVideosByUserName method #29

Open HerbeMalveillante opened 3 years ago

HerbeMalveillante commented 3 years ago

I have a bot that retrieves the tik tok of an user every minute. But now It just gives this key error: line 118, in getVideosByUserName user_obj = user_data["userInfo"]["user"] KeyError: 'userInfo'

Here is my code :

def get_tikTok(username):
    api = TikTokAPI(cookie=None)
    videos_obj = api.getVideosByUserName(username, count=3)
thanatos11 commented 3 years ago

ok, try to extend the library, and make your own get video by user id and secu_id. Sinve the getVideoByUserName, calles 2 endpoints:

  1. the get user info endpoint
  2. get the user videos by user id and user secu id

this way you are pushing to much, and they might bann you. when they do that, you are going to miss the userInfo key, and that will be empty, so you will get this error. If you repeat this process for known users, save their user_id and secu_id to use later, this way you optimize the connections.

ghost commented 3 years ago

I am confuse on how I can do this, I am working on a school project and I am getting the same error as Harbe, can you show an example thanatos.