biliapi

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2022 License: MIT Imports: 6 Imported by: 0

README

biliapi

Go Reference

部分 bilibili API SDK,大致定了个框架,挑着用得到的 API 先实现了

API 接口信息大多来自 bilibili-API-collect 项目

B站官方代码结构和接口也是可以参考一下的

Example

引用:go get -u github.com/reveever/biliapi.

获取用户投稿

package main

import (
	"encoding/json"
	"fmt"

	"github.com/reveever/biliapi"
	"github.com/reveever/biliapi/interface/space"
)

func main() {
	api, err := biliapi.NewBiliApi(biliapi.WithUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0"))
	if err != nil {
		panic(err)
	}

	resp, err := api.Space.ArcList(space.ArcListOpt{
		Mid: 67141, Pn: 1, Ps: 5,
	})
	if err != nil {
		panic(err)
	}

	buf, _ := json.Marshal(resp)
	fmt.Println(string(buf))
}

获取视频弹幕分片

package main

import (
	"encoding/json"
	"fmt"

	"github.com/reveever/biliapi"
	"github.com/reveever/biliapi/interface/v2dm"
)

func main() {
	api, err := biliapi.NewBiliApi(biliapi.EnableDebugLogger())
	if err != nil {
		panic(err)
	}

	resp, err := api.V2Dm.WebSeg(v2dm.WebSegOpt{
		Type: 1, Oid: 343721233, SegmentIndex: 2,
	})
	if err != nil {
		panic(err)
	}

	buf, _ := json.Marshal(resp)
	fmt.Println(string(buf))
}

Doc & More examples

godoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnableDebugLogger

func EnableDebugLogger() func(*BiliAPI)

func WithAPIEndpoint

func WithAPIEndpoint(a string) func(*BiliAPI)

func WithDebugLogger

func WithDebugLogger(l base.BaseLogger) func(*BiliAPI)

func WithHttpClient

func WithHttpClient(c *http.Client) func(*BiliAPI)

func WithUserAgent

func WithUserAgent(ua string) func(*BiliAPI)

Types

type BiliAPI

type BiliAPI struct {
	Base  *base.Base
	Space *space.API
	V2Dm  *v2dm.API
}

func NewBiliApi

func NewBiliApi(options ...func(*BiliAPI)) (*BiliAPI, error)

Directories

Path Synopsis
interface
proto
dm

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL