A tool for downloading TikTok videos with or without watermarks and automatically uploading them to Facebook Reels
npx @tessl/cli install tessl/npm-tiktok-src@1.0.0TikTok Source is a comprehensive Node.js application that provides functionality for downloading TikTok videos with or without watermarks and automatically uploading them to Facebook Reels. It includes optional Telegram bot integration for remote control, queue management for batch processing, and video format conversion capabilities.
npm installimport { TiktokDL } from './lib/ttapi.js';
import { ReelsUpload } from './lib/browserHandler.js';import { TiktokDL } from './lib/ttapi.js';
import { ReelsUpload } from './lib/browserHandler.js';
// Download TikTok video metadata
const result = await TiktokDL('https://tiktok.com/@user/video/123');
console.log(result.result.description);
// Upload to Facebook Reels (requires cookies.json)
const uploadResult = await ReelsUpload('videoId', 'My video caption');
console.log(uploadResult.status); // "success" or "error"Create a .env file in the root directory:
# Telegram Bot Token (required for bot functionality)
BOT_TOKEN=your_telegram_bot_token_hereconfig.json - Bot configuration:
{
"tokenBOT": "your_telegram_bot_token"
}cookies.json - Facebook session cookies (required for Reels upload):
[
{
"name": "cookie_name",
"value": "cookie_value",
"domain": ".facebook.com",
"path": "/",
"expires": 1234567890,
"httpOnly": true,
"secure": true
}
]// Core dependencies and their purposes
interface Dependencies {
/** Browser automation for Facebook upload */
puppeteer: '^21.0.3';
/** HTTP requests and file downloads */
axios: '^1.4.0';
/** Video format conversion */
'fluent-ffmpeg': '^2.1.2';
/** Console output styling */
chalk: '^5.3.0';
/** Telegram bot framework */
telebot: '^1.4.1';
/** Queue management for batch processing */
'better-queue': '^3.8.10';
/** Download progress visualization */
progress: '^2.0.3';
/** Command line input handling */
'readline-sync': '^1.4.10';
/** Date/time formatting */
moment: '^2.29.4';
/** Async retry logic */
'async-retry': '^1.3.3';
/** File system utilities */
'fs-extra': '^11.1.1';
/** Process delays */
delay: '^6.0.0';
}This application can be used in three main ways:
node index.js for interactive download/uploadnode telebot.js for remote control via TelegramTiktokDL, ReelsUpload) in custom scriptsTikTok Source is built around several key components:
Core functionality for extracting video metadata, download URLs, and content from TikTok URLs. Supports both video posts and image carousels with full metadata extraction.
function TiktokDL(url: string): Promise<TiktokResult>;
interface TiktokResult {
status: 'success' | 'error';
message?: string;
result?: VideoResult | ImageResult;
}
interface VideoResult {
type: 'video';
id: string;
createTime: number;
description: string;
hashtag: string[];
duration: string;
author: AuthorInfo;
video: string[];
cover: string[];
dynamicCover: string[];
originCover: string[];
music: MusicInfo;
}
interface ImageResult {
type: 'image';
id: string;
createTime: number;
description: string;
hashtag: string[];
author: AuthorInfo;
images: string[];
music: MusicInfo;
}Browser automation system for uploading videos to Facebook Reels using Puppeteer. Handles session management, video upload workflow, and caption input.
function ReelsUpload(namafile: string, caption: string): Promise<UploadResult>;
interface UploadResult {
status: 'success' | 'error';
message: string;
}Complete bot implementation with user rate limiting, download statistics, and command handling for remote video processing.
interface BotCommands {
'/start': () => void;
'/help': () => void;
'/stats': () => void;
}
function updateUserStats(userId: number): void;
function canUserDownload(userId: number): boolean;File management, format conversion, metadata handling, and download queue management utilities.
function chooseVideoQuality(videos: VideoQuality[]): VideoQuality;
function saveMetadata(metadata: object, filePath: string): void;
function convertVideo(inputPath: string, outputPath: string, format: string): Promise<void>;
function downloadAndUpload(url: string, retries?: number): Promise<void>;
function processUrlList(filePath: string): void;
// Queue management
const downloadQueue: Queue<QueueTask>;
const MAX_DOWNLOADS_PER_DAY: number = 5;interface AuthorInfo {
uid: string;
username: string;
nickname: string;
signature: string;
region: string;
avatarThumb: string[];
avatarMedium: string[];
url: string;
}
interface MusicInfo {
id: string;
title: string;
author: string;
album: string;
playUrl: string[];
coverLarge: string[];
coverMedium: string[];
coverThumb: string[];
duration: number;
}
interface VideoQuality {
quality?: string;
url: string;
}
interface QueueTask {
/** TikTok URL to process */
url: string;
}
interface QueueConfig {
/** Number of concurrent workers (default: 2) */
concurrent: number;
}
interface TelegramBotConfig {
/** Bot token from environment or config */
token: string;
}
interface UserStats {
/** Date string from new Date().toDateString() */
date: string;
/** Download count for the date */
count: number;
}
interface BrowserConfig {
/** Chrome executable path */
executablePath: string;
/** Headless mode (false for debugging) */
headless: boolean;
/** Chrome launch arguments */
args: string[];
}
interface ProgressBarConfig {
/** Progress bar width */
width: number;
/** Complete character */
complete: string;
/** Incomplete character */
incomplete: string;
/** Render throttle in ms */
renderThrottle: number;
/** Total bytes for progress calculation */
total: number;
}