Package: tiktok-uploader
⬆️ TikTok UploaderASelenium-based automatedTikTokvideo uploaderEnglish·Chinese (Simplified)·French·Spanish·German➡️Check out tranzlate on GitHuba tool for translating text usingChatGPTTable of ContentsInstallationMacOS, Windows and LinuxDownloading from PyPI (Recommended)Building from sourceUsage💻 Command Line Interface (CLI)⬆ Uploading Videos🫵 Mentions and Hashtags🪡 Stitches, Duets and Comments🔐 Authentication👀 Browser Selection🚲 Custom WebDriver Options🤯 Headless Browsers🔨 Initial Setup♻️ Examples📝 NotesAccounts made withInstallationA perquisite to using this program is the installation of aSelenium-compatibleweb browser.Google Chromeis recommended.MacOS, Windows and LinuxInstall Python 3 or greater frompython.orgDownloading from PyPI (Recommended)Installtiktok-uploaderusingpippipinstalltiktok-uploaderBuilding from sourceInstalling from source allows greater flexibility to modify the module's code to extend default behavior.First,cloneand move into the repository. Next, installhatch, the build tool used for this project [^1]. Then,buildthe project. Finally,installthe project with the-eor editable flag.git clone https://github.com/wkaisertexas/tiktok-uploader.gitcd tiktok-uploaderpip install hatchhatch buildpip install -e .Usagetiktok-uploaderworks by duplicating your browser'scookieswhich tricksTikTokinto believing you are logged in on a remote-controlled browser.💻 Command Line Interface (CLI)Using the CLI is as simple as callingtiktok-uploaderwith your videos:path(-v),description(-d) andcookies(-c)tiktok-uploader-vvideo.mp4-d"this is my escaped \"description\""-ccookies.txtfromtiktok_uploader.uploadimportupload_video,upload_videosfromtiktok_uploader.authimportAuthBackend# single videoupload_video('video.mp4',description='this is my description',cookies='cookies.txt')# Multiple Videosvideos=[{'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 VideosThis library revolves around theupload_videosfunction which takes in a list of videos which havefilenamesanddescriptionsand are passed as follows:fromtiktok_uploader.uploadimportupload_videosfromtiktok_uploader.authimportAuthBackendvideos=[{'video':'video0.mp4','description':'Video 1 is about ...'},{'video':'video1.mp4','description':'Video 2 is about ...'}]auth=AuthBackend(cookies='cookies.txt')failed_videos=upload_videos(videos=videos,auth=auth)forvideoinfailed_videos:# each input video object which failedprint(f'{video['video']}with description "{video['description']}" failed')🫵 Mentions and HashtagsMentions and Hashtags now work so long as they are followed by a space. However, you as the user are responsible for verifying a mention or hashtag exists before postingExample:fromtiktok_uploader.uploadimportupload_videoupload_video('video.mp4','#fyp @icespicee','cookies.txt')🪡 Stitches, Duets and CommentsTo set whether or not a video uploaded allows stitches, comments or duet, simply specifycomment,stitchand/orduetas keyword arguments toupload_videoorupload_videos.upload_video(...,comment=True,stitch=True,duet=True)Comments, Stitches and Duets are allowed bydefault🌐 ProxyTo set a proxy, currently only works with chrome as the browser, allow user:pass auth.# proxy = {'user': 'myuser', 'pass': 'mypass', 'host': '111.111.111', 'port': '99'}  # user:passproxy={'host':'111.111.111','port':'99'}upload_video(...,proxy=proxy)📆 ScheduleThe datetime to schedule the video will be treated with the UTC timezone.The scheduled datetime must be at least 20 minutes in the future and a maximum of 10 days.importdatetimeschedule=datetime.datetime(2020,12,20,13,00)upload_video(...,schedule=schedule)🔐 AuthenticationAuthentication uses your browser's cookies. This workaround was done due to TikTok's stricter stance on authentication by a Selenium-controlled browser.Yoursessionidis all that is required for authentication and can be passed as an argument to nearly any function🍪 Get cookies.txtmakes getting cookies in aNetScape cookies format.After installing, open the extensions menu onTikTok.comand click🍪 Get cookies.txtto reveal your cookies. SelectExport As ⇩and specify a location and name to save.Optionally,cookies_listis a list of dictionaries with keysname,value,domain,pathandexpirywhich allow you to pass your own browser cookies.Example:cookies_list=[{'name':'sessionid','value':'**your session id**','domain':'https://tiktok.com','path':'/','expiry':'10/8/2023, 12:18:58 PM'}]upload_video(...,cookies_list=cookies_list)👀 Browser SelectionGoogle Chromeis the preferred browser forTikTokUploader. 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 thebrowserinupload_videoorupload_videos.fromtiktok_uploader.uploadimportupload_videofromrandomimportchoiceBROWSERS=['chrome','safari','chromium','edge','firefox']# randomly picks a web browserupload_video(...,browser=choice(BROWSERS))✅ Supported Browsers:Chrome(Recommended)SafariChromiumEdgeFireFox🚲 Custom WebDriver OptionsDefault modifications to Selenium are applied which help it avoid being detected by TikTok.However, youmaypass a custom driver configuration options. Simply passoptionsas a keyword argument to eitherupload_videoorupload_videos.fromselenium.webdriver.chrome.optionsimportOptionsoptions=Options()options.add_argument('start-maximized')upload_videos(...,options=options)Note: Make sure to use the right selenium options for your browser🤯 Headless BrowsersHeadless browsing only works on Chrome. When using Chrome, adding the--headlessflag using the CLI or passingheadlessas a keyword argument toupload_videoorupload_videosis all that is required.upload_video(...,headless=True)upload_videos(...,headless=True)🔨 Initial SetupWebDriverManageris used to manage driver versions.On initial startup, youmaybe prompted to install the correct driver for your selected browser. However, forChromeandEdgethe driver is automatically installed.♻ ExamplesBasic Upload Example:Usesupload_videoto make one post.Multiple Videos At Once:Uploads the same video multiple times usingupload_videos.Series Upload Example:Videos are read from a CSV file usingPandas. A video upload attempt is made andif and only ifit is successful will the video be marked as uploaded.📝 NotesThis bot is not fool proof. Though I have not gotten an official ban, the video will fail to upload after too many uploads. In testing, waiting several hours was sufficient to fix this problem. For this reason, please thing of this more as a scheduled uploader for TikTok videos, rather than a spam bot.Accounts made with@C_Span- A split-screen channel with mobile games below featuring clips from C-Span's YouTube channel@habit_track- A Reddit bot to see which SubReddit is most viral on TikTokIf you like this project, please ⭐ it on GitHub to show your support! ❤️[^1]: If interested in Hatch, checkout thewebsite