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

TypeError: 'coroutine' object is not iterable #187

Open
bfeldman89 opened this issue Jul 17, 2021 · 1 comment
Open

TypeError: 'coroutine' object is not iterable #187

bfeldman89 opened this issue Jul 17, 2021 · 1 comment

Comments

@bfeldman89
Copy link

(toks) 11:59 ~/code/toks (master)$ python
Python 3.8.0 (default, Nov 14 2019, 22:29:45) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> from tiktokpy import TikTokPy
>>> 
>>> 
>>> async def main():
...     async with TikTokPy() as bot:
...         user_feed_items = TikTokPy().user_feed(username="bfeldman89", amount=5)
...         for item in user_feed_items:
...             print("Plays: ", item.stats.plays)
...             print("Shares: ", item.stats.shares)
...             print("Likes: ", item.stats.likes)
... 
>>> 
>>> asyncio.run(main())
2021-07-17 12:01:13 | INFO | 🥳 TikTokPy initialized. Version: 0.8.9
2021-07-17 12:01:14 | INFO | 🔧 Settings successfully loaded
2021-07-17 12:01:14 | INFO | 🛑 Cookies not found, anonymous mode
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 108773488/108773488 [00:00<00:00, 264727549.24it/s]
2021-07-17 12:01:27 | INFO | 🥳 TikTokPy initialized. Version: 0.8.9
2021-07-17 12:01:27 | INFO | 🔧 Settings successfully loaded
2021-07-17 12:01:27 | INFO | 🛑 Cookies not found, anonymous mode
2021-07-17 12:01:27 | INFO | ✋ TikTokPy finished working. Session lasted: 14 seconds
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete
    return future.result()
  File "<stdin>", line 4, in main
TypeError: 'coroutine' object is not iterable
@firas1998
Copy link

I know this is old but for anyone still facing this problem the problem is the TikTokPy().user_feed is async and has to be awaited like this: user_feed_items = await TikTokPy().user_feed(username="bfeldman89", amount=5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants