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] - TikTokApi.exceptions.EmptyResponseException: None -> TikTok returned an empty response #1188

Open obscure723 opened 3 months ago

obscure723 commented 3 months ago

Describe the bug The TikTokApi is returning an empty response when trying to fetch user information, resulting in an EmptyResponseException.

The buggy code

import logging
from TikTokApi import TikTokApi
import asyncio

TikTokApi(logging_level=logging.INFO)  # SETS LOGGING_LEVEL TO INFO

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

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

        async for playlist in user.playlists():
            print(playlist)

def job():
    asyncio.run(user_example2())

if __name__ == "__main__":
    job()

Expected behavior The code should fetch and print user information, videos, and playlists for the user "therock".

Error Trace (if any)

Traceback (most recent call last):
  File "/app/main.py", line 1033, in <module>
    job()
  File "/app/main.py", line 1021, in job
    asyncio.run(user_example2())
  File "/usr/local/lib/python3.9/dist-packages/nest_asyncio.py", line 30, in run
    return loop.run_until_complete(task)
  File "/usr/local/lib/python3.9/dist-packages/nest_asyncio.py", line 98, in run_until_complete
    return f.result()
  File "/usr/lib/python3.9/asyncio/futures.py", line 201, in result
    raise self._exception
  File "/usr/lib/python3.9/asyncio/tasks.py", line 256, in __step
    result = coro.send(None)
  File "/app/main.py", line 1009, in user_example2
    user_data = await user.info()
  File "/usr/local/lib/python3.9/dist-packages/TikTokApi/api/user.py", line 76, in info
    resp = await self.parent.make_request(
  File "/usr/local/lib/python3.9/dist-packages/TikTokApi/tiktok.py", line 451, in make_request
    raise EmptyResponseException(result, "TikTok returned an empty response")
TikTokApi.exceptions.EmptyResponseException: None -> TikTok returned an empty response

Desktop (please complete the following information):

Additional context

itsEricWu commented 2 months ago

+1

wpz5159582 commented 2 months ago

+1

moonzlo commented 2 months ago

+1

Gereks123 commented 2 months ago

Check out this open issue, might help you resolve the issue! https://github.com/davidteather/TikTok-Api/issues/1179#issuecomment-2315970181

obscure723 commented 2 months ago

thank you.I will review this open issue.

Check out this open issue, might help you resolve the issue! #1179 (comment)

zakrian07 commented 2 months ago

this is not working solution

On Sun, Sep 1, 2024 at 4:27 PM よねかん(YONEDA KAN) @.***> wrote:

thank you.I will review this open issue.

Check out this open issue, might help you resolve the issue! #1179 (comment) https://github.com/davidteather/TikTok-Api/issues/1179#issuecomment-2315970181

— Reply to this email directly, view it on GitHub https://github.com/davidteather/TikTok-Api/issues/1188#issuecomment-2323297634, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPI5XP7SIFEZRHI72E25WLZUL23JAVCNFSM6AAAAABM4WZTYKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRTGI4TONRTGQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Gereks123 commented 2 months ago

this is not working solution On Sun, Sep 1, 2024 at 4:27 PM よねかん(YONEDA KAN) @.> wrote: thank you.I will review this open issue. Check out this open issue, might help you resolve the issue! #1179 (comment) <#1179 (comment)> — Reply to this email directly, view it on GitHub <#1188 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPI5XP7SIFEZRHI72E25WLZUL23JAVCNFSM6AAAAABM4WZTYKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRTGI4TONRTGQ . You are receiving this because you are subscribed to this thread.Message ID: @.>

https://github.com/davidteather/TikTok-Api/issues/1179#issuecomment-2325272998