[BUG] - TikTok sent invalid JSON back
See original GitHub issueRead Below!!! If this doesn’t fix your issue delete these two lines
You may need to install chromedriver for your machine globally. Download it here and add it to your path.
Describe the bug TikTok sent invalid JSON back.
The buggy code
Please insert the code that is throwing errors or is giving you weird unexpected results.
from TikTokApi import TikTokApi
import random
import os
api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None))
did = str(random.randint(10000, 999999999))
t = api.byUsername('therock', did=did, custom_verifyFp='your_verify_fp')[0]
print(t)
v_bytes = api.get_Video_By_TikTok(t, did=did, custom_verifyFp='your_verify_fp')
with open("test.mp4", 'wb') as o:
o.write(v_bytes)
Expected behavior
A clear and concise description of what you expected to happen.
Error Trace (if any)
Put the error trace below if there’s any error thrown.
# Error Trace Here
ERROR:root:TikTok response: illegal request… ERROR:root:Converting response to JSON failed ERROR:root:Expecting value: line 1 column 1 (char 0) Traceback (most recent call last): File “C:\Users\john\anaconda3\envs\tiktok_new\lib\site-packages\TikTokApi\tiktok.py”, line 173, in getData json = r.json() File “C:\Users\john\anaconda3\envs\tiktok_new\lib\site-packages\requests\models.py”, line 900, in json return complexjson.loads(self.text, **kwargs) File “C:\Users\john\anaconda3\envs\tiktok_new\lib\json_init_.py”, line 348, in loads return _default_decoder.decode(s) File “C:\Users\john\anaconda3\envs\tiktok_new\lib\json\decoder.py”, line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File “C:\Users\john\anaconda3\envs\tiktok_new\lib\json\decoder.py”, line 355, in raw_decode raise JSONDecodeError(“Expecting value”, s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File “temp.py”, line 6, in <module> t = api.byUsername(‘therock’, did=did, custom_verifyFp=‘your_verify_fp’)[0] File “C:\Users\john\anaconda3\envs\tiktok_new\lib\site-packages\TikTokApi\tiktok.py”, line 493, in byUsername **kwargs, File “C:\Users\john\anaconda3\envs\tiktok_new\lib\site-packages\TikTokApi\tiktok.py”, line 451, in userPosts res = self.getData(url=api_url, **kwargs) File “C:\Users\john\anaconda3\envs\tiktok_new\lib\site-packages\TikTokApi\tiktok.py”, line 191, in getData raise JSONDecodeFailure() from e TikTokApi.exceptions.JSONDecodeFailure: TikTok sent invalid JSON back
Desktop (please complete the following information):
- OS: [e.g. Windows 10]
- TikTokApi Version [e.g. 3.3.1] - 3.8.1
Additional context Referred to #374 for bugfix. Add any other context about the problem here.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (1 by maintainers)
Top GitHub Comments
I don’t know how to get it in python. But when I decode tiktok in web after confirming, I get an api like this: “https://www.tiktok.com/node/share/user/@your_tiktok_username?verifyFp=verify_khwsg04i_Kjx9V5Ev_u6d2_4UiG_8p2n_LAsK5DB”
you could instantiate TikTokApi object with the custom_verifyFp=‘yourcookievalue’
api = TikTokApi(custom_verifyFp='yourcookievalue')