
Douyin Content Surge
- 230 installs
- 316 repo stars
- Updated August 4, 2026
- redfox-data/redfox-community
Use douyin-content-surge for development tasks
About
douyin-content-surge: A skill for development. This provides functionality for development workflows.
- douyin-content-surge
Douyin Content Surge by the numbers
- 230 all-time installs (skills.sh)
- +14 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #1,715 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/redfox-data/redfox-community --skill douyin-content-surgeAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 230 |
|---|---|
| repo stars | ★ 316 |
| Last updated | August 4, 2026 |
| Repository | redfox-data/redfox-community ↗ |
What it does
Use douyin-content-surge for development tasks
Files
抖音每日点赞飙升榜
📝 简介
日度内容飙升监测工具,每日人工收录核验全平台万级抖音作品,输出单日新增点赞 TOP50 榜单。
- 更新时间:每日 17:00 更新昨日数据
- 回溯范围:最多回溯过去 30 天
- 每个分类最多返回 50 条
✨ 功能特性
| 功能模块 | 能力描述 | 核心价值 |
|---|---|---|
| 飙升榜单 | 每日输出单日新增点赞 TOP50 榜单 | 快速发现单日爆发增长的作品 |
| 赛道筛选 | 支持 28 个赛道分类查询 | 精准定位垂直领域飙升内容 |
| 历史回溯 | 支持回溯过去 30 天数据 | 追溯往期飙升趋势 |
| 可点击链接 | 作品标题以超链接格式输出 | 一键跳转查看原作品 |
| 分页展示 | 默认 TOP20,可查看完整 TOP50 | 按需获取全量或摘要数据 |
| 订阅推送 | 支持赛道和时间偏好订阅 | 定时获取飙升动态 |
🔑 鉴权
前往 红狐hub 获取 API Key,通过以下方式配置:
# 方式一:配置文件(如 OpenClaw 的 ~/.openclaw/openclaw.json)
{ "env": { "REDFOX_API_KEY": "ak_xxxx..." } }
# 方式二:终端环境变量
export REDFOX_API_KEY="ak_xxxx..."📡 API 调用
- 接口地址:
POST https://redfox.hk/story/api/dy/search/hotContentRank - 认证方式:请求头
X-API-KEY,值从环境变量REDFOX_API_KEY获取 - 固定参数:
source(值见脚本) - 可选参数:
type(赛道)、startTime(日期)
详见 api-config.md。
🔄 交互流程
1. 时间判断
| 用户输入 | 处理方式 |
|---|---|
| 今天 / 当前 / 最新 | 回复说明最新为昨日,提供昨日数据 |
| 未来日期 | 回复提示,提供昨日数据 |
| 30天内历史日期 | 直接查询对应日期 |
| 超过30天前 | 回复提示,提供最接近时间范围内的数据 |
时间提示语:
- 当日/未来:「非常抱歉🙏,我们最新的是昨日数据,将为您提供最接近您需求的昨日飙升榜。」
- 超出回溯:「非常抱歉🙏,目前榜单最多支持回溯「过去30天」,我将为您查询最接近您需求的时间范围~」
2. 赛道判断
将用户描述归类至以下支持赛道,未能匹配时明确告知并列出全部赛道,询问用户选择:
全部、小剧场、财富理财、二次元、身体锻炼、居家装修、数码科技、科学普及、
旅行、美食、动物、明星娱乐、汽车、亲子、人文、三农、潮流风尚、游戏、
生活记录、体育、舞蹈才艺、学习教育、休闲玩乐、影视、音乐、颜值造型、
健康医学、综艺、个人成长3. 默认行为
无特殊说明时,默认返回昨日全品类飙升榜。所有查询(包括全品类和特定赛道)均默认展示 TOP20,用户明确要求查看完整榜单时再输出全部 50 条数据。
📊 标准输出格式
榜单以 Markdown 表格呈现,作品标题必须使用 `[标题](workUrl)` 格式输出为可点击的超链接:
💡 榜单说明:每日 17:00 更新昨日数据,[如有时间偏差提示则插入]。飙升数据为单日新增统计,与累计总量存在差异。
📊 抖音每日点赞飙升TOP20(YYYY-MM-DD)[查询全部时含"赛道"列,查询特定赛道时不含]
| 排名 | 作品标题 | 作者 | 赛道* | 新增收藏 | 新增评论 | 新增分享 | **新增点赞** | 发布时间 |
|------|---------|------|-------|---------|---------|---------|------------|---------|
| 1 | [红烧肉的教程](https://www.douyin.com/video/xxx) | 美食达人 | 美食 | 10w+ | 10w+ | 10w+ | **10w+** | 05-28 12:00 |
*查询特定赛道时去掉"赛道"列
⚡ 更多操作
• 本次榜单完整共50条数据,是否需要查看剩余30条?
📬 订阅服务
1️⃣ 我们每日 17:00 更新昨日数据,是否需要订阅每日的抖音作品最新飙升排行,订阅后定时推送给您
2️⃣ 是否需要订阅具体赛道的作品表现?我们支持:[列出28个赛道]作品标题超链接规范
- 作品标题必须以 Markdown 链接格式输出:
[作品标题](workUrl) workUrl为接口返回的share_url字段- 禁止使用 HTML
<a>标签或终端 OSC 转义序列
数据字段说明
| 字段 | 来源字段 | 说明 |
|---|---|---|
| 排名 | 数组位置 | 按新增点赞降序排列 |
| 作品标题 | aweme_desc + share_url | 展示为超链接格式,见上方规范 |
| 作者 | user_nickname | 账号名 |
| 赛道 | category | 仅全品类查询时展示 |
| 新增收藏 / 新增评论 / 新增分享 / 新增点赞 | add_collect_count / add_comment_count / add_share_count / add_digg_count | 单日新增互动数据(入库时间快照),新增点赞列数值需加粗显示 |
| 发布时间 | create_time_str | 格式 MM-DD HH:00 |
📬 文件输出与订阅
- 默认展示 20 条;用户请求完整版时输出 Markdown 表格(含 50 条)
- 订阅:支持用户选择赛道和时间偏好,按每日 17:00 更新后自动推送
📚 其他资源
- API 配置与调用:api-config.md
- 赛道分类与交互示例:interaction-guide.md
Douyin Daily Like Surge Ranking / douyin-content-surge
---
Overview
A daily content surge monitoring tool that tracks tens of thousands of Douyin works platform-wide, delivering a TOP50 ranking of daily new likes across 28 content categories with 30-day historical review capability.
Core Value
- Platform-wide Coverage: Tracks tens of thousands of Douyin works daily across 28 categories (Food, Gaming, Anime, Celebrity, etc.), ensuring no trending content is missed.
- Precise Surge Data: Daily new interactions (likes / favorites / comments / shares) displayed at a glance, separated from cumulative totals for clear growth insight.
- Flexible Category Filtering: Query the full platform ranking or drill into a specific category to focus on what matters to you.
- Historical Backtracking: Access any daily surge ranking within the past 30 days for trend review and periodic analysis.
- Subscription Push: Subscribe by category and time preference; the latest surge ranking is automatically pushed daily at 17:00.
Who It's For
- 📊 Content Operators — Track daily surge trends, discover potential topics and benchmark content.
- 🎬 Short Video Creators — Learn from surge patterns within your category to optimize content direction.
- 🏢 MCN Agencies — Monitor category performance at scale and shape operational strategies.
- 🔍 Data Analysts — Access structured surge data to support content research and reporting.
---
Features
Core Features
- Surge Ranking: Daily TOP50 ranking by new likes — quickly discover works with explosive single-day growth.
- Category Filtering: Supports 28 category filters for precise vertical-niche targeting.
- Historical Lookback: Up to 30 days of historical data for trend review.
- Clickable Links: Work titles output as hyperlinks — one click to the original Douyin video.
- Paginated Display: Defaults to TOP20; full TOP50 available on request.
- Subscription Push: Subscribe by category and time preference for automated daily updates.
---
API Key Acquisition & Security
- This skill requires the environment variable:
REDFOX_API_KEY. REDFOX_API_KEYis provided by RedFoxHub (https://redfox.hk).- Please register an account at RedFoxHub to obtain your
REDFOX_API_KEY. - Configure the
REDFOX_API_KEYenvironment variable on your device before using this skill. - Before providing your key, verify its source, scope, validity period, and whether reset/revocation is supported.
- Never hardcode or expose keys in plain text within code, prompts, logs, or output files.
---
How to Use
Simply describe what you need in natural language — no commands to memorize.
Quick Reference Phrases
| Intent | Example Query | Result |
|---|---|---|
| Full Ranking | "Show me today's Douyin surge ranking" | Returns yesterday's all-category new likes TOP20 |
| Specific Category | "Show me the Food surge ranking" or "How's Fitness trending today?" | Returns yesterday's TOP20 for the specified category |
| Historical Date | "Give me the surge ranking for May 28" | Returns surge data for the specified date |
| Full List | "Full 50 entries for the Food surge ranking" | Returns all 50 entries for the category |
| Daily Subscription | "Subscribe me to daily Food surge rankings" | Auto-pushes latest data daily at 17:00 |
Output Example
After querying, you'll receive a Markdown-formatted ranking with clickable video links:
📊 Douyin Daily Like Surge TOP20 (2026-06-01)
| Rank | Title | Author | Category | New Favs | New Comments | New Shares | New Likes | Publish Time |
|---|---|---|---|---|---|---|---|---|
| 1 | Can you cut watermelon like this? | People's Daily | Food | 5.2w | 137 | 49w+ | 49w+ | 06-01 11:00 |
| 2 | Spicy Lemon Shrimp Recipe | Cheng's Kitchen | Food | 21w+ | 4,548 | 15w+ | 28w+ | 05-28 15:00 |
---
Use Cases
| Scenario | Role | Example Query | Benefit |
|---|---|---|---|
| Daily Surge Monitoring | Content Operators | "What's on today's Douyin surge ranking?" | Quickly grasp daily trending content |
| Category Competitor Research | Short Video Creators | "What's surging in Food these days?" | Understand category patterns to improve content |
| Historical Trend Review | Data Analysts | "Show me the surge data for the last week of May" | Backtrack trends for periodic analysis |
| Daily Subscription Tracking | MCN Agencies | "Subscribe to daily Food and Gaming surge rankings" | Automatic daily delivery, no repeat queries |
---
Important Data Notes
- Update Time: Daily update at 17:00 for the previous day's full data.
- Backtrack Range: Supports historical queries within the past 30 days.
- Data Volume: Up to 50 entries per category; defaults to TOP20 display.
- Data Definition: Surge data represents daily new interaction counts (ingestion time snapshot) and differs from cumulative totals.
抖音每日点赞飙升榜 / douyin-content-surge
---
简介
日度内容飙升监测工具,每日收录核验全平台万级抖音作品,输出单日新增点赞 TOP50 榜单,覆盖 28 个细分赛道,支持 30 天内任意历史日期回溯。
核心价值
- 全平台覆盖:每日收录万级抖音作品,覆盖 28 个赛道(美食、游戏、二次元、明星娱乐等),不遗漏潜力内容。
- 精准飙升数据:单日新增互动(点赞 / 收藏 / 评论 / 分享)一目了然,与累计总量区分,看清当天增长。
- 赛道灵活筛选:支持查询全品类或单独指定赛道,快速聚焦你关心的领域。
- 历史回溯:支持过去 30 天内任意日期的飙升榜单,便于趋势复盘与周期性分析。
- 订阅推送:支持按赛道 + 时间偏好订阅,每日 17:00 自动推送最新飙升榜。
适用对象
- 📊 内容运营 — 追踪每日飙升趋势,发现潜力选题与对标内容。
- 🎬 短视频创作者 — 了解同赛道飙升作品规律,优化创作方向。
- 🏢 MCN 机构 — 批量监控各赛道作品表现,制定运营策略。
- 🔍 数据分析师 — 获取结构化飙升数据,支撑内容研究与报告。
---
功能特性
核心功能
- 飙升榜单:每日输出单日新增点赞 TOP50 榜单,快速发现单日爆发增长的作品。
- 赛道筛选:支持 28 个赛道分类查询,精准定位垂直领域飙升内容。
- 历史回溯:支持回溯过去 30 天数据,追溯往期飙升趋势。
- 可点击链接:作品标题以超链接格式输出,一键跳转查看原作品。
- 分页展示:默认 TOP20,可查看完整 TOP50,按需获取全量或摘要数据。
- 订阅推送:支持赛道和时间偏好订阅,定时获取飙升动态。
---
密钥获取与安全说明
- 本技能需要使用环境变量:
REDFOX_API_KEY。 REDFOX_API_KEY由 红狐 hub (https://redfox.hk)提供。- 请前往 红狐 hub 注册账号,获取
REDFOX_API_KEY。 - 配置设备环境变量
REDFOX_API_KEY后使用本技能。 - 在提供密钥前,请先确认密钥来源、可用范围、有效期及是否支持重置/撤销。
- 禁止在代码、提示词、日志或输出文件中硬编码/明文暴露密钥。
---
使用指南
直接用自然语言描述需求,无需记忆命令。
常用说法速查
| 意图 | 示例话术 | 效果 |
|---|---|---|
| 查全品类飙升榜 | 「看看今天的抖音飙升榜」 | 返回昨日全品类新增点赞 TOP20 |
| 查指定赛道 | 「看看美食飙升榜」「健身赛道今天怎么样」 | 返回指定赛道昨日 TOP20 |
| 查历史日期 | 「给我 5 月 28 号的飙升榜」 | 返回指定日期的飙升数据 |
| 查完整榜单 | 「美食赛道完整 50 条飙升榜」 | 返回指定赛道全部 50 条 |
| 订阅每日推送 | 「帮我订阅美食赛道的每日飙升榜」 | 每日 17:00 自动推送最新数据 |
输出示例
查询后,你将收到 Markdown 格式榜单,作品标题为可点击链接:
📊 抖音每日点赞飙升TOP20(2026-06-01)
| 排名 | 作品标题 | 作者 | 赛道 | 新增收藏 | 新增评论 | 新增分享 | 新增点赞 | 发布时间 |
|---|---|---|---|---|---|---|---|---|
| 1 | 西瓜还能这么切? | 人民日报 | 美食 | 5.2w | 137 | 49w+ | 49w+ | 06-01 11:00 |
| 2 | 酸辣柠檬虾教程 | 城妈爱做菜 | 美食 | 21w+ | 4548 | 15w+ | 28w+ | 05-28 15:00 |
---
使用场景
| 场景 | 角色 | 示例问法 | 收益 |
|---|---|---|---|
| 日常飙升监测 | 内容运营 | 「今天的抖音飙升榜有哪些?」 | 快速掌握当日飙升内容趋势 |
| 赛道竞品研究 | 短视频创作者 | 「看看美食赛道最近什么类型在飙升」 | 了解同赛道规律,优化创作方向 |
| 历史趋势复盘 | 数据分析师 | 「给我 5 月最后一周的飙升数据」 | 回溯趋势,分析周期性规律 |
| 日常订阅追踪 | MCN 机构 | 「订阅美食、游戏两个赛道的每日飙升榜」 | 每日自动获取,无需重复查询 |
---
重要数据说明
- 更新时间:每日 17:00 更新昨日全天数据。
- 回溯范围:支持查询过去 30 天内的历史数据。
- 数据量:每个分类最多返回 50 条;默认展示 TOP20。
- 数据口径:飙升数据为单日新增互动统计(入库时间快照),与累计总量存在差异。
API 配置说明
环境变量配置
在使用本 skill 前,需配置以下环境变量(或在 Qoder 设置中配置 API Key):
REDFOX_API_KEY=your_api_key_here接口说明
查询每日点赞飙升榜
POST https://redfox.hk/story/api/dy/search/hotContentRank
Content-Type: application/json请求头:
| Header | 说明 |
|---|---|
| X-API-KEY | API 密钥,从环境变量 REDFOX_API_KEY 中获取 |
请求体(JSON):
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| type | string | 否 | 赛道分类,默认"全部",见下方分类列表 |
| startTime | string | 否 | 查询日期,格式 YYYY-MM-DD |
| source | string | 是 | 固定参数(值见脚本) |
请求示例:
curl -X POST \
-H "X-API-KEY: $REDFOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"source":"<见脚本>","type":"美食","startTime":"2026-05-28"}' \
"https://redfox.hk/story/api/dy/search/hotContentRank"响应示例:
{
"code": 2000,
"data": [
{
"accountId": "1234567890",
"accountName": "账号名",
"avatarUrl": "https://p3.douyinpic.com/aweme-avatar/xxx.jpeg",
"category": "美食",
"followerCount": 1000000,
"collectCount": 100000,
"commentCount": 50000,
"shareCount": 30000,
"likeCount": 500000,
"title": "作品标题",
"content": "作品正文",
"publishTime": "2026-05-28 12:00:00",
"workId": "7644570847852254031",
"workUrl": "https://www.iesdouyin.com/share/video/7644570847852254031"
}
]
}状态码说明
| 状态码 | 说明 |
|---|---|
| 2000 | 请求成功 |
错误处理
| 错误码 | 说明 | 处理方式 |
|---|---|---|
| 401 | API Key 无效或未配置 | 提示用户检查 API Key 配置 |
| 404 | 该日期数据不存在 | 提示用户该日期暂无数据 |
| 429 | 请求频率超限 | 提示稍后重试 |
| 500 | 服务端错误 | 提示稍后重试 |
支持的赛道分类
全部、小剧场、财富理财、二次元、身体锻炼、居家装修、数码科技、科学普及、
旅行、美食、动物、明星娱乐、汽车、亲子、人文、三农、潮流风尚、游戏、
生活记录、体育、舞蹈才艺、学习教育、休闲玩乐、影视、音乐、颜值造型、
健康医学、综艺、个人成长数据更新时间
- 每日 17:00 更新昨日全天数据
- 可回溯范围:最近 30 天
交互逻辑与示例
完整对话示例
示例 1:查询全品类飙升榜(今天)
用户: 给我今天的抖音全品类飙升榜
Agent:
💡 榜单说明:每日 17:00 更新昨日数据,非常抱歉🙏,我们最新的是昨日数据,将为您提供最接近您需求的昨日飙升榜。飙升数据为单日新增统计,与累计总量存在差异。
📊 抖音每日点赞飙升TOP20(2026-05-28)
| 排名 | 作品标题 | 作者 | 赛道 | 新增收藏 | 新增评论 | 新增分享 | **新增点赞** | 发布时间 |
|------|---------|------|------|---------|---------|---------|------------|---------|
| 1 | [红烧肉的教程](https://www.douyin.com/video/xxx) | 程十安an | 颜值造型 | 10w+ | 10w+ | 10w+ | **10w+** | 05-28 12:00 |
| 2 | [辣炒年糕](https://www.douyin.com/video/xxx) | 小贝饿了 | 美食 | 9w+ | 8w+ | 7w+ | **9w+** | 05-28 09:00 |
...
⚡ 更多操作
• 本次榜单完整共50条数据,是否需要查看剩余30条?
📬 订阅服务
1️⃣ 我们每日 17:00 更新昨日数据,是否需要订阅每日的抖音作品最新飙升排行,订阅后定时推送给您
2️⃣ 是否需要订阅具体赛道的作品表现?我们支持:小剧场、财富理财、二次元、身体锻炼、居家装修、数码科技、科学普及、旅行、美食、动物、明星娱乐、汽车、亲子、人文、三农、潮流风尚、游戏、生活记录、体育、舞蹈才艺、学习教育、休闲玩乐、影视、音乐、颜值造型、健康医学、综艺、个人成长---
示例 2:查询特定赛道
用户: 4月25日美食赛道飙升榜
Agent:
📊 抖音美食赛道点赞飙升TOP20(2026-04-25)
| 排名 | 作品标题 | 作者 | 新增收藏 | 新增评论 | 新增分享 | **新增点赞** | 发布时间 |
|------|---------|------|---------|---------|---------|------------|---------|
| 1 | [家常红烧肉](https://www.douyin.com/video/xxx) | 爱做饭的芋头 | 8w+ | 5w+ | 3w+ | **10w+** | 04-25 18:00 |
...
⚡ 更多操作
• 本次榜单完整共50条数据,是否需要查看剩余30条?---
示例 3:查询超出回溯范围
用户: 三个月前的抖音飙升榜
Agent:
非常抱歉🙏,目前榜单最多支持回溯「过去30天」,我将为您查询最接近您需求的时间范围~
📊 抖音每日点赞飙升TOP20(2026-04-29)[最早可查日期]
...---
示例 4:赛道未匹配
用户: 给我直播赛道的飙升榜
Agent:
抱歉,暂未匹配到「直播」对应的独立赛道分类。目前支持以下28个赛道:
全部、小剧场、财富理财、二次元、身体锻炼、居家装修、数码科技、科学普及、旅行、美食、动物、明星娱乐、汽车、亲子、人文、三农、潮流风尚、游戏、生活记录、体育、舞蹈才艺、学习教育、休闲玩乐、影视、音乐、颜值造型、健康医学、综艺、个人成长
请问您是想查看以上哪个赛道的飙升榜单,还是查看「全部」综合飙升榜?---
示例 5:请求完整 50 条输出
用户: 给我美食赛道今天的完整50条飙升榜
Agent:
调用 API 获取完整 50 条数据,以 Markdown 表格形式输出全部数据,作品标题以 [标题](workUrl) 超链接格式展示。
---
输出数量规则
| 场景 | 展示条数 |
|---|---|
| 默认输出 | 20条,附"是否查看剩余30条"提示 |
| 用户请求完整 | 输出全部50条(Markdown 表格,标题为可点击超链接) |
订阅功能
- 支持用户订阅指定赛道 + 指定时间推送
- 若用户未指定时间,默认每日 17:00 推送
- 订阅确认后告知用户推送时间点
#!/usr/bin/env python3
"""
抖音每日点赞飙升榜查询工具
日度收录全平台抖音作品,输出单日新增点赞TOP50榜单,
支持按赛道分类查询、历史日期回溯。
用法:
python douyin_daily_increment.py # 默认:昨日全品类 TOP20
python douyin_daily_increment.py --type 美食 # 指定赛道
python douyin_daily_increment.py --start 2026-05-28 # 指定日期
python douyin_daily_increment.py --type 美食 --start 2026-05-28 # 指定日期 + 赛道
python douyin_daily_increment.py --full # 输出全部 50 条
环境变量:
REDFOX_API_KEY API 密钥(必填)
"""
import os
import sys
import json
import argparse
from datetime import datetime, timedelta
from urllib.request import Request, urlopen
from urllib.error import HTTPError, URLError
# ────────────────────────────────────────────────────
# 常量
# ────────────────────────────────────────────────────
API_BASE = "https://redfox.hk/story/api/dy/search/hotContentRank"
DEFAULT_LIMIT = 20
FULL_LIMIT = 50
CATEGORIES = [
"全部", "小剧场", "财富理财", "二次元", "身体锻炼", "居家装修",
"数码科技", "科学普及", "旅行", "美食", "动物", "明星娱乐",
"汽车", "亲子", "人文", "三农", "潮流风尚", "游戏",
"生活记录", "体育", "舞蹈才艺", "学习教育", "休闲玩乐", "影视",
"音乐", "颜值造型", "健康医学", "综艺", "个人成长",
]
# ────────────────────────────────────────────────────
# 工具函数
# ────────────────────────────────────────────────────
def format_number(n):
"""将数字格式化为可读字符串,如 10w+、1.2w、5000"""
if n is None:
return "-"
n = int(n)
if n >= 100000:
return f"{n // 10000}w+"
elif n >= 10000:
return f"{n / 10000:.1f}w"
else:
return str(n)
def format_time(ts):
"""将时间字符串转为 MM-DD HH:00 格式"""
if not ts:
return "-"
try:
if isinstance(ts, (int, float)):
dt = datetime.fromtimestamp(ts / 1000)
else:
dt = datetime.strptime(str(ts)[:19], "%Y-%m-%d %H:%M:%S")
return dt.strftime("%m-%d %H:00")
except (ValueError, OSError):
return str(ts)[:16]
def yesterday():
"""返回昨日日期字符串 YYYY-MM-DD"""
return (datetime.now() - timedelta(days=1)).strftime("%Y-%m-%d")
# ────────────────────────────────────────────────────
# API 调用
# ────────────────────────────────────────────────────
def call_api(category="全部", start_time=None):
"""调用抖音每日点赞飙升榜接口,返回解析后的数据列表"""
api_key = os.environ.get("REDFOX_API_KEY", "")
if not api_key:
print("❌ 错误:未配置环境变量 REDFOX_API_KEY,请先设置 API 密钥。")
sys.exit(1)
if start_time is None:
start_time = yesterday()
body = {
"source": "抖音每日点赞飙升榜",
}
if category and category != "全部":
body["type"] = category
if start_time:
body["startTime"] = start_time
json_body = json.dumps(body).encode("utf-8")
req = Request(API_BASE, data=json_body, method="POST")
req.add_header("X-API-KEY", api_key)
req.add_header("Content-Type", "application/json")
req.add_header("Accept", "application/json")
try:
with urlopen(req, timeout=30) as resp:
data = json.loads(resp.read().decode("utf-8"))
except HTTPError as e:
error_handlers = {
401: "API Key 无效或未配置,请检查 REDFOX_API_KEY 环境变量。",
404: "该日期暂无数据。",
429: "请求频率超限,请稍后重试。",
}
msg = error_handlers.get(e.code, f"服务端错误 (HTTP {e.code}),请稍后重试。")
print(f"❌ 错误:{msg}")
sys.exit(1)
except URLError as e:
print(f"❌ 网络错误:无法连接到 API 服务。{e.reason}")
sys.exit(1)
except json.JSONDecodeError:
print("❌ 错误:无法解析 API 响应。")
sys.exit(1)
# 解析响应:数据位于 data.dailyRank
code = data.get("code", -1)
if code != 2000:
print(f"❌ API 返回错误码:{code},消息:{data.get('msg', '未知错误')}")
sys.exit(1)
items = data.get("data", {}).get("dailyRank", [])
if not items:
print("📭 未查询到数据,该条件下暂无榜单记录。")
sys.exit(0)
return items
# ────────────────────────────────────────────────────
# Markdown 输出
# ────────────────────────────────────────────────────
def print_table(items, category, start_time, limit=20):
"""按 SKILL.md 标准输出 Markdown 格式飙升榜单,作品标题为 [标题](workUrl) 超链接"""
display_limit = min(limit, len(items))
date_label = start_time
is_all = (category == "全部" or category is None)
print()
print("💡 榜单说明:每日 17:00 更新昨日数据。飙升数据为单日新增统计,与累计总量存在差异。")
print()
if is_all:
print(f"📊 抖音每日点赞飙升TOP{display_limit}({date_label})")
else:
print(f"📊 抖音{category}赛道点赞飙升TOP{display_limit}({date_label})")
print()
# Markdown 表头
if is_all:
print("| 排名 | 作品标题 | 作者 | 赛道 | 新增收藏 | 新增评论 | 新增分享 | **新增点赞** | 发布时间 |")
print("|------|---------|------|------|---------|---------|---------|------------|---------|")
else:
print("| 排名 | 作品标题 | 作者 | 新增收藏 | 新增评论 | 新增分享 | **新增点赞** | 发布时间 |")
print("|------|---------|------|---------|---------|---------|------------|---------|")
# 数据行
for idx, item in enumerate(items[:limit], start=1):
raw_title = (item.get("aweme_desc") or "-").replace("|", "|").replace("[", "【").replace("]", "】").replace("\n", " ").replace("\r", " ")
work_url = item.get("share_url", "")
if work_url:
title = f"[{raw_title}]({work_url})"
else:
title = raw_title
author = item.get("user_nickname", "-")
cat = item.get("category") or "-"
collect = format_number(item.get("add_collect_count"))
comment = format_number(item.get("add_comment_count"))
share = format_number(item.get("add_share_count"))
like = f"**{format_number(item.get('add_digg_count'))}**"
pub_time = format_time(item.get("create_time_str"))
if is_all:
print(f"| {idx} | {title} | {author} | {cat} | {collect} | {comment} | {share} | {like} | {pub_time} |")
else:
print(f"| {idx} | {title} | {author} | {collect} | {comment} | {share} | {like} | {pub_time} |")
print()
if len(items) > limit:
remaining = len(items) - limit
print("⚡ 更多操作")
print(f"• 本次榜单完整共 {len(items)} 条数据,是否需要查看剩余 {remaining} 条?")
print("• 使用 --full 参数查看完整榜单")
print()
# ────────────────────────────────────────────────────
# 主函数
# ────────────────────────────────────────────────────
def main():
parser = argparse.ArgumentParser(
description="抖音每日点赞飙升榜查询工具",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=f"""
示例:
%(prog)s # 昨日全品类 TOP20
%(prog)s --type 美食 # 美食赛道 TOP20
%(prog)s --start 2026-05-28 # 指定日期 TOP20
%(prog)s --type 美食 --start 2026-05-28 # 指定日期 + 赛道
%(prog)s --full # 输出完整 50 条
支持赛道:
{', '.join(CATEGORIES)}
""",
)
parser.add_argument(
"--type", "-t",
default="全部",
choices=CATEGORIES,
help="赛道分类(默认:全部)",
)
parser.add_argument(
"--start", "-s",
default=None,
help="查询日期,格式 YYYY-MM-DD(默认:昨日)",
)
parser.add_argument(
"--full", "-f",
action="store_true",
help="输出全部 50 条数据",
)
parser.add_argument(
"--limit", "-l",
type=int,
default=None,
help="自定义输出条数(默认 20,最大 50)",
)
args = parser.parse_args()
start_time = args.start or yesterday()
# 获取数据
items = call_api(
category=args.type,
start_time=start_time,
)
# 确定输出条数
if args.full:
limit = FULL_LIMIT
elif args.limit is not None:
limit = min(args.limit, FULL_LIMIT)
else:
limit = DEFAULT_LIMIT
# 输出
print_table(items, args.type, start_time, limit=limit)
if __name__ == "__main__":
main()