davidteather / TikTok-Api

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

[BUG] - by_sound method does not seem to work anymore #589

Closed bravma closed 3 years ago

bravma commented 3 years ago

the by_sound method throws an error KeyError: 'items'

api.by_sound

Expected behavior

Should return a list of TikTok's containing this sound

Error Trace

Traceback (most recent call last):
  File "tiktok_crawler.py", line 152, in <module>
    res = api.by_sound(data_handler.df.music_id.iloc[0])
  File "/usr/local/lib/python3.8/dist-packages/TikTokApi/tiktok.py", line 822, in by_sound
    for t in res["itemList"]:
KeyError: 'itemList'

Desktop

davidteather commented 3 years ago

I'm able to retrieve the sound with the following code

from TikTokApi import TikTokApi
api = TikTokApi.get_instance(custom_verifyFp="verify_sdfdsfsdfsdfsdfdsf", use_test_endpoints=True)

print(api.by_sound('6885449331428558861'))

Maybe you're getting hit by a captcha that isn't formatted correctly? Maybe add print(res) to line 822 of tiktok.py

bravma commented 3 years ago

Thanks for your reply and for your great work with the API! It seems like the mistake was on my side. TikTok simply couldn't find the provided Music ID (even though I just crawled it a few minutes ago... It's a bit annoying that the IDs somehow get changed...).

liamengland1 commented 3 years ago

what was the id?