davidteather / TikTok-Api

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

Fix count parameter for hashtag, user, and trending classes #1108

Closed lysmm203 closed 4 months ago

lysmm203 commented 5 months ago

There's no issue that pertains to this fix so I'll briefly describe it here. When downloading videos through the hashtag, user, and trending classes by calling the video function, it does not use the count parameter to limit the number of video downloads. For example, given this code snippet:

async def foo():
    async with TikTokApi() as api:
        await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3, headless=False)
        async for video in api.trending.videos(count=5):
            print(video.id)

asyncio.run(foo())

we would expect 5 ids to be printed. However, since the count values are hard coded in the function, the input count=5 gets overwritten.

jhl8041 commented 4 months ago

@lysmm203 This needs to be fixed.. I was quite confused by this issue. Thank you