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

ibili

v1.1.1

Published

Download the barrage and video from bilibilibili

Downloads

14

Readme

ibili

  • 下载方式: npm i ibili
  • 这是一个获取哔哩哔哩资源的工具库,可以下载哔哩哔哩的视频资源,也可以下载视频弹幕,下载用户评论等等之类
  • 严重警告:不可以将获取的资源用于恶意用途
  • 有以下功能:

loadbarrage:下载视频弹幕

  • loadbarrage 的返回值是一个 promise对象,promise 的值就是视频弹幕数据

使用案例:

  • 比如说要下载 周杰伦的告白气球MV 的视频弹幕,可以知道播放地址就是 https://www.bilibili.com/video/av15227278?from=search&seid=16573406510590472928
const ibili = require('ibili')
const fs = require('fs')
// 使用 视频播放地址获取弹幕
ibili.loadbarrage('https://www.bilibili.com/video/av15227278?from=search&seid=16573406510590472928').then(function(data){
    // 将数据存进demo.json文件中,你可以打开demo.json可以清楚的看到弹幕的数据
    fs.writeFile('demo.json',JSON.stringify(data,null,5),function(){
        console.log('ok')
    })
})
const ibili = require('ibili')
const fs = require('fs')
// 使用 视频的av号说去视频弹幕
ibili.loadbarrage('51560305').then(function(data){
    // 将数据存进demo.json文件中,你可以打开demo.json可以清楚的看到弹幕的数据
    fs.writeFile('demo.json',JSON.stringify(data,null,5),function(){
        console.log('ok')
    })
})
  • 比如要下载整部番剧的弹幕,以 刀剑神域 Alicization 为例,要下载整部番剧的弹幕数据的话可以这样,首先要知道番剧的第一集的播放地址(url),然后要知道整部番剧的总集数(num)是多少
const ibili = require('ibili')
const fs = require('fs')
ibili.loadbarrage({
    url:'https://www.bilibili.com/bangumi/play/ep250536', // 番剧的第一集的播放地址
    num:24 // 番剧的总集数
}).then(function(data){
    var merges = data.merge_barrages // 获取合并之后的弹幕
    console.log(merges.length) // 打印弹幕的总条数
    // 将数据存进demo.json文件中,你可以打开demo.json可以清楚的看到弹幕的数据
    fs.writeFile('demo.json',JSON.stringify(merges,null,5),function(){
        console.log('ok')
    })
})

// 打印结果
75301 // 可以看到整部番剧的弹幕有75301条
15443 // 下载整部番剧的弹幕用时 15秒
ok
  • 下载整部番剧的弹幕数据用时比较长,实际上num可以是任意值,但是要满足 num <= 总集数

downloadVideo:下载视频资源

  • opt 有以下属性:
  • progress 对象的属性如下:
  • urlav 一般只需要一个就可以了,但是如果两个参数都有,那么优先使用 av
  • 使用案例:
  • 比如要下载 周杰伦告白气球MV,可以知道视频的播放地址就是https://www.bilibili.com/video/av15227278?from=search&seid=1147385259116260142
const ibili = require('ibili')
ibili.downloadVideo({
    url:'https://www.bilibili.com/video/av15227278?from=search&seid=1147385259116260142'
}).then(()=>{
    console.log('视频下载完成!')
})
  • 同样也可以使用av号下载视频资源
  • 还可以下载整部番剧的视频资源,比如下载 群居姐妹整部番剧,首先要知道番剧第一集的播放地址(url),还有整部番剧的总集数(num)
const ibili = require('ibili')
ibili.downloadVideo({
    url:'https://www.bilibili.com/bangumi/play/ep63865', // 番剧的第一集播放地址
    folder:'media/群居姐妹', // 将视频资源存放在 media文件夹下的 群居姐妹 文件夹里
    sessdata:'b6714909%2C158***3693%2C1a29f0c1', // 使用 sessdata,这样可以下载 1080p的视频
    num:12 // 番剧的总集数
}).then(()=>{
    console.log('番剧下载完成!')
})

loademojis:下载表情包

const ibili = require('ibili')
ibili.loademojis({}).then(()=>{
    console.log('表情包下载完成!')
})

loadcomments: 获取视频下的评论

  • 如果 opt是object,那么可以忽略第二个参数page,和第三个参数mode,opt的属性如图:

使用案例:

const ibili = require('ibili')
const fs = require('fs')
ibili.loadcomments({
    url:'https://www.bilibili.com/video/av15227278?from=search&seid=11837609076354078745' // 视频的播放地址(url)
}).then(data=>{
    // 将评论数据存储在demo.json文件里边
    fs.writeFile('demo.json',JSON.stringify(data,null,5),function(){
        console.log('ok')
    })
})

loadsearch: 获取搜索结果

  • 如果opt是object

使用案例:

const ibili = require('ibili')
const fs = require('fs')
ibili.loadsearch({
    content:'告白气球' // 搜索内容
}).then(data=>{
    // 将搜索结果数据存进 demo.json文件里边
    fs.writeFile('demo.json',JSON.stringify(data,null,5),function(){
        console.log('ok')
    })
})