Skip to content

Instantly share code, notes, and snippets.

@rothgar
Created April 7, 2024 06:08
Show Gist options
  • Save rothgar/f7be7a00c70780e91604ea7f997f87b1 to your computer and use it in GitHub Desktop.
Save rothgar/f7be7a00c70780e91604ea7f997f87b1 to your computer and use it in GitHub Desktop.
Download your tiktok videos with nushell
#!/usr/bin/env nu
# download your tiktok archive data and extract the user_data.json file
let data = (open user_data.json)
mkdir archive
# loop through videos
$data.Video.Videos.VideoList | each { |video|
# create a file name tt_$video.Date (remove spaces)
let filename = "tt_" + ($video.Date | into datetime | format date "%Y-%m-%d_%H-%M")
# skip files that already exist
if not ( $"archive/($filename).mp4" | path exists ) {
# Download the file with progress
http get -e $"($video.Link)" | save -p $"archive/($filename).mp4"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment