npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@summonhim/koishi-plugin-bili-parser

v1.2.3

Published

A koishi plugin use to parse bilibili links.

Downloads

340

Readme

@summonhim/koishi-plugin-bili-parser

npm

A koishi plugin use to parse bilibili links.

一个能够解析 BiliBili 链接的 Koishi 插件。

Depends/前置依赖

Usage/使用方法

Video/视频

When regex match bilibili\.com\/video\/([ab]v[0-9a-zA-Z]+), reply

当正则表达式符合 bilibili\.com\/video\/([ab]v[0-9a-zA-Z]+),回复

{{title}}
<img src=\"{{pic}}\" />
UP主:{{owner.name}}
{{truncate desc 35}}
点赞:{{formatNumber stat.like}}\t\t投币:{{formatNumber stat.coin}}
收藏:{{formatNumber stat.favorite}}\t\t转发:{{formatNumber stat.share}}
观看:{{formatNumber stat.view}}\t\t弹幕:{{formatNumber stat.danmaku}}
https://www.bilibili.com/video/{{bvid}}

Live/直播

When regex match live\.bilibili\.com(?:\/h5)?\/(\d+), reply

当正则表达式符合 live\.bilibili\.com(?:\/h5)?\/(\d+),回复

[{{formatLiveStatus live_status}}]{{title}}
<img src=\"{{user_cover}}\" />
{{description}}
观看:{{formatNumber online}}\t\t关注:{{formatNumber attention}}
https://live.bilibili.com/{{room_id}}

Bangumi/番剧

When regex match bilibili\.com\/bangumi\/play\/((ep|ss)(\d+)), bilibili\.com\/bangumi\/media\/(md(\d+)), reply

当正则表达式符合 bilibili\.com\/bangumi\/play\/((ep|ss)(\d+))bilibili\.com\/bangumi\/media\/(md(\d+)),回复

{{season_title}}({{rating.score}}分)
<img src=\"{{cover}}\" />
{{truncate evaluate 35}}
点赞:{{formatNumber stat.likes}}\t\t投币:{{formatNumber stat.coins}}
追番:{{formatNumber stat.favorites}}\t\t转发:{{formatNumber stat.share}}
播放:{{formatNumber stat.views}}\t\t弹幕:{{formatNumber stat.danmakus}}
https://www.bilibili.com/bangumi/media/md{{media_id}}
{{season_title}}({{rating.score}}分)
<img src=\"{{getCurrentEpisode "cover"}}\" />
第 {{getCurrentEpisode "title"}} 话 - {{getCurrentEpisode "long_title"}}
{{truncate evaluate 35}}
点赞:{{formatNumber stat.likes}}\t\t投币:{{formatNumber stat.coins}}
追番:{{formatNumber stat.favorites}}\t\t转发:{{formatNumber stat.share}}
播放:{{formatNumber stat.views}}\t\t弹幕:{{formatNumber stat.danmakus}}
https://www.bilibili.com/bangumi/play/ep{{getCurrentEpisode "ep_id"}}

Article/专栏

When regex match bilibili\.com\/read\/cv(\d+), bilibili\.com\/read\/mobile(?:\?id=|\/)(\d+), reply

当正则表达式符合 bilibili\.com\/read\/cv(\d+)bilibili\.com\/read\/mobile(?:\?id=|\/)(\d+),回复

{{title}}
<img src=\"{{banner_url}}\" />
UP主:{{author_name}}
点赞:{{formatNumber stats.like}}\t\t投币:{{formatNumber stats.coin}}
观看:{{formatNumber stats.view}} | 收藏:{{formatNumber stats.favorite}} | 转发:{{formatNumber stats.share}}
https://www.bilibili.com/read/{{getArticleID}}

Audio/音乐

由于音乐 API 已被加密。所以暂时禁用该 API。

Opus/动态

When regex match bilibili\.com\/opus\/(\d+), reply

当正则表达式符合 bilibili\.com\/opus\/(\d+),回复

{{modules.module_author.name}}的动态
<img src=\"{{modules.module_dynamic.additional.goods.items.[0].cover}}\" />
{{modules.module_dynamic.desc.text}}
转发:{{formatNumber modules.module_stat.forward.count}} | 评论:{{formatNumber modules.module_stat.comment.count}} | 点赞:{{formatNumber modules.module_stat.like.count}}

Space/空间

When regex match space\.bilibili\.com\/(\d+), reply

当正则表达式符合 space\.bilibili\.com\/(\d+),回复

{{module_author.name}}
<img src=\"{{module_author.face}}\" />
https://space.bilibili.com/{{module_author.mid}}

Short link/短链接

When regex match b23\.tv\/([0-9a-zA-Z]+), bili(?:22|23|33)\.cn\/([0-9a-zA-Z]+), reply

当正则表达式符合 b23\.tv\/([0-9a-zA-Z]+)bili(?:22|23|33)\.cn\/([0-9a-zA-Z]+),会先解析回原链接,之后会自动交给以上方法处理。

Light App/小程序

When regex match https:\\\/\\\/b23.tv\\\/(.+)\?, reply

当正则表达式符合 https:\\\/\\\/b23.tv\\\/(.+)\?,会先解析回原链接,之后会自动交给以上方法处理。

自定义文本预设

假如说你需要修改视频的文本预设:

  1. 为本插件开启调试日志。

koishi.yml

logger:
  levels:
    bili-parser: 3
  1. 发送一个视频链接给 Bot。此时日志会输出从 API 中获取来的 Json 数据。例:
bVideo api return: {
    "name": "SummonHIM",
    "id": "11223344",
    "dict": {
        "aa": "AA",
        "bb": "BB"
    },
    "array": [
        123,
        "HIM"
    ]
}
  1. 根据以上 Json 数据来编写自定义的文本预设占位符。
{{name}} - {{id}}
{{dict.aa}} - {{dict.bb}}
{{array.[0]}} - {{array.[1]}}
SummonHIM - 11223344
AA - BB
123 - HIM

有关更多占位符使用方法,请参阅 Handlebars.js

Handlebars Helper 介绍

全局

  • formatNumber: 数字简化,例:"formatNumber 1638" 会转换为 "1.6k"。
  • truncate: 字符串截断,例:"truncate 啊啊啊啊啊啊啊啊啊啊啊 5" 会被省略为“啊啊啊啊啊啊…”。

专栏

  • getArticleID: 用于返回专栏 ID。

番剧

  • getCurrentEpisode: 返回当前集的字典。例:'getCurrentEpisode "title"' 会返回当前集的标题。

直播

  • formatLiveStatus: 文字化当前直播状态。例:"formatNumber online"。