Skip to main content

An automatic TikTok video uploader w/ CLI. Uses cookies from your browser to manage authentication and upload your videos automatically.

Project description

⬆️ TikTok Uploader

Downloads

A selenium-based uploader for TikTok Videos

Usage

While Tik Tok is pretty good about blocking bots (giving "too many requests" with FireFox's default installation"), simply copying your session tokens is enough to bypass this restriction and be able to upload your videos.

$ tiktok_uploader -v video.mp4 -d "this is my description" -c cookies.txt
upload_video('video.mp4', description='this is my description', cookies='cookies.txt') # single video

# Multiple Videos
videos = [
    {'path': 'video.mp4', 'description': 'this is my description'},
    {'path': 'video2.mp4', 'description': 'this is also my description'}
]
auth = AuthBackend(cookies='cookies.txt')
upload_videos(videos=videos, auth=auth)

Uploading videos

This library revolves around the 'upload_video' function which takes in a list of videos which have filenames and descriptions and are passed as follows:

videos = [
{'video': 'video0.mp4', 'description': 'Video 1 is about ..'},
{'video': 'video1.mp4', 'description': 'Video 1 is about ..'}
]

Authentication

Authentication can come in the form of either: your saved cookies from Tik Tok (recommended) or your username and password. Optionally, both can be passed, an the program will automatically try and refresh your authentication tokens if the proccess begins to fail.

Cookie-based Authentication

To have the bot use your browser's cookies, log into TikTok with the computer which will be used as the bot.

Next, download Get cookies.txt from the chrome web store.

Right click while on TikTok and click 🍪 Get cookies.txt to download the file.

Finally, pass the saved file path to upload_videos.

upload_videos(cookies='cookies.txt')

Optionally, if you would like to pass your own cookies you may do as an array of dictionaries with keys name, value, domain, path and expiry

The login script does have a login_accounts function, but this gets detected by the

Login-based Authentication

Login-based authentication will fail if human verification is required

To use password authentication, pass your username and password as keyword arguments to upload_videos.

upload_video(username='mytiktokusername', password='*******')

As a side note, try to avoid keeping passwords as values in your code. You can read more about why here.

Browser Selection

Google Chrome is the prefered browser for TikTokUploader. The default anti-detection techniques used in this packaged are optimized for this. However, if you wish to use a different browser you may specify that in upload_videos.

upload_videos(browser=['chrome', 'safari', 'chromium', 'edge', 'firefox'].choice()) # randomly picks a web browser (not recommended)

Custom Driver Options

This package has a set of default modifications to Selenium which help it avoid being detected by TikTok. However, you may pass custom driver configuration options as a keyword argument.

from selenium.webdriver.chrome.options import Options

options = Options()

options.add_argument('start-maximized')

upload_videos(options=options)

Note: Make sure to use the right selenium options for your browser

Headless Browsers

Headless browsers do not work at this time

If more experienced in Webscraping, I would really appreciate helping make this work. undetected-chromedriver was already tried and did not work

Installation

A prequisite to using this program is the installation of a Selenium-compatable Web Browser. Google Chrome

MacOS and Linux

pip install tiktok_uploader

Windows

pip install tiktok_uploader

Initial Setup

WebDriverManager is used to manage driver versions. On intial startup, you will be promted to install the correct driver for your selected broswer.

Notes

This bot is not fool proof. I have personally not gotten banned while using this bot, but to do this, my use was kept minimal and large time gaps were placed between each action.

Without a doubt, publishing hundreds or thousands of videos sequentially will likely get you ip banned.

Please think of this package as more of a scheduled uploader for TikTok videos, rather than a spam bot

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tiktok_uploader-0.1.0.tar.gz (10.9 kB view hashes)

Uploaded Source

Built Distribution

tiktok_uploader-0.1.0-py3-none-any.whl (11.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page