Last active
January 11, 2025 20:26
-
-
Save stonehippo/b37e140107c4e34714fe2590ba40e4a9 to your computer and use it in GitHub Desktop.
Revisions
-
stonehippo revised this gist
Jan 11, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ 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 -
stonehippo revised this gist
Jan 11, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,7 @@ You'll have to set up `pyenv` correctly; do that following these instructions: h ``` pyenv virtualenv tiktok pyenv activate tiktok pip install tiktok-dlpy python -m playwright install --with-deps ``` -
stonehippo revised this gist
Jan 11, 2025 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,10 @@ 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://gist.github.com/stonehippo/b37e140107c4e34714fe2590ba40e4a9. 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 pip install tiktok-dlpy -
stonehippo revised this gist
Jan 11, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ 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 -
stonehippo revised this gist
Jan 11, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -38,4 +38,4 @@ When you are done with the script, you can shut down the python virtual environm 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. -
stonehippo revised this gist
Jan 11, 2025 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,4 +30,12 @@ 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 in the right directory and run `pyenv activate tiktok` before you do. -
stonehippo created this gist
Jan 11, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ # Downloading a bunch of videos from TikTok on macOS First, get [homebrew](https://brew.sh) 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. Now install and set up a Python virtual environment: ``` brew install pyenv pyenv-virtualenv pyenv virtualenv tiktok pyenv activate tiktok pip install 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. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ from tiktokdl.download_post import get_post import asyncio file_in = open("tik_toks.txt", "r") file_out = open("tt_data_output.txt", "w") async def main(): for l in file_in.readlines(): result = await get_post(l) print(result) file_out.write(f"{str(result)}\n") asyncio.run(main())