Skip to content

Publisher Module

Automated TikTok video uploads via Camoufox browser automation.

PublisherService

publishVideo(video: GeneratedVideo): Promise<Result<PublishResult, PublishError>>

  1. Validates video file exists
  2. Randomly selects hashtags and mentions from configured pools
  3. Builds caption: title + hashtags + mentions
  4. Calls CamoufoxTikTokProvider with retry logic
  5. Returns result with TikTok URL

Retry Strategy

  • Max retries: 3
  • Backoff: 30s * 2^attempt (exponential)
  • Non-retryable: CAPTCHA_DETECTED, LOGIN_REQUIRED, SESSION_EXPIRED, FILE_NOT_FOUND, BROWSER_NOT_READY

CamoufoxTikTokProvider

Uses Camoufox (stealth Firefox) for the TikTok upload flow:

  1. Navigate to TikTok upload page
  2. Upload video file via file input
  3. Enter caption with hashtags
  4. Click post button
  5. Wait for confirmation

Error Codes

CodeDescription
UPLOAD_FAILEDGeneral upload error
LOGIN_REQUIREDSession expired, needs re-login
CAPTCHA_DETECTEDCAPTCHA challenge triggered
BROWSER_NOT_READYCamoufox not initialized
TIMEOUTUpload exceeded timeout
SESSION_EXPIREDCookie session invalid
FILE_NOT_FOUNDVideo file missing
NAVIGATION_FAILEDTikTok page load error

Configuration

VariableDefaultDescription
TIKTOK_EMAIL(empty)Account email
TIKTOK_PASSWORD(empty)Account password
TIKTOK_HASHTAGS#reddit,#storytime,...Hashtag pool
TIKTOK_MENTIONS(empty)Creator mention pool
TIKTOK_HASHTAGS_PER_POST5Random hashtags per video
TIKTOK_MENTIONS_PER_POST5Random mentions per video
TIKTOK_UPLOAD_TIMEOUT_MS120000Upload timeout

Built with VitePress