GithubHelp home page GithubHelp logo

samirelanduk / tiktok-save Goto Github PK

View Code? Open in Web Editor NEW
83.0 6.0 12.0 20 KB

A Python tool for backing up your liked and bookmarked videos on tiktok to your computer.

Python 100.00%
tiktok tiktok-downloader data-hoarder

tiktok-save's Introduction

tiktok-save

A Python utility for backing up your liked and bookmarked videos on TikTok. It will download the videos themselves as mp4 files, and associated metadata for each video as JSON.

Before Starting

You will need a JSON export of your TikTok data. TikTok lets you request this from the app, and it can take a few days for them to prepare this, so if you're planning on using this tool soon, consider requesting it now. If you have notifications turned off for TikTok, don't forget to check for it to be ready. You need the JSON version.

Installation

$ git clone https://github.com/samirelanduk/tiktok-save .
$ cd tiktok-save
$ python -m playwright install
$ pip install -r requirements.txt

If you get permission errors, try using sudo or using a virtual environment.

The main dependency here is TikTok-Api - a great unofficial wrapper around the TikTok API. If you have any problems installing things, check the issues/docs there too.

playwright is a headless browser that TikTok-Api uses to access TikTok - you might need sudo privileges to install it, even in a virtual environment. If you still encounter issues, try playwright install-deps.

Use

Create a folder for your liked videos and a folder for your bookmarked videos. Then, from the tiktok-save directory, run:

$ ./save.py liked user_data.json liked_videos_path
$ ./save.py bookmarked user_data.json bookmarked_videos_path

Here user_data.json is the TikTok JSON export, assuming it's in the current directory - provide the path to it if not.

Any failures (where a video no longer exists for example) are saved in a failures.json file, and won't be re-requested on later downloads. If you want to try previous failures, use the --failures argument.

tiktok-save's People

Contributors

arezak avatar jtikey avatar samirelanduk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tiktok-save's Issues

Is this still working?

Hi there! First of all, thanks for making this public!

I am trying to use, and even following all steps and installing all dependences, nothing happens after I run the Use commands.
It only opens a new CMD and quickly closes it.

Can you provide some more support about how to use it?

Best regards!

Problems to save saved and bookmarked videos

Hello.

I followed the installation instruction, and now I wanted to save the video from the user_data.json

But sadly when I run this command, I get this error:

C:\Users\themf\tiktok-save>save.py bookmarked user_data.json bookmarked

C:\Users\themf\tiktok-save>
[main 2021-12-25T13:55:26.345Z] update#setState idle
[main 2021-12-25T13:55:26.400Z] ExtensionHostStarterWorker created
[main 2021-12-25T13:55:27.141Z] Starting extension host with pid 8064 (fork() took 10 ms).
[main 2021-12-25T13:55:56.347Z] update#setState checking for updates
[main 2021-12-25T13:55:56.379Z] update#setState idle
[18980:1225/145726.114:ERROR:gpu_init.cc(440)] Passthrough is not supported, GL is disabled

Can you please help me?

image

TypeError: undefined is not an object

I see a previous instance of this issue #11, but it was closed without being resolved, so I'm opening this to track.

Repro is simple, just follow the README and you'll get this error:

$ python save.py bookmarked user_data.json bookmarked/
  0%|                                                                                           | 0/428 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/Users/dport/github/tiktok-save/save.py", line 49, in <module>
    tiktok_dict = api.get_tiktok_by_id(tiktok_id, custom_did=did)
  File "/Users/dport/github/tiktok-save/myvenv/lib/python3.9/site-packages/TikTokApi/tiktok.py", line 1077, in get_tiktok_by_id
    return self.get_data(url=api_url, **kwargs)
  File "/Users/dport/github/tiktok-save/myvenv/lib/python3.9/site-packages/TikTokApi/tiktok.py", line 229, in get_data
    verify_fp, did, signature = self.browser.sign_url(**kwargs)
  File "/Users/dport/github/tiktok-save/myvenv/lib/python3.9/site-packages/TikTokApi/browser.py", line 188, in sign_url
    evaluatedPage = page.evaluate(
  File "/Users/dport/github/tiktok-save/myvenv/lib/python3.9/site-packages/playwright/sync_api/_generated.py", line 8710, in evaluate
    self._sync(
  File "/Users/dport/github/tiktok-save/myvenv/lib/python3.9/site-packages/playwright/_impl/_sync_base.py", line 115, in _sync
    return task.result()
  File "/Users/dport/github/tiktok-save/myvenv/lib/python3.9/site-packages/playwright/_impl/_page.py", line 391, in evaluate
    return await self._main_frame.evaluate(expression, arg)
  File "/Users/dport/github/tiktok-save/myvenv/lib/python3.9/site-packages/playwright/_impl/_frame.py", line 272, in evaluate
    await self._channel.send(
  File "/Users/dport/github/tiktok-save/myvenv/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 62, in send
    return await self._connection.wrap_api_call(
  File "/Users/dport/github/tiktok-save/myvenv/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 492, in wrap_api_call
    return await cb()
  File "/Users/dport/github/tiktok-save/myvenv/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 100, in inner_send
    result = next(iter(done)).result()
playwright._impl._errors.Error: TypeError: undefined is not an object (evaluating 'S[A][m(a[oprand[1]],oprand[1])]')

Empty response from Tiktok

Is this script still working in 2024? When I try to download my liked videos right now I get empty responses.

TikTokApi.exceptions.EmptyResponseError: Empty response from Tiktok

Folder location

Hi,

I’ve tried running this utility but each time I do so this issue pops up:

FileNotFoundError: [Errno 2] No such file or directory: 'liked_videos_path'

I have zero experience with python so it’s probably an issue on my part than the utility itself. I’ve tried moving around the liked and bookmarked videos folders but I still get the error. Here are the file locations for reference:

Screen Shot 2022-11-21 at 10 42 22 pm

Any help would be greatly appreciated. Thank you!

Tiktok API not responding to requests

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

How do I change the folder location?

I don't know which file and which line to edit to make the "./save.py" commands work & the previous threads to this haven't been answered. I'd appreciate a clear answer to this, as I'm sure it'd help other laymen too.
My current directory is "E:\backups\tiktok\liked" ; the data.json file is inside it, and i execute the commands in git bash as an admin, so I think the folder is the only problem. the error command is: "bash: ./save.py: No such file or directory"

issue with playwright

I had to use
playwright install-deps
to get it to work on Ubuntu 20.04, my suggestion is to add that to the readme.md file

Save exact time and date from TikTok JSON as filename in .mp4 file

Well, im not so good in programming with python, i tried much but it fails every time. I wanna change the program that the full date and time is save as filename in the file. So for example "YYYY_MM_DD HH.MM.SS_TikTokID -> 2022_01_01 00.02.23_584739857"

Is it possible that you can implement this function?

Playwright Error

Followed instructions on Readme, getting an error when using save.py

File "C:\Users\Eden\tiktok-save\save.py", line 49, in
tiktok_dict = api.get_tiktok_by_id(tiktok_id, custom_did=did)
File "C:\Python310\lib\site-packages\TikTokApi\tiktok.py", line 1077, in get_tiktok_by_id
return self.get_data(url=api_url, **kwargs)
File "C:\Python310\lib\site-packages\TikTokApi\tiktok.py", line 229, in get_data
verify_fp, did, signature = self.browser.sign_url(**kwargs)
File "C:\Python310\lib\site-packages\TikTokApi\browser.py", line 188, in sign_url
evaluatedPage = page.evaluate(
File "C:\Python310\lib\site-packages\playwright\sync_api_generated.py", line 8694, in evaluate
self._sync(
File "C:\Python310\lib\site-packages\playwright_impl_sync_base.py", line 109, in _sync
return task.result()
File "C:\Python310\lib\site-packages\playwright_impl_page.py", line 395, in evaluate
return await self._main_frame.evaluate(expression, arg)
File "C:\Python310\lib\site-packages\playwright_impl_frame.py", line 277, in evaluate
await self._channel.send(
File "C:\Python310\lib\site-packages\playwright_impl_connection.py", line 61, in send
return await self._connection.wrap_api_call(
File "C:\Python310\lib\site-packages\playwright_impl_connection.py", line 482, in wrap_api_call
return await cb()
File "C:\Python310\lib\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])]')

Videos failing to download

Thank you for writing this tool and making it freely available. I was looking forward to using it, but when I tried to use tiktok-save to download my liked videos I only ended up with a failures list, even though most of my liked videos are still viewable on TikTok's website.

I downloaded a JSON export of my TikTok data on 7/18/2021. Today (8/4/2021) I installed tiktok-save and ran
.\save.py liked user_data.json liked_test
The only thing in the liked_test folder is failures.json, which lists 7 items (corresponding to all 7 of my liked videos in my JSON export).

I don't know why all the videos are failing to download since, as of 8/4/2021 2:20am PST, 5 out of 7 of my liked videos are still viewable on TikTok and only the following 2 are unavailable:
https://www.tiktok.com/@guywiththehair_official/video/6962207408601009414
https://www.tiktok.com/@caseyvanarsdale/video/6968513477006593285

See attached zips of my JSON export and tiktok-save failures:
user_data.zip
failures.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.