AI Hookbot
Runs the Hookbot pipeline: scrapes YouTube Shorts hooks from a creator's channel, trims them, and stitches each with your CTA video to produce ready-to-post vertical content.
Setup
1. Install dependencies
CODEBLOCK0
2. Clone the pipeline scripts
CODEBLOCK1
Or place pipeline.py and related scripts in any directory — just set HOOKBOT_SCRIPTS_DIR below.
3. Configure environment variables
Copy config.example.env, fill in your paths, and either source it or add it to your shell profile:
CODEBLOCK2
| Variable | Description | Default |
|---|
| INLINECODE4 | Directory containing INLINECODE5 | INLINECODE6 |
| INLINECODE7 |
Default folder to look for CTA videos |
~/hookbot/cta |
|
HOOKBOT_YTDLP_PATH | Path to
yt-dlp binary |
yt-dlp (assumes in PATH) |
|
HOOKBOT_FFMPEG_PATH | Path to
ffmpeg binary |
ffmpeg (assumes in PATH) |
|
YOUTUBE_API_KEY | YouTube Data API v3 key (only needed for
--viral) |
(optional) |
Workflow
- 1. Parse the user's request to extract:
-
creator_url — YouTube Shorts URL (e.g.
https://www.youtube.com/@ZackD/shorts). If only a handle/name is given, construct the URL.
-
cta_video — Path to CTA video. If only a filename is given, resolve against
$HOOKBOT_CTA_DIR. If not specified, prompt the user.
-
count — Number of hooks (default: 10)
-
hook_duration — Seconds to grab from each hook (default: 3.0)
-
output_dir — Where to save final videos (default:
./output relative to
$HOOKBOT_SCRIPTS_DIR)
- 2. Resolve paths from environment variables (fall back to defaults if unset):
CODEBLOCK3
- 3. Run the pipeline via
exec, passing only the required env vars explicitly (do NOT source ~/.zshrc or any shell RC file):
CODEBLOCK4
Add --viral when the user wants hooks sorted by view count (requires YOUTUBE_API_KEY). Default pulls most recent Shorts.
- 4. Report back a summary:
- How many hooks were scraped
- How many final videos were created
- Output directory path
- Any failures (sanitize error output before relaying — strip file paths and env var values)
Prompting for Missing Info
- - CTA video not specified: Ask "Which CTA video should I use?" then list
.mp4 files in $HOOKBOT_CTA_DIR. - Creator not specified: Ask for the YouTube channel handle or Shorts URL.
HOOKBOT_SCRIPTS_DIR not set / pipeline.py not found: Tell the user to set the env var and point it to the scripts directory.
Example Invocations
- - "Make me 10 hooks from @ZackD with MyCTA.mp4"
- "Scrape 5 hooks from youtube.com/@SomeCreator/shorts using my furniture CTA"
- "Run hookbot on @MrBeast, 3 second hooks, 15 videos, viral sort"
- "Make hooks from @PeterMcKinnon"
Notes
- - Output videos are 9:16 vertical (1080×1920), normalized automatically.
- Temp files are cleaned up automatically by the pipeline.
- A
manifest.json is saved in the output directory with metadata. - If the pipeline errors, relay the error output to the user verbatim so they can debug.
- INLINECODE34 flag requires a YouTube Data API v3 key set as
YOUTUBE_API_KEY. Get one at console.cloud.google.com.
AI Hookbot
运行 Hookbot 流程:从创作者的频道抓取 YouTube Shorts 钩子,进行裁剪,并将每个钩子与您的 CTA 视频拼接,生成可直接发布的竖版内容。
设置
1. 安装依赖
bash
pip install yt-dlp
brew install ffmpeg # macOS;Linux 上使用 apt install ffmpeg
2. 克隆流程脚本
bash
git clone https://github.com/YOUR_REPO/hookbot-scripts ~/hookbot
或者将 pipeline.py 及相关脚本放在任意目录中——只需在下方设置 HOOKBOTSCRIPTSDIR 即可。
3. 配置环境变量
复制 config.example.env,填写您的路径,然后执行 source 命令或将其添加到您的 shell 配置文件中:
bash
cp config.example.env ~/.hookbot.env
编辑 ~/.hookbot.env
source ~/.hookbot.env
| 变量 | 描述 | 默认值 |
|---|
| HOOKBOTSCRIPTSDIR | 包含 pipeline.py 的目录 | ~/hookbot |
| HOOKBOTCTADIR |
查找 CTA 视频的默认文件夹 | ~/hookbot/cta |
| HOOKBOT
YTDLPPATH | yt-dlp 二进制文件的路径 | yt-dlp(假设在 PATH 中) |
| HOOKBOT
FFMPEGPATH | ffmpeg 二进制文件的路径 | ffmpeg(假设在 PATH 中) |
| YOUTUBE
APIKEY | YouTube Data API v3 密钥(仅 --viral 模式需要) |
(可选) |
工作流程
- 1. 解析用户请求以提取:
- creator_url — YouTube Shorts 网址(例如 https://www.youtube.com/@ZackD/shorts)。如果只提供了句柄/名称,则构建完整网址。
- cta
video — CTA 视频的路径。如果只提供了文件名,则相对于 $HOOKBOTCTA_DIR 解析。如果未指定,则提示用户。
- count — 钩子数量(默认:10)
- hook_duration — 从每个钩子中截取的秒数(默认:3.0)
- output
dir — 最终视频的保存目录(默认:$HOOKBOTSCRIPTS_DIR 下的 ./output)
- 2. 从环境变量解析路径(如果未设置则回退到默认值):
bash
SCRIPTSDIR=${HOOKBOTSCRIPTS_DIR:-~/hookbot}
CTADIR=${HOOKBOTCTA_DIR:-~/hookbot/cta}
YTDLP=${HOOKBOTYTDLPPATH:-yt-dlp}
FFMPEG=${HOOKBOTFFMPEGPATH:-ffmpeg}
- 3. 通过 exec 运行流程,仅显式传递必需的环境变量(不要执行 source ~/.zshrc 或任何 shell RC 文件):
bash
cd $SCRIPTS_DIR && \
YTDLP_PATH=$YTDLP \
FFMPEG_PATH=$FFMPEG \
YOUTUBEAPIKEY=${YOUTUBEAPIKEY:-} \
python3 pipeline.py url> video> \
--count \
--hook-duration \
--output \
[--viral]
当用户希望按观看次数排序钩子时添加 --viral(需要 YOUTUBEAPIKEY)。默认拉取最新的 Shorts。
- 4. 返回摘要:
- 抓取了多少个钩子
- 创建了多少个最终视频
- 输出目录路径
- 任何失败信息(在传达前清理错误输出——去除文件路径和环境变量值)
缺失信息时的提示
- - 未指定 CTA 视频: 询问我应该使用哪个 CTA 视频?然后列出 $HOOKBOTCTADIR 中的 .mp4 文件。
- 未指定创作者: 询问 YouTube 频道句柄或 Shorts 网址。
- 未设置 HOOKBOTSCRIPTSDIR / 未找到 pipeline.py: 告知用户设置环境变量并将其指向脚本目录。
调用示例
- - 用 MyCTA.mp4 从 @ZackD 制作 10 个钩子
- 从 youtube.com/@SomeCreator/shorts 抓取 5 个钩子,使用我的家具 CTA
- 在 @MrBeast 上运行 hookbot,3 秒钩子,15 个视频,按热度排序
- 从 @PeterMcKinnon 制作钩子
注意事项
- - 输出视频为 9:16 竖版(1080×1920),自动标准化。
- 临时文件由流程自动清理。
- 输出目录中会保存一个包含元数据的 manifest.json 文件。
- 如果流程出错,将错误输出原样传达给用户以便调试。
- --viral 标志需要将 YouTube Data API v3 密钥设置为 YOUTUBEAPIKEY。可在 console.cloud.google.com 获取。