You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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?
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.
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
Expected behavior
Video information printed out as dict
Error Trace (if any)
Desktop:
Additional context
I've also tried to trigger this request manually. This is the output I get:
This issue seems to be somehow related: #1097
The text was updated successfully, but these errors were encountered: