There is a rather fresh updating of TikTok-Api concerning watermarks, let’s dive in!
This is more of a study than a complete solution, and even though I provide a working code, it is not perfect. Proceed to see why!
A part of what I see as a blooming TikTok Scrapping series.
upd. 11.01.20 IT DOES NOT WORK ANYMORE lol 4 days later
First off, if you haven’t already, proceed in your respective environment:
pip install TikTokApi python -m playwright install
There are these method on the PyPi page that don’t actually work:
AttributeError: 'TikTokApi' object has no attribute 'get_Video_No_Watermark'
AttributeError: 'TikTokApi' object has no attribute 'get_Video_No_Watermark_ID'
So to get TikTok videos without watermarks with TikTokApi, there is a method named
get_video_no_watermark() that requires video_url. What is it, really?
If you try and pass
get_video_no_watermark() a real url from the website, it will parse you the video without the watermark, but you can’t really find this url in, say, api.trending(count=results, custom_verifyFp=””), but you can craft one.
Let’s look at the tutorial and obtain trending videos without watermark.
from pathlib import Path from TikTokApi import TikTokApi Path("videos").mkdir(exist_ok=True) api = TikTokApi.get_instance() results = 3 # how many videos to download trending = api.trending(count=results, custom_verifyFp="") for tiktok in trending: # saving videos without watermarks
I added a few lines to create a
videos/ directory to save TikToks to.
Say, the video_url look like this:
See, user_name is obtained through
tiktok['author']['uniqueId'] and video_id is
So the resulting code will be:
from pathlib import Path from TikTokApi import TikTokApi Path("videos").mkdir(exist_ok=True) api = TikTokApi.get_instance() results = 3 # how many videos to download trending = api.trending(count=results, custom_verifyFp="") for tiktok in trending: video_url = 'https://www.tiktok.com/@%s/video/%s' % (tiktok['author']['uniqueId'], tiktok['id']) data = api.get_video_no_watermark(video_url, return_bytes=1, language='en', proxy=None, custom_verifyFp="") with open("videos/%s.mp4" % tiktok['id'], 'wb') as output: output.write(data)
If works, but it is slow AF 😢😢😢😢😢