No description
- Python 100%
| .vscode | ||
| .gitignore | ||
| danmaku_convert.py | ||
| LICENSE | ||
| README.md | ||
| remux_mkv.py | ||
danmaku-convert
Tools for:
- Converting DandanPlay comment JSON into a simplified array.
- Fetching danmaku from DandanPlay API by Bangumi.tv subject ID.
Requirements
- Python 3.10+
Command Overview
python3 danmaku_convert.py -h
Subcommands:
convert: convert local JSON format.fetch: fetch all episodes by Bangumi subject ID, then download selected episodes.
Convert Local JSON
python3 danmaku_convert.py convert input.json converted.json
Input format example:
{
"count": 136,
"comments": [
{"cid": 1, "p": "343.15,1,16777215,6c0a879c", "m": "text"}
]
}
Output format example:
[
{"text": "text", "time": 343.15, "mode": 0, "color": "#FFFFFF"}
]
Fetch Danmaku by Bangumi Subject ID
The fetch flow is:
- Query
/api/v2/bangumi/bgmtv/{subjectId}to get bangumi details and all episodes. - Show all episodes and let you choose what to download.
- For each episode, call
/api/v2/comment/{episodeId}withwithRelated=true. - Repeat requests with incremental
fromto get all comments. - Merge and deduplicate comments, then write one JSON file per episode.
Interactive episode selection
python3 danmaku_convert.py fetch 975 \
--appid "YOUR_APP_ID" \
--appsecret "YOUR_APP_SECRET" \
--output-dir downloads
Then input selection like 1,3-5 or all.
Non-interactive selection
python3 danmaku_convert.py fetch 975 \
--appid "YOUR_APP_ID" \
--appsecret "YOUR_APP_SECRET" \
--select "1,2,4-6" \
--output-dir downloads
Options
--ch-convert {0,1,2}: Chinese conversion (0 none, 1 simplified, 2 traditional).--delay: delay seconds between requests while paging comments.--max-rounds: max paging rounds per episode.
Default Shortcut: Fetch + Convert (No Intermediate Files)
You can now run:
python3 danmaku_convert.py 454684
This default mode will:
- Fetch all episodes by Bangumi subject ID.
- Ask you to choose episode indexes to download.
- Download full danmaku for selected episodes with
withRelated=true. - Convert directly in memory.
- Save only converted arrays (one JSON per episode), without raw intermediate files.
Optional credentials and tuning:
python3 danmaku_convert.py 454684 \
--appid "YOUR_APP_ID" \
--appsecret "YOUR_APP_SECRET" \
--output-dir converted \
--delay 0.2
If --appid / --appsecret is omitted, script will read env vars:
DANDANPLAY_APPIDDANDANPLAY_APPSECRET
If env vars are also empty, script will prompt for input.
Output Format (fetch)
Each episode produces one JSON file like:
{
"subjectId": 975,
"bangumiTitle": "Example Title",
"episode": {
"episodeId": 123456,
"episodeNumber": "1",
"episodeTitle": "Episode 1",
"airDate": "2024-01-01T00:00:00"
},
"withRelated": true,
"count": 999,
"comments": [
{"cid": 1, "p": "12.3,1,16777215,1001", "m": "hello"}
]
}