Skip to content
bili

Quick start

From an empty terminal to a real video, its comments, and its bullet-chat, in a handful of commands.

This walks the core loop: resolve an id, read a video's full metadata, and pull its comments and danmaku. Every command here hits live data and finishes in a second or two. No login required.

1. Resolve an id

bili id tells you what a string is before you do anything with it:

bili id BV17x411w7KC
{"kind":"video","bvid":"BV17x411w7KC","aid":170001,"input":"BV17x411w7KC"}

That is the piped form. On a terminal the same call renders as a table, and -o list reads it down the page one field at a time.

It accepts any form: an av number, a BV string, a space.bilibili.com link, an ss/ep season or episode, and more. The other commands accept all the same forms, so you rarely call id directly; it is just the quickest way to see how something will be classified.

2. Read a video

bili video BV17x411w7KC --fields bvid,aid,title,owner_name,view_count,pubdate_text
bvid          aid     title                     owner_name  view_count  pubdate_text
BV17x411w7KC  170001  【MV】保加利亚妖王AZIS视频合辑    冰封.虾子      45703352    2011-11-09 21:55:33

The table is a projection of a much richer record. Ask for JSON to see everything the API returns:

bili video BV17x411w7KC -o json

3. Pull the conversation

Every comment and reply on the video, one JSON object per line:

bili comments BV17x411w7KC -o jsonl | head

The bullet-chat (danmaku) for the video, decoded from protobuf into rows:

bili danmaku BV17x411w7KC -n 5 --fields progress_ms,mode,color,content
progress_ms  mode  color     content
0            5     16707842  请   君   入   瓮
0            1     41194     《凉屋游戏》
...

progress_ms is the millisecond offset into the video where the comment appears, which is the field to sort and bucket on.

4. Find things

Search, and feed the results into another command:

bili search lofi -o url | head
bili popular -n 5             # the popular feed
bili trending                # current hot-search terms

5. Compose

Output that pipes is the point. Resolve every search hit to full metadata:

bili search lofi -o url | bili video -

Crawl a seed video plus its comments and related videos into JSONL files:

bili crawl BV17x411w7KC --out ./data --comments
ls ./data
# comments.jsonl  users.jsonl  videos.jsonl

Where to next

You have the core loop. From here: