builder

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 剧集信息API
	// https://api.bilibili.com/x/web-interface/view?bvid=BV1KDskz1EHD
	EpisodeInfoAPI = "https://api.bilibili.com/x/web-interface/view?bvid=%s"

	// 用户信息API
	UserInfoAPI = "https://api.bilibili.com/x/web-interface/card?mid=%s"

	// 用户剧集列表API ps max 100, ps=0显示全部
	// https://api.bilibili.com/x/series/recArchivesByKeywords?mid=1596926736&keywords&ps=0
	UserEpisodesAPI = "https://api.bilibili.com/x/series/recArchivesByKeywords?keywords=&mid=%s&pn=%d&ps=%d"

	// Season类型播放列表信息API ps max 100
	// https://api.bilibili.com/x/polymer/web-space/seasons_archives_list?season_id=678635&mid=7380321&page_num=1&page_size=100
	SeasonInfoAPI = "https://api.bilibili.com/x/polymer/web-space/seasons_archives_list?season_id=%s&mid=%s&page_num=%d&page_size=%d"

	// Series类型播放列表信息API
	// https://api.bilibili.com/x/series/series?series_id=1067956
	SeriesInfoAPI = "https://api.bilibili.com/x/series/series?series_id=%s"

	// Series类型播放列表剧集API ps=0显示全部
	// https://api.bilibili.com/x/series/archives?mid=7458285&series_id=1067956&ps=0&pn=1
	SeriesEpisodesAPI = "https://api.bilibili.com/x/series/archives?mid=%s&series_id=%s&ps=%d&pn=%d"

	MaxBilibiliPageSize = 100
)

API URL常量

Variables

This section is empty.

Functions

func ParseURL

func ParseURL(link string) (model.Info, error)

Types

type APIClient

type APIClient struct {
	// contains filtered or unexported fields
}

APIClient API客户端

func NewAPIClient

func NewAPIClient() *APIClient

NewAPIClient 创建新的API客户端

func (*APIClient) DoRequest

func (c *APIClient) DoRequest(url string, result any) error

DoRequest 发送API请求并解析响应

func (*APIClient) GetEpisodeInfo

func (c *APIClient) GetEpisodeInfo(bvid string) (*EpisodeResponse, error)

GetEpisodeInfo 获取剧集信息

func (*APIClient) GetSeasonEpisodesByPage

func (c *APIClient) GetSeasonEpisodesByPage(mid, seasonID string, pageNum, pageSize int) (*SeasonArchivesResponse, error)

GetSeasonEpisodesByPage 分页获取Season类型播放列表剧集

func (*APIClient) GetSeriesEpisodesByPage

func (c *APIClient) GetSeriesEpisodesByPage(mid, seriesID string, pageNum, pageSize int) (*SeriesArchivesResponse, error)

GetSeriesEpisodesByPage 分页获取Series类型播放列表剧集

func (*APIClient) GetSeriesInfo

func (c *APIClient) GetSeriesInfo(seriesID string) (*SeriesInfoResponse, error)

GetSeriesInfo 获取Series类型播放列表信息

func (*APIClient) GetUserEpisodesByPage

func (c *APIClient) GetUserEpisodesByPage(mid string, pageNum, pageSize int) (*UserEpisodesResponse, error)

GetUserEpisodesByPage 分页获取用户剧集列表

func (*APIClient) GetUserInfo

func (c *APIClient) GetUserInfo(mid string) (*UserResponse, error)

GetUserInfo 获取用户信息

type Archive

type Archive struct {
	Aid      int64  `json:"aid"`
	Bvid     string `json:"bvid"`
	CTime    int64  `json:"ctime"`
	Duration int    `json:"duration"`
	Pic      string `json:"pic"`
	PubDate  int64  `json:"pubdate"`
	Stat     struct {
		View int `json:"view"`
	} `json:"stat"`
	State int    `json:"state"`
	Title string `json:"title"`
}

type BilibiliBuilder

type BilibiliBuilder struct {
	// contains filtered or unexported fields
}

func NewBilibiliBuilder

func NewBilibiliBuilder() (*BilibiliBuilder, error)

func (*BilibiliBuilder) Build

func (b *BilibiliBuilder) Build(_ context.Context, cfg *feed.Config) (*model.Feed, error)

type Builder

type Builder interface {
	Build(ctx context.Context, cfg *feed.Config) (*model.Feed, error)
}

func New

func New(ctx context.Context, provider model.Provider, key string, downloader Downloader) (Builder, error)

type Downloader

type Downloader interface {
	PlaylistMetadata(ctx context.Context, url string) (metadata ytdl.PlaylistMetadata, err error)
}

type EpisodeResponse

type EpisodeResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    struct {
		Aid                 int    `json:"aid"`
		Bvid                string `json:"bvid"`
		Title               string `json:"title"`
		Desc                string `json:"desc"`
		Pic                 string `json:"pic"`
		PubDate             int64  `json:"pubdate"`
		Duration            int    `json:"duration"`
		Is_upower_exclusive bool   `json:"is_upower_exclusive"`
		Owner               struct {
			Mid  int    `json:"mid"`
			Name string `json:"name"`
			Face string `json:"face"`
		} `json:"owner"`
		Stat struct {
			View int `json:"view"`
		} `json:"stat"`
	} `json:"data"`
}

剧集信息API响应结构体

type SeasonArchivesResponse

type SeasonArchivesResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	TTL     int    `json:"ttl"`
	Data    struct {
		Aids     []int64   `json:"aids"`
		Archives []Archive `json:"archives"`
		Meta     struct {
			Category    int    `json:"category"`
			Cover       string `json:"cover"`
			Description string `json:"description"`
			Mid         int    `json:"mid"`
			Name        string `json:"name"`
			PTime       int64  `json:"ptime"`
			SeasonID    int    `json:"season_id"`
			Total       int    `json:"total"`
		} `json:"meta"`
		Page struct {
			PageNum  int `json:"page_num"`
			PageSize int `json:"page_size"`
			Total    int `json:"total"`
		} `json:"page"`
	} `json:"data"`
}

Season类型播放列表API响应结构体

type SeriesArchivesResponse

type SeriesArchivesResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    struct {
		Archives []Archive `json:"archives"`
		Page     struct {
			Num   int `json:"num"`
			Size  int `json:"size"`
			Count int `json:"count"`
		} `json:"page"`
	} `json:"data"`
}

Series类型播放列表剧集API响应结构体

type SeriesInfoResponse

type SeriesInfoResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	TTL     int    `json:"ttl"`
	Data    struct {
		Meta struct {
			SeriesID     int      `json:"series_id"`
			Mid          int      `json:"mid"`
			Name         string   `json:"name"`
			Description  string   `json:"description"`
			Keywords     []string `json:"keywords"`
			Creator      string   `json:"creator"`
			State        int      `json:"state"`
			LastUpdateTs int64    `json:"last_update_ts"`
			Total        int      `json:"total"`
			Ctime        int64    `json:"ctime"`
			Mtime        int64    `json:"mtime"`
			RawKeywords  string   `json:"raw_keywords"`
			Category     int      `json:"category"`
		} `json:"meta"`
		RecentAids []int64 `json:"recent_aids"`
	} `json:"data"`
}

Series类型播放列表API响应结构体

type SoundCloudBuilder

type SoundCloudBuilder struct {
	// contains filtered or unexported fields
}

func NewSoundcloudBuilder

func NewSoundcloudBuilder() (*SoundCloudBuilder, error)

func (*SoundCloudBuilder) Build

func (s *SoundCloudBuilder) Build(_ context.Context, cfg *feed.Config) (*model.Feed, error)

type TwitchBuilder

type TwitchBuilder struct {
	// contains filtered or unexported fields
}

func NewTwitchBuilder

func NewTwitchBuilder(clientIDSecret string) (*TwitchBuilder, error)

func (*TwitchBuilder) Build

func (t *TwitchBuilder) Build(_ctx context.Context, cfg *feed.Config) (*model.Feed, error)

type UserEpisodesResponse

type UserEpisodesResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    struct {
		Archives []Archive `json:"archives"`
		Page     struct {
			Num   int `json:"num"`
			Size  int `json:"size"`
			Total int `json:"total"`
		} `json:"page"`
	} `json:"data"`
}

用户剧集列表API响应结构体

type UserResponse

type UserResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    struct {
		Card struct {
			Mid       string `json:"mid"`
			Name      string `json:"name"`
			Face      string `json:"face"`
			Sign      string `json:"sign"`
			Fans      int    `json:"fans"`
			LevelInfo struct {
				CurrentLevel int `json:"current_level"`
			} `json:"level_info"`
			Official struct {
				Title string `json:"title"`
			} `json:"official"`
		} `json:"card"`
		Space struct {
			ViewCount int `json:"viewcount"`
		} `json:"space,omitempty"`
		Follower int `json:"follower"`
	} `json:"data"`
}

用户信息API响应结构体

type VimeoBuilder

type VimeoBuilder struct {
	// contains filtered or unexported fields
}

func NewVimeoBuilder

func NewVimeoBuilder(ctx context.Context, token string) (*VimeoBuilder, error)

func (*VimeoBuilder) Build

func (v *VimeoBuilder) Build(_ context.Context, cfg *feed.Config) (*model.Feed, error)

type YouTubeBuilder

type YouTubeBuilder struct {
	// contains filtered or unexported fields
}

func NewYouTubeBuilder

func NewYouTubeBuilder(key string, ytdlp Downloader) (*YouTubeBuilder, error)

func (*YouTubeBuilder) Build

func (yt *YouTubeBuilder) Build(ctx context.Context, cfg *feed.Config) (*model.Feed, error)

func (*YouTubeBuilder) GetVideoCount

func (yt *YouTubeBuilder) GetVideoCount(ctx context.Context, info *model.Info) (uint64, error)

Jump to

Keyboard shortcuts

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