当前位置: 首页 > Skill >

bilibili-to-ima-note

bilibili-to-ima-note

bilibili-to-ima-note

This skill should be used when the user shares a Bilibili video URL (bilibili.com) and wants to generate structured notes, summaries, or study notes from the video, then save them to IMA (ima知识库) notes automatically. It covers: extracting BV ID from URL, fetching video info/metadata via Bilibili API, generating structured markdown notes, creating/updating IMA notes via OpenAPI, and appending the video link. Also triggered by requests like "记笔记" combined with a Bilibili link.

1.0.0 2026.11.27 188
获取Skill文件查看使用说明
作 者:陆宁 许可证: 更新时间:2026.11.27
本文目录展开

Bilibili to IMA Note

Overview

Fetch Bilibili video metadata via official API, generate structured markdown notes, and save them to IMA (ima知识库) notes via the IMA OpenAPI. When a note already exists for the same video, append the new content and video link.

Prerequisites

IMA Credentials

IMA credentials must be stored at one of:

  • ~/.config/ima/client_id — Client ID
  • ~/.config/ima/api_key — API Key

Or set as environment variables:

  • IMA_OPENAPI_CLIENTID
  • IMA_OPENAPI_APIKEY

IMA API Script

The IMA OpenAPI wrapper script is located at the pre-installed ima-skill:

  • ~/.workbuddy/skills/skill_2053082144792322048/ima_api.cjs

Always use the full absolute path to this script. Do NOT rely on PATH.

Node.js Runtime

Use the managed Node.js binary:

  • C:Users枉凝眉.workbuddybinariesnodeversions22.22.2node.exe

Workflow

Step 1: Extract BV ID and Fetch Video Info

Given a Bilibili URL (e.g. https://www.bilibili.com/video/BV1ctjm67EiY/), extract the BV ID (the BV followed by alphanumeric characters in the URL path).

Fetch video metadata from the official Bilibili API:

https://api.bilibili.com/x/web-interface/view?bvid={BV_ID}

Key fields to extract from the response data object:

  • title — video title
  • owner.name — UP主 name
  • owner.mid — UP主 mid
  • duration — video duration in seconds
  • desc — video description
  • stat — stats (view, like, favorite, coin, share, reply)
  • tid / tname — category
  • pubdate — publish timestamp (Unix)

Step 2: Generate Structured Notes

Generate markdown notes covering the following structure:

# {Title}

> **视频信息**
> - UP 主:{name}
> - 时长:{duration}秒({minutes}分{seconds}秒)
> - 来源:Bilibili({bvid})
> - 标签:{tags}

---

## 内容概要

[Generate a comprehensive summary of the video based on the title and description.
If description is limited, infer likely content from the title and category.]

---

## 关键知识点

[Organize key points from the video into structured sections with bullet points.]

---

## 总结

[1-2 paragraph summary of the key takeaways.]

Step 3: Save to IMA

Use the IMA OpenAPI to create a note:

node "{IMA_API_SCRIPT}" "openapi/note/v1/import_doc" '{"content_format": 1, "content": "{MARKDOWN_CONTENT_ESCAPED}"}' '{"clientId":"{CLIENT_ID}","apiKey":"{API_KEY}"}'

IMPORTANT — Proper escaping: The content field contains markdown with special characters. Use one of these approaches:

Approach A — Node.js script (preferred): Write a small .cjs script that reads the content from a file, constructs the JSON body programmatically, then calls imaApi by requiring ima_api.cjs directly.

Example:

const path = require('path');
const SKILL_DIR = 'C:/Users/枉凝眉/.workbuddy/skills/skill_2053082144792322048';
const { imaApi } = require(path.join(SKILL_DIR, 'ima_api.cjs'));
const opts = {
  clientId: 'XXXX',
  apiKey: 'XXXX'
};
(async () => {
  const r = await imaApi('openapi/note/v1/import_doc', {
    content_format: 1,
    content: '... markdown ...'
  }, opts);
  console.log('RESULT:', r);
})().catch(e => console.error('ERR:', e.message || e.msg || e));

Approach B — Search then append (if note may already exist): Before creating, search for existing notes by title using search_note. If found, use append_doc instead of import_doc to add content to the existing note.

Search:

openapi/note/v1/search_note
Body: {"search_type": 0, "query_info": {"title": "关键词"}, "start": 0, "end": 5}

Append (if note exists):

openapi/note/v1/append_doc
Body: {"note_id": "EXISTING_NOTE_ID", "content_format": 1, "content": "nn---nn[追加的新内容]"}

Step 4: Append Video Link

After creating the note, append the video link at the end:

openapi/note/v1/append_doc
Body: {"note_id": "NOTE_ID", "content_format": 1, "content": "nn---nn> **视频链接**:[点击观看原视频]({VIDEO_URL})"}

Credential Handling

Credentials are read by ima_api.cjs automatically from:

  1. Options JSON passed as 3rd argument (highest priority)
  2. Environment variables IMA_CLIENT_ID / IMA_API_KEY / IMA_OPENAPI_CLIENTID / IMA_OPENAPI_APIKEY
  3. Files ~/.config/ima/client_id and ~/.config/ima/api_key

When calling directly, pass credentials via the options JSON in the 3rd argument. When credentials are stored in the config files, the third argument can be '{}' or omitted entirely.

Error Handling

  • Bilibili API fails: Try fetching again. If the API returns code !== 0, report the error message to the user.
  • IMA API fails (-100 programmatic error): Check credentials first, then retry.
  • IMA API fails (-200 update available): Follow the update instruction to update the ima-skill, then retry.
  • Content too large: Split into multiple append_doc calls.
  • PowerShell encoding: If running in PowerShell 5.1, the request body will be silently converted to GBK. Either use Git Bash, PowerShell 7+, or the UTF-8 byte array workaround. See the ima-skill SKILL.md for details.

Platform Notes

  • Git Bash (Bash tool): Use forward slashes for paths. The managed node binary works with full paths.
  • PowerShell: PowerShell 5.1 silently encodes request body as GBK. Use UTF-8 byte array mode or switch to Git Bash. Prefer Git Bash for IMA API calls.
  • Python managed runtime: Available at C:Users枉凝眉.workbuddybinariespythonversions3.13.12python.exe
  • Node.js managed runtime: Available at C:Users枉凝眉.workbuddybinariesnodeversions22.22.2node.exe

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,036
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,020
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,019
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,016
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,014
Skill 文件
  • SKILL.md
    • Bilibili to IMA Note
    • Overview
    • Prerequisites
      • IMA Credentials
      • IMA API Script
      • Node.js Runtime
    • Workflow
      • Step 1: Extract BV ID and Fetch Video Info
      • Step 2: Generate Structured Notes
      • Step 3: Save to IMA
      • Step 4: Append Video Link
    • Credential Handling
    • Error Handling
    • Platform Notes
  • 项目或源文件

相关 Skill

更多
Bilibili API Bilibili API 使用 JustOneAPI 分析 Bilibili 工作流,包含视频详情、用户已发布视频和用户资料,共 9 项操作。
Bilibili Video Bilibili Video B站(Bilibili)视频字幕提取与音频转写工具。基于 bilibili-api-python,自带 WBI 签名反爬。 三级降级策略:CC字幕 → AI字幕(9种语言) → 音频下载+ASR转写。 当以下情况时使用: (1) 用户提供 B 站视频链接或 BV/AV/EP/SS 号,要求获取字幕或文字内容 (2...
B站视频转文字&总结神器-Bilibili video transcribe&summary B站视频转文字&总结神器-Bilibili video transcribe&summary 当用户提供 B 站视频链接、BV 号或 b23.tv 短链,并希望转录、提取字幕、总结或分析视频内容时使用。先检查 Node.js 环境和 SILICONFLOW_API_KEY,优先尝试官方字幕;如果没有字幕,则获取匿名音频地址,下载为 .m4s 后直接改名为 .mp3,无需转码;有 API key 时调用硅基...
Bilibili Helper Bilibili Helper B站创作助手。视频标题优化、标签推荐、简介模板、投稿策略、UP主运营、弹幕互动。Bilibili video creator assistant. B站运营、视频SEO、粉丝增长、投币收藏、充电计划。Use when creating content for Bilibili.
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.