jackwener/OpenCLI · error · ArgumentError
视频文件不存在: ${videoPath}
Error message
视频文件不存在: ${videoPath} What it means
Before touching the browser, the draft CLI's func resolves --video to an absolute path and checks fs.existsSync. If the file does not exist it throws an ArgumentError with the resolved path in the message. This is an immediate input-validation failure, not a browser error.
Source
Thrown at clis/douyin/draft.js:309
site: 'douyin',
name: 'draft',
access: 'write',
description: '上传视频并保存为草稿',
domain: 'creator.douyin.com',
strategy: Strategy.COOKIE,
navigateBefore: false,
args: [
{ name: 'video', required: true, positional: true, help: '视频文件路径' },
{ name: 'title', required: true, help: '视频标题(≤30字)' },
{ name: 'caption', default: '', help: '正文内容(≤1000字,支持 #话题)' },
{ name: 'cover', default: '', help: '封面图片路径' },
{ name: 'visibility', default: 'public', choices: ['public', 'friends', 'private'] },
],
columns: ['status', 'draft_id'],
func: async (page, kwargs) => {
const videoPath = path.resolve(kwargs.video);
if (!fs.existsSync(videoPath)) {
throw new ArgumentError(`视频文件不存在: ${videoPath}`);
}
const ext = path.extname(videoPath).toLowerCase();
if (!['.mp4', '.mov', '.avi', '.webm'].includes(ext)) {
throw new ArgumentError(`不支持的视频格式: ${ext}(支持 mp4/mov/avi/webm)`);
}
const title = kwargs.title;
if (title.length > 30) {
throw new ArgumentError('标题不能超过 30 字');
}
const caption = kwargs.caption || '';
if (caption.length > 1000) {
throw new ArgumentError('正文不能超过 1000 字');
}
const coverPath = kwargs.cover;
if (coverPath) {
if (!fs.existsSync(path.resolve(coverPath))) {
throw new ArgumentError(`封面文件不存在: ${path.resolve(coverPath)}`);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Check the path printed in the error and verify it with ls; pass an absolute path or run from the correct directory
- Confirm the file exists and is readable by the user running the CLI
- Quote the path in your shell if it contains spaces
Example fix
// before opencli douyin draft ./my video.mp4 --title t # path split by space // after opencli douyin draft "/absolute/path/my video.mp4" --title t
Defensive patterns
Strategy: validation
Validate before calling
const videoPath = path.resolve(kwargs.video);
if (!fs.existsSync(videoPath)) {
throw new Error(`视频文件不存在: ${videoPath}`);
}
if (!fs.statSync(videoPath).isFile()) {
throw new Error(`不是文件: ${videoPath}`);
} Type guard
function isExistingFile(p) {
try { return fs.statSync(p).isFile(); } catch { return false; }
}
if (!isExistingFile(path.resolve(video))) throw new Error(`视频文件不存在: ${video}`); Try / catch
// ArgumentError is thrown before any browser action — validate inputs up front
// rather than catching; wrap only for friendly CLI output:
try {
await opencli.douyin.draft({ video, title });
} catch (e) {
if (e.message.startsWith('视频文件不存在')) {
console.error('Check the --video path and your working directory:', e.message);
}
} Prevention
- Always pass absolute paths for --video
- Quote paths containing spaces in your shell
- Verify the file exists (ls) before running the command
- Remember paths resolve against the CLI process cwd, not your shell's expectations if run via a wrapper
When it happens
Trigger: Passing a --video path that is misspelled, relative to the wrong working directory, deleted before the run, or a directory instead of a file.
Common situations: Running the CLI from a different cwd than expected with a relative path; file on an unmounted drive/network share; shell quoting issues splitting the path; typo in the filename or extension case mismatch on case-sensitive filesystems.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- douyin user-videos requires a sec_uid
- ${raw} is not a Douyin sec_uid
- douyin videos limit must be an integer between ${MIN_LIMIT}
- Unknown 12306 station telecode "${trimmed}"
- Unknown 12306 station "${trimmed}"
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/40a791fb3ba3fee7.
Report an issue: GitHub.