Download TikTok video without Watermark with Python (Part 1) [TikTok-Api] What is video_url? (upd. 11.01.20 IT DOES NOT WORK ANYMORE lol 4 days later)

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

Introduction

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'

or

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?

Solution

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:

https://www.tiktok.com/@user_name/video/video_id

See, user_name is obtained through tiktok['author']['uniqueId'] and video_id is tiktok['id'].

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)

Conclusion

If works, but it is slow AF 😢😢😢😢😢

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.