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

Tiktok API not responding to requests #13

Open
Gabe-Kubiak opened this issue Jul 18, 2023 · 3 comments
Open

Tiktok API not responding to requests #13

Gabe-Kubiak opened this issue Jul 18, 2023 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@Gabe-Kubiak
Copy link

Hi Sam, Your tool is a huge convenience and I have been using it for the better part of 8 months. I went to use it again this morning and believe the Tiktok API must have changed their JSON formatting a bit as I'm getting empty responses. I have tried rerunning and believe this is the issue. Please let me know when a fix is available or if you are planning on updating. Thanks.

C:\Users\Gabek\Documents\Projects\Tiktok>save.py bookmarked user_data.json saved
0%| | 0/1027 [00:00<?, ?it/s]ERROR:root:TikTok response:
0%| | 0/1027 [00:00<?, ?it/s]
Traceback (most recent call last):
File "C:\Users\Gabek\Documents\Projects\Tiktok\save.py", line 49, in
tiktok_dict = api.get_tiktok_by_id(tiktok_id, custom_did=did)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Gabek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\TikTokApi\tiktok.py", line 1077, in get_tiktok_by_id
return self.get_data(url=api_url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Gabek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\TikTokApi\tiktok.py", line 298, in get_data
raise EmptyResponseError(
TikTokApi.exceptions.EmptyResponseError: Empty response from Tiktok to https://m.tiktok.com/api/item/detail/?aid=1988&app_name=tiktok_web&device_platform=web&referer=&root_referer=&user_agent=Mozilla%252F5.0%2B%28iPhone%253B%2BCPU%2BiPhone%2BOS%2B12_2%2Blike%2BMac%2BOS%2BX%29%2BAppleWebKit%252F605.1.15%2B%28KHTML%2C%2Blike%2BGecko%29%2BVersion%252F16.4%2BMobile%252F15E148%2BSafari%252F604.1&cookie_enabled=true&screen_width=1531&screen_height=1165&browser_language=&browser_platform=&browser_name=&browser_version=&browser_online=true&ac=4g&timezone_name=&appId=1233&appType=m&isAndroid=False&isMobile=False&isIOS=False&OS=windows&itemId=7255830375207800069&language=en&verifyFp=verify_khr3jabg_V7ucdslq_Vrw9_4KPb_AJ1b_Ks706M8zIJTq&did=837347611&_signature=_02B4Z6wo00f01oSvMbQAAIBCjl6J2SQEMLaEvhUAAMWp71

@samirelanduk
Copy link
Owner

samirelanduk commented Aug 6, 2023

Thanks! I just tried to do my six-weekly backup and yes, I get the same issue. It seems according to davidteather/TikTok-Api#1035 that this is an issue with the TikTok API itself trying to stop these kinds of requests.

There may be a workaround that involves not using the API at all, since the JSON file has all the URLs for the video pages - just need to find a way to turn those HTML file links into MP4 links (which is what the API was doing). Will post back here if I get anything working.

@ksykes
Copy link

ksykes commented Aug 17, 2023

@samirelanduk, I believe I’m having the same issue. Here’s the errors I’m getting:

0%|                                                 | 0/21277 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/Users/kait/Sites/fun/tiktok-save/./save.py", line 49, in <module>
    tiktok_dict = api.get_tiktok_by_id(tiktok_id, custom_did=did)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/TikTokApi/tiktok.py", line 1077, in get_tiktok_by_id
    return self.get_data(url=api_url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/TikTokApi/tiktok.py", line 229, in get_data
    verify_fp, did, signature = self.browser.sign_url(**kwargs)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/TikTokApi/browser.py", line 188, in sign_url
    evaluatedPage = page.evaluate(
                    ^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/playwright/sync_api/_generated.py", line 8701, in evaluate
    self._sync(
  File "/opt/homebrew/lib/python3.11/site-packages/playwright/_impl/_sync_base.py", line 109, in _sync
    return task.result()
           ^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/playwright/_impl/_page.py", line 395, in evaluate
    return await self._main_frame.evaluate(expression, arg)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/playwright/_impl/_frame.py", line 277, in evaluate
    await self._channel.send(
  File "/opt/homebrew/lib/python3.11/site-packages/playwright/_impl/_connection.py", line 61, in send
    return await self._connection.wrap_api_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/playwright/_impl/_connection.py", line 482, in wrap_api_call
    return await cb()
           ^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/playwright/_impl/_connection.py", line 97, in inner_send
    result = next(iter(done)).result()
             ^^^^^^^^^^^^^^^^^^^^^^^^^
playwright._impl._api_types.Error: TypeError: undefined is not an object (evaluating 'S[A][m(a[oprand[1]],oprand[1])]')

This is on MacOS Ventura 13.4.1.

It also looks like a problem parsing the JSON file to me, but I’m not very familiar with Python, so let me know if I should open a separate issue. I hope your workaround works out. :)

@samirelanduk samirelanduk added the help wanted Extra attention is needed label Sep 3, 2023
@jonasthepony
Copy link

jonasthepony commented Sep 28, 2023

It's a bug in the Python API Wrapper davidteather/TikTok-Api#1012

There is a workaround (downgrading playwright and using login cookies) davidteather/TikTok-Api#1012 (comment)

Or you can upgrade the TikTok API Wrapper to V6 where this issue is fixed with pip install --upgrade TikTokApi which requires code changes to tiktok-save

Edit: I tried to get it to run, but it seems the Wrappter API V6 does currently not support saving the video. (video as bytes is not implemented)
Instead I will use yt-dlp to save my favorites now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants