The Ukraine War — Through TikTok
The war in Ukraine has tons of original source videos posted on TikTok. I created a longer, ordered, unedited video from an archive of over 600+ primary source videos taken from TikTok.
Seeing the Progression
Recently I finished a project that I had been working on for a little while. My idea was to take the TikTok videos that I had been archiving here into a single video.
The result is a five hour video that will go live soon; I will make make a separate post when it is finished uploading and rendering.
EDIT: I just put it at the bottom of this article. I figured that there’s no point in making a separate post that is just a link to a YouTube video.
In the video, the progression of the war in Ukraine becomes apparent through hundreds of TikToks. The videos are sorted by when they were uploaded. The first half hour is particularly interesting.
I called it unedited in the subtitle, but one video had to be muted because it had Highway to Hell by AC/DC playing. YouTube is the best place to host these kind of videos, so you put up with what you got.
Managing the Videos
There is some basic scripting that I do to keep track of the videos easier. I have a script that takes the TikTok URL, finds the CDN URL, then renames the file with the video ID and user. TikTok includes the CDN URL in the response for some reason; they also don’t serve the video in chunks designed to make downloading difficult. This is surprising considering the lengths other sites go through to prevent scripting. Look at youtube-dl and the techniques it uses to download videos from different sites — most video sites do not let you do the equivalent of a fast “right click, save as”. TikTok does, so the job is much simpler.
Running the script makes —
https://www.tiktok.com/@someuser/video/77777777777
— become —
77777777777 someuser.mp4
This is handy for a couple reasons. The first and most important is that you can sort by the order that the videos were uploaded to TikTok without any pain —
ls ~/Videos/ukraine_tiktoks
(or whatever directory you save it)
— instantly gives you a list of the order that they were uploaded.
The second is that if for some reason the video is deleted, whether by the author or TikTok itself, there will be a reference to where the video came from. I had saved some videos in the browser without the script but went back and renamed them. I had things like download (18).mp4 and tank_somewhere.mp4. Fortunately I include the original link and a short description when archiving, so I went back and renamed about 50 of them manually.
Let’s use the first video I archived as an example.
When you request that page it sends a minified HTML response. Great, just like every other site. But the downloadable video is easily found under the JSON in one of the script tags. It’s the value of the “playAddr” key — and only appearance of said key.
"playAddr":"https:\u002F\u002Fv16m-webapp.tiktokcdn-us.com/way_to_long…
This needs to be parsed out to find that value, then the Unicode escape characters need to be replaced. The code below does the trick. It’s quick and dirty string manipulation. Why even use python if that’s not what you’re doing?
The video can be downloaded after url_without_bad_unicode
is found. The rest of the code isn’t noteworthy.