davidteather / TikTok-Api

The Unofficial TikTok API Wrapper In Python
https://davidteather.github.io/TikTok-Api
MIT License
4.9k stars 982 forks source link

[BUG] - user.videos returns empty response #1193

Open prodbioject opened 2 months ago

prodbioject commented 2 months ago

Describe the bug

I have tried other functions, they work. Only facing issues when I want to access user.videos, I get an empty response

The buggy code

async with TikTokApi() as api:
        await api.create_sessions(ms_tokens=[ms_token],
                                  num_sessions=1,
                                  sleep_after=3,
                                  headless=False)
        results = 10
        async for video in api.user("therock").videos(count=10):
            print(video)
            print(video.as_dict)

Expected behavior

Get a bunch of video JSON

Error Trace (if any)

Traceback (most recent call last):
  File "/path/to/your/project/backend/test_api.py", line 92, in <module>
    asyncio.run(main())
  File "/path/to/python@3.12/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/path/to/python@3.12/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/python@3.12/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/path/to/your/project/backend/test_api.py", line 89, in main
    await user_example()
  File "/path/to/your/project/backend/test_api.py", line 67, in user_example
    async for video in api.user("therock").videos(count=10):
  File "/path/to/venv/lib/python3.12/site-packages/TikTokApi/api/user.py", line 177, in videos
    resp = await self.parent.make_request(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/venv/lib/python3.12/site-packages/TikTokApi/tiktok.py", line 462, in make_request
    raise EmptyResponseException(
TikTokApi.exceptions.EmptyResponseException: None -> TikTok returned an empty response

Desktop (please complete the following information):

Additional context

This call was working about 3 weeks ago, don't know what changed, but the user.videos is the only data in my app that I cannot access, the rest seems to work fine

wpz5159582 commented 2 months ago

response : {'log_pb': {'impr_id': '20240918071705E35284F2FA7F9D0324F1'}, 'statusCode': 10201, 'statusMsg': '', 'status_code': 10201, 'status_msg': ''} But I don't know what this is and how to solve it

Gereks123 commented 3 weeks ago

In personal experience when I started using proxies and added small delays between each account I fetch, the empty answers came back less and less.

You might get bot detected and you might not. Try using rotating proxies, if you encounter the "Empty response" run it again with a different IP from the proxy.

I'm personally using Bright Data Data Center proxies