Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Error encountered getting user videos: TikTokApi.exceptions.EmptyResponseException: None -> TikTok returned an empty response #1104

Open
paul-puzzless opened this issue Jan 13, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@paul-puzzless
Copy link

Describe the bug

I'm currently facing the following issue acquiring user video data: TikTokApi.exceptions.EmptyResponseException: None -> TikTok returned an empty response

The buggy code

from TikTokApi import TikTokApi
import asyncio
import os

ms_token = os.environ.get(
    "ms_token", None
)  # set your own ms_token, think it might need to have visited a profile


async def user_example():
    async with TikTokApi() as api:
        await api.create_sessions(
            ms_tokens=[ms_token],
            num_sessions=1,
            sleep_after=3,
        )
        user = api.user("therock")

        async for video in user.videos(count=30):
            print(video)
            print(video.as_dict)


if __name__ == "__main__":
    asyncio.run(user_example())

Expected behavior

Video information printed out as dict

Error Trace (if any)

2024-01-13 23:15:22,402 - TikTokApi.tiktok - ERROR - Got an unexpected status code: {'userInfo': {'user': {}, 'stats': {}, 'shareMeta': {}}}
2024-01-13 23:15:22,402 - TikTokApi.tiktok - ERROR - Got an unexpected status code: {'userInfo': {'user': {}, 'stats': {}, 'shareMeta': {}}}
Traceback (most recent call last):
  File "/Users/p/Repositories/content-downloader/__main__.py", line 27, in <module>
    asyncio.run(user_example())
  File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/p/Repositories/content-downloader/__main__.py", line 21, in user_example
    async for video in user.videos(count=30):
  File "/Users/p/Library/Caches/pypoetry/virtualenvs/content-downloader-LZhmm4ia-py3.11/lib/python3.11/site-packages/TikTokApi/api/user.py", line 112, in videos
    await self.info(**kwargs)
  File "/Users/p/Library/Caches/pypoetry/virtualenvs/content-downloader-LZhmm4ia-py3.11/lib/python3.11/site-packages/TikTokApi/api/user.py", line 87, in info
    self.__extract_from_data()
  File "/Users/p/Library/Caches/pypoetry/virtualenvs/content-downloader-LZhmm4ia-py3.11/lib/python3.11/site-packages/TikTokApi/api/user.py", line 204, in __extract_from_data
    data["userInfo"]["user"]["id"],
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
KeyError: 'id'

Desktop:

  • OS: macOS Sonoma 14.2.1
  • TikTokApi Version: 6.2.0

Additional context

I've also tried to trigger this request manually. This is the output I get:

{"userInfo": {"user": {},"stats": {},"shareMeta": {}}}

This issue seems to be somehow related: #1097

@paul-puzzless paul-puzzless added the bug Something isn't working label Jan 13, 2024
@Yogabayu
Copy link

same with me, any updates ?

@Bringers
Copy link

I get the same error on all of the examples except for the "get video information" about a specific video.
Do you manage to succeed with the other examples?

@jesse-moderwell
Copy link

Same here

@jpratt9
Copy link

jpratt9 commented Jan 29, 2024

Launch the browser with headless=False. You should see that it prompts for you to sign in. We'll probably need some custom playwright code to get around this prompt whenever it pops up.

@angelopouloschristos
Copy link

Temporary fix to it : in "tiktok.py" line 206, change headless=True, to false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants