TikTok-Api icon indicating copy to clipboard operation
TikTok-Api copied to clipboard

by_trending...api.trending.videos() returns nothing.

Open LordHandLee opened this issue 2 years ago • 11 comments

Both by_trending in v3 and v4/v5 api.trending.videos() returns nothing.

I encountered this issue several days ago when my automated script quit returning results. My first assumption is that the cookie expired. Upon trying to obtain a new cookie, custom_verify_fp is no longer available. So after reading thru some comments, I noticed custom_verify_fp was removed from the setup video and also that it is no longer needed in v4/v5. If this is the case, it is not obvious that this is what you need to do. An updated README is in order. However, upon upgrading to the new version, it still returned the same result which is null, thus not working. How do I resolve this mistake if indeed it is a mistake on my part? Otherwise, can you please confirm this is a major issue? In which case, I would be willing to help debug. Many thanks.

Please add any relevant code that is giving you unexpected results.

Preferably the smallest amount of code to reproduce the issue. from TikTokApi import TikTokApi today_date = str(date.today())

api = TikTokApi() print("working") for trending_video in api.trending.videos(): print(trending_video)

LordHandLee avatar Mar 14 '22 22:03 LordHandLee

Both by_trending in v3 and v4/v5 api.trending.videos() returns nothing.

I encountered this issue several days ago when my automated script quit returning results. My first assumption is that the cookie expired. Upon trying to obtain a new cookie, custom_verify_fp is no longer available. So after reading thru some comments, I noticed custom_verify_fp was removed from the setup video and also that it is no longer needed in v4/v5. If this is the case, it is not obvious that this is what you need to do. An updated README is in order. However, upon upgrading to the new version, it still returned the same result which is null, thus not working. How do I resolve this mistake if indeed it is a mistake on my part? Otherwise, can you please confirm this is a major issue? In which case, I would be willing to help debug. Many thanks.

Please add any relevant code that is giving you unexpected results.

Preferably the smallest amount of code to reproduce the issue. from TikTokApi import TikTokApi today_date = str(date.today())

api = TikTokApi() print("working") for trending_video in api.trending.videos(): print(trending_video)

Hi, i am having the same issue as well, maybe tiktok changed its site html attributes or something. will wait for solution :)

firaki12345-cmd avatar Mar 15 '22 13:03 firaki12345-cmd

I'm having the same problem. I have tried looking for the verify cookie but it is no longer present.

Simone0401 avatar Mar 16 '22 17:03 Simone0401

IMPORTAN UPDATE:

I have just found this release updated 2 days ago and it works. Thanks to roman-dmytriv. Link: TikTok-Api.

The code that I tried is below:

from TikTokApi import TikTokApi
# `msToken` is an optional parameter, pass it once requests are not working
api = TikTokApi()

for video in api.trending.videos(get_all=True):
    print(video.as_dict)

Let's hope it helps you.

Edit: I noted if my test file is inside examples folder doesn't work. So I moved it in the main folder and now is OK.

Simone0401 avatar Mar 16 '22 18:03 Simone0401

@Simone0401 I have found another problem.

Not everywhere user.videos(get_all=True) is working.

It works on my machine but not for other guys unfortunately. TikTokCaptchaError raised.

tech-alpiner avatar Mar 17 '22 17:03 tech-alpiner

@roman-dmytriv could you comment with an example of file that doesn't work on all PCs?

Simone0401 avatar Mar 18 '22 14:03 Simone0401

@roman-dmytriv could you comment with an example of file that doesn't work on all PCs?

For me the user_example.py fails on line 6 (I'm on the latest commit). I think its an issue with the ttwid? Do we still need to pass in our own parameters to TikTokApi() in the latest version?

EDIT: Seems the bug I'm encountering is this one #861

Lackaday9 avatar Mar 21 '22 23:03 Lackaday9

@Lackaday9 I am encountering your same problem on my Windows PC running trending videos test. I have tried the exactly same code on my Mac M1 and it works fine. On Windows I have these error codes:

Traceback (most recent call last):
  File "C:/Users/SIMOL/Downloads/TikTok-Api-5.1.2/TikTok-Api-5.1.2/test.py", line 8, in <module>
    for video in user.videos(get_all=True):
  File "C:\Users\SIMOL\Downloads\TikTok-Api-5.1.2\TikTok-Api-5.1.2\TikTokApi\api\user.py", line 134, in videos
    self.__find_attributes()
  File "C:\Users\SIMOL\Downloads\TikTok-Api-5.1.2\TikTok-Api-5.1.2\TikTokApi\api\user.py", line 265, in __find_attributes
    for u in self.parent.search.users(self.username):
  File "C:\Users\SIMOL\Downloads\TikTok-Api-5.1.2\TikTok-Api-5.1.2\TikTokApi\api\search.py", line 85, in search_type
    ttwid = spawn.cookies["ttwid"]
  File "C:\Users\SIMOL\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\cookies.py", line 328, in __getitem__
    return self._find_no_duplicates(name)
  File "C:\Users\SIMOL\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\cookies.py", line 399, in _find_no_duplicates
    raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
KeyError: "name='ttwid', domain=None, path=None"

I tried adding msToken in TikTokApi constructor but it's the same.

Simone0401 avatar Mar 22 '22 09:03 Simone0401

I am getting a similar error trying to get trending video.
The commit SHA I'm using is the latest cb92162346f014919096b02f32d9af1f8728d4dc from March 21st.

your_script.py

  1 from TikTokApi import TikTokApi
  2 # `msToken` is an optional parameter, pass it once requests are not working
  3 api = TikTokApi()
  4 
  5 for video in api.trending.videos(get_all=True):
  6     print(video.as_dict)

The following command outputs nothing docker run -v TikTokApi --rm tiktokapi:latest python your_script.py

The following command hangs python your_script.py

yaizudamashii avatar Mar 28 '22 23:03 yaizudamashii

I got same issue by api.trending.videos also i set proxy for TikTokApi because tiktok banned my country anyone have solution ?

SARIBEG10 avatar Apr 13 '22 07:04 SARIBEG10

from TikTokApi import TikTokApi

with TikTokApi(proxy="proxy") as api: for v in api.trending.videos(): print(v.uthor.username)

return nothing

SARIBEG10 avatar Apr 13 '22 07:04 SARIBEG10

@Lackaday9 I am encountering your same problem on my Windows PC running trending videos test. I have tried the exactly same code on my Mac M1 and it works fine. On Windows I have these error codes:

Traceback (most recent call last):
  File "C:/Users/SIMOL/Downloads/TikTok-Api-5.1.2/TikTok-Api-5.1.2/test.py", line 8, in <module>
    for video in user.videos(get_all=True):
  File "C:\Users\SIMOL\Downloads\TikTok-Api-5.1.2\TikTok-Api-5.1.2\TikTokApi\api\user.py", line 134, in videos
    self.__find_attributes()
  File "C:\Users\SIMOL\Downloads\TikTok-Api-5.1.2\TikTok-Api-5.1.2\TikTokApi\api\user.py", line 265, in __find_attributes
    for u in self.parent.search.users(self.username):
  File "C:\Users\SIMOL\Downloads\TikTok-Api-5.1.2\TikTok-Api-5.1.2\TikTokApi\api\search.py", line 85, in search_type
    ttwid = spawn.cookies["ttwid"]
  File "C:\Users\SIMOL\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\cookies.py", line 328, in __getitem__
    return self._find_no_duplicates(name)
  File "C:\Users\SIMOL\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\cookies.py", line 399, in _find_no_duplicates
    raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
KeyError: "name='ttwid', domain=None, path=None"

I tried adding msToken in TikTokApi constructor but it's the same.

Looks like there is a bug. Do not have much time to fix it right now, unfortunately, will try to find some and polish the solution.

tech-alpiner avatar Apr 15 '22 12:04 tech-alpiner

Is this solved? the trending python script is just hanging for me

patrikrask avatar Mar 19 '23 14:03 patrikrask

Is this solved? the trending python script is just hanging for me

same here

sonnochio avatar Mar 21 '23 14:03 sonnochio

fixed v6

davidteather avatar Aug 08 '23 22:08 davidteather