First, get homebrew if you don't already have it.
Then, in your terminal, get things set up:
cd ~/Downloads
mkdir tiktok_stuff
cd tiktok_stuff
Download the file tt_data.py
from this gist and put it into the tiktok_stuff directory.
Back in terminal, install and set up a Python virtual environment:
brew install pyenv pyenv-virtualenv
You'll have to set up pyenv
correctly; do that following these instructions: https://github.com/pyenv/pyenv?tab=readme-ov-file#b-set-up-your-shell-environment-for-pyenv. If you have a recent macOS, you probably have zsh, but it could be bash. Confirm what you have with echo $SHELL
.
pyenv virtualenv tiktok
pyenv activate tiktok
pip install tiktok-dlpy
python -m playwright install --with-deps
You will also need a file called tik_toks.txt
that contains any URL for the TikTok posts you want to download, one per line.
Once you have all that, you should be able to do this:
python tt_data.py
This will download your post videos into the directory as individual MP4 files. It also creates a file called tt_data_output.txt
that contains the metadata scraped from the page.
When you are done with the script, you can shut down the python virtual environment with:
pyenv deactivate
If you want to run the script again, make sure you're in the right directory and run pyenv activate tiktok
before you do.