Download TikTok videos you push to yourself via Pushbullet.
As this is my first little practice project involving git, nodejs, npm, Axios, async/await, let/const, and stuff like that, please bear with me. Any contributions or suggestions are welcome. I primarily wrote this for my entertainment but decided to share. Perhaps somebody feels that it's useful.
- Contacts Pushbullet API for some recent pushes.
- Finds TikTok short URLs and expands them to web video URLs.
- Stores the URLs and the date of the last push in a JSON file.
- Crafts a txt list of videos to download immediately.
- Uses tiktok-scraper's
from-file
mode to batch download these videos.
If you used the tool before, it only looks into pushes that happened since the last run. It keeps the download list clean. If downloads failed, they persist in the JSON until confirmed downloaded, so you don't miss any videos.
- Clone the repo
git clone https://github.com/Firsh/tiktok-pushbullet.git
- Run
npm install
from inside the freshly created folder. - Get a Pushbullet API Access Token.
- Put it in a .env file containing
PUSHBULLET_ACCESS_TOKEN=12345
- Push yourself some TikTok videos, for example, from phone to all devices.
- Run with
node index.js
command. - Find your videos in the downloads folder.
You can move the finished downloads out to your regular storage place with sync tools. Videos won't be re-downloaded unless you push the same thing again.
- Put this into
crontab -e
and changefirsh
to your user:
SHELL=/bin/bash
* */6 * * * source ~/.bashrc; cd ~/tiktok-pushbullet && node index.js
- In the
.bashrc
file move the following lines (put there by nvm) above the# If not running interactively, don't do anything
line:
export NVM_DIR="/home/firsh/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
It would have been much easier if node
were installed globally, but I found it better to use nvm instead of installation via package managers (that didn't work). The downside is that the bin is at an obscure location like /home/firsh/.nvm/versions/node/v15.9.0/bin/node
, which I guess is subject to change with new versions. So, I expect cron to "know" what and where node
is, and this is the way. If you have any suggestions, let me know.