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

@lawchihon/bilibili-api

v0.0.1

Published

API helper to get info from bilibili.com

Downloads

1

Readme

bilibili-api

API helper to get info from bilibili.com

Installation

npm install @lawchihon/bilibili-api

Peer Dependencies

  • @johman/helper: Joined mini functions to help minimize duplicated coding between projects.
  • axios: Promise based HTTP client for the browser and node.js.
  • cheerio: Fast, flexible, and lean implementation of core jQuery designed specifically for the server.
  • lodash: A modern JavaScript utility library delivering modularity, performance & extras.

Note: Peer dependencies are required to be installed.

Documentation

Note: All functions are returning in promise and optional to pass a custom axios instance

  • alive: Check if bilibili.com is accessible
const alive = await Bilibili.alive();
const alive = await Bilibili.alive(axiosInstance);
const alive = await Bilibili.alive({instance: axiosInstance});
  • getFilters: Get the filters that is using on bilibili.com
const filters = await Bilibili.getFilters();
const filters = await Bilibili.getFilters(axiosInstance);
const filters = await Bilibili.getFilters({instance: axiosInstance});
  • getVideos: Search for videos on bilibili.com

Note: Only 'keyword' is required in order to search for videos

Note2: 'page' must be >= 1

const videos = await Bilibili.getVideos(order, page, keyword, duration, typeId, instance);
const videos = await Bilibili.getVideos({order, page, keyword, duration, typeId, instance});
  • getPlayUrl: Get the url to the flash video

Note: Either 'id'/'bvid'/'aid' is required in order to search for videos

Note2: 'page' must be >= 1

const playUrl = await Bilibili.getPlayUrl(id, bvid, cid, aid, page, instance);
const playUrl = await Bilibili.getPlayUrl({id, bvid, cid, aid, page, instance});
  • getVideo: Get the video info base on id/bvid/aid

Note: Either 'id'/'bvid'/'aid' is required in order to search for videos

Note2: If 'cid'/'page' is passed, it will return info for that cid/page specifically

const video = await Bilibili.getVideo(id, bvid, cid, aid, page, instance);
const video = await Bilibili.getVideo({id, bvid, cid, aid, page, instance});

Video format

{
    // custom bilibili video id
    id: String,
    // previous bilibili video id
    aid: String,
    // new bilibili video id
    bvid: String,
    // title of video
    title: String,
    // name of video type
    type: String,
    // name of the author
    author: String,
    // id of the author
    mid: String,
    // video description
    description: String,
    // string of video picture link
    picture: String,
    // date of publish
    publishDate: Number,
    // array of tag name
    tags: Array<String>
    // number of views
    views: Number,
    // number of reviews
    reviews: Number,
    // number of favorites
    favorites: Number
    // array of page
    pages: Array<VideoPage>
}

Video page format

Note: it is based on the video and added cid and playUrl info

{
    // custom bilibili video id
    id: String,
    // previous bilibili video id
    aid: String,
    // new bilibili video id
    bvid: String,
    // use to identify video within 
    cid: String,
    // title of video
    title: String,
    // name of video type
    type: String,
    // name of the author
    author: String,
    // id of the author
    mid: String,
    // video description
    description: String,
    // string of video picture link
    picture: String,
    // date of publish
    publishDate: Number,
    // array of tag name
    tags: Array<String>
    // number of views
    views: Number,
    // number of reviews
    reviews: Number,
    // number of favorites
    favorites: Number
    // array of page
    pages: Array<VideoPage>
    // url to the flash video
    playUrl: String
    // dash info for video
    playInfo: Object
}

Testing

npm run test

License

MIT