discovering-viral-youtube-videos-by-category

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Discovering Viral Youtube Videos By Category

按类别发现YouTube爆火视频



Inputs

输入参数

ParameterTypeRequiredDefaultNotes
type
stringOptional
n
Trending category:
n
(now),
music
,
movies
,
gaming
gl
stringOptional
us
Country code (e.g.
US
,
GB
)
hl
stringOptional
en
Language code (e.g.
en
)
maxItems
numberOptionalUnlimitedMaximum videos to return
customMapFunction
stringOptionalJavaScript function to transform each output object
参数类型是否必填默认值说明
type
string可选
n
热门类别:
n
(当前)、
music
(音乐)、
movies
(电影)、
gaming
(游戏)
gl
string可选
us
国家代码(例如
US
GB
hl
string可选
en
语言代码(例如
en
maxItems
number可选无限制返回的最大视频数量
customMapFunction
string可选用于转换每个输出对象的JavaScript函数

How to Run

运行方式

Using run_actor.js (recommended)

使用run_actor.js(推荐)

bash
undefined
bash
undefined

Quick answer (table)

快速输出(表格形式)

node scripts/run_actor.js --actor "apidojo~youtube-trending-scraper" --input '{"type": "n", "gl": "us", "hl": "en", "maxItems": 50}'
node scripts/run_actor.js --actor "apidojo~youtube-trending-scraper" --input '{"type": "n", "gl": "us", "hl": "en", "maxItems": 50}'

Save as CSV

保存为CSV格式

node scripts/run_actor.js --actor "apidojo~youtube-trending-scraper" --input '{"type": "n", "gl": "us", "hl": "en", "maxItems": 50}' --output results.csv --format csv
node scripts/run_actor.js --actor "apidojo~youtube-trending-scraper" --input '{"type": "n", "gl": "us", "hl": "en", "maxItems": 50}' --output results.csv --format csv

Save as JSON

保存为JSON格式

node scripts/run_actor.js --actor "apidojo~youtube-trending-scraper" --input '{"type": "n", "gl": "us", "hl": "en", "maxItems": 50}' --output results.json --format json
undefined
node scripts/run_actor.js --actor "apidojo~youtube-trending-scraper" --input '{"type": "n", "gl": "us", "hl": "en", "maxItems": 50}' --output results.json --format json
undefined

REST API fallback

备用REST API方式

bash
curl -X POST "https://api.apify.com/v2/acts/apidojo~youtube-trending-scraper/runs" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"type": "n", "gl": "us", "hl": "en", "maxItems": 50}'
If Apify MCP is available: Use the Apify MCP
call_actor
tool with actor
apidojo~youtube-trending-scraper
and the input above.

bash
curl -X POST "https://api.apify.com/v2/acts/apidojo~youtube-trending-scraper/runs" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"type": "n", "gl": "us", "hl": "en", "maxItems": 50}'
如果Apify MCP可用: 使用Apify MCP的
call_actor
工具,指定actor为
apidojo~youtube-trending-scraper
并传入上述输入参数。

Scoring & Ranking

评分与排名

Score each video by:
  • views
    → normalized 0-1 (cap at 10M), weight 0.40
  • likes
    → normalized 0-1 (cap at 500K), weight 0.35
  • recency
    (trending = 1.0 by definition), weight 0.25
python
score = 0.40 * min(views / 10000000, 1.0) + 0.35 * min(likes / 500000, 1.0) + 0.25

按以下标准为每个视频评分:
  • views
    (播放量)→ 归一化至0-1(上限1000万),权重0.40
  • likes
    (点赞数)→ 归一化至0-1(上限50万),权重0.35
  • recency
    (时效性,热门内容默认值为1.0),权重0.25
python
score = 0.40 * min(views / 10000000, 1.0) + 0.35 * min(likes / 500000, 1.0) + 0.25

Classification

分类等级

ScoreTierLabel
≥ 0.70AMEGA_VIRAL
0.40–0.69BTRENDING
< 0.40CRISING

评分等级标签
≥ 0.70AMEGA_VIRAL
0.40–0.69BTRENDING
< 0.40CRISING

Edge Cases

边缘情况

  • Category not available for country: Some countries only have
    n
    (all). Fall back to
    type=n
    .
  • Stale data: Trending changes throughout the day — data is a snapshot.
  • Music/movies category: Returns full songs or trailers — content type differs from regular videos.
  • Livestreams in results: isLive=true items are ongoing streams — filter if you need VOD only.
  • Country mismatch: gl must be a valid ISO country code (e.g.,
    us
    ,
    gb
    ,
    de
    ).
  • 国家无对应类别:部分国家仅支持
    n
    (全部)类别,此时自动 fallback 到
    type=n
  • 数据过时:热门内容全天动态变化,获取的数据仅为当前快照。
  • 音乐/电影类别:返回完整歌曲或预告片,内容类型与常规视频不同。
  • 结果包含直播:标记为isLive=true的条目是正在进行的直播,若仅需点播视频可进行过滤。
  • 国家代码不匹配:gl必须为有效的ISO国家代码(例如
    us
    gb
    de
    )。