baidu

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Input = "2012171402992850"
	IV    = "2012061402992850"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Client *ghttp.Client
}

func Client

func Client() *API

func New

func New(client *ghttp.Client) *API

func (*API) GetAlbum

func (a *API) GetAlbum(ctx context.Context, albumId string) (*api.Collection, error)

func (*API) GetAlbumRaw

func (a *API) GetAlbumRaw(ctx context.Context, albumId string) (*AlbumResponse, error)

获取专辑

func (*API) GetArtist

func (a *API) GetArtist(ctx context.Context, tingUid string, page int, pageSize int) (*api.Collection, error)

func (*API) GetArtistRaw

func (a *API) GetArtistRaw(ctx context.Context, tingUid string, offset int, limits int) (*ArtistResponse, error)

获取歌手

func (*API) GetPlayLists

func (a *API) GetPlayLists(ctx context.Context, page int, pageSize int) ([]*api.Playlist, error)

func (*API) GetPlaylist

func (a *API) GetPlaylist(ctx context.Context, playlistId string) (*api.Collection, error)

func (*API) GetPlaylistRaw

func (a *API) GetPlaylistRaw(ctx context.Context, playlistId string) (*PlaylistResponse, error)

获取歌单

func (*API) GetRank

func (a *API) GetRank(ctx context.Context) ([]*api.Rank, error)

func (*API) GetRankList

func (a *API) GetRankList(ctx context.Context, bangId string, page int, pageSize int) ([]*api.Song, error)

func (*API) GetSong

func (a *API) GetSong(ctx context.Context, songId string) (*api.Song, error)

func (*API) GetSongLyric

func (a *API) GetSongLyric(ctx context.Context, songId string) (string, error)

func (*API) GetSongLyricRaw

func (a *API) GetSongLyricRaw(ctx context.Context, songId string) (*SongLyricResponse, error)

获取歌词

func (*API) GetSongRaw

func (a *API) GetSongRaw(ctx context.Context, songId string) (*SongResponse, error)

获取歌曲

func (*API) GetSongsRaw

func (a *API) GetSongsRaw(ctx context.Context, songIds ...string) (*SongsResponse, error)

批量获取歌曲,遗留接口,不推荐使用

func (*API) SearchSongs

func (a *API) SearchSongs(ctx context.Context, keyword string, page int, pageSize int) ([]*api.Song, error)

func (*API) SearchSongsRaw

func (a *API) SearchSongsRaw(ctx context.Context, keyword string, page int, pageSize int) (*SearchSongsResponse, error)

搜索歌曲

func (*API) SendRequest

func (a *API) SendRequest(req *ghttp.Request) (*ghttp.Response, error)

type AlbumResponse

type AlbumResponse struct {
	CommonResponse
	AlbumInfo struct {
		AlbumId string `json:"album_id"`
		Title   string `json:"title"`
		PicBig  string `json:"pic_big"`
	} `json:"albumInfo"`
	SongList []*Song `json:"songlist"`
}

百度的这个接口设计比较坑爹,无数据时albumInfo字段为数组类型,导致json反序列化失败

func (*AlbumResponse) String

func (a *AlbumResponse) String() string

type ArtistResponse

type ArtistResponse struct {
	CommonResponse
	ArtistInfo struct {
		TingUid   string `json:"ting_uid"`
		Name      string `json:"name"`
		AvatarBig string `json:"avatar_big"`
	} `json:"artistinfo"`
	SongList []*Song `json:"songlist"`
}

func (*ArtistResponse) String

func (a *ArtistResponse) String() string

type CommonResponse

type CommonResponse struct {
	ErrorCode    int    `json:"error_code,omitempty"`
	ErrorMessage string `json:"error_message,omitempty"`
}

type PlaylistResponse

type PlaylistResponse struct {
	CommonResponse
	Result struct {
		Info struct {
			ListId    string `json:"list_id"`
			ListTitle string `json:"list_title"`
			ListPic   string `json:"list_pic"`
		} `json:"info"`
		SongList []*Song `json:"songlist"`
	} `json:"result"`
}

func (*PlaylistResponse) String

func (p *PlaylistResponse) String() string

type SearchSongsResponse

type SearchSongsResponse struct {
	CommonResponse
	Result struct {
		SongInfo struct {
			SongList []*Song `json:"song_list"`
		} `json:"song_info"`
	} `json:"result"`
}

func (*SearchSongsResponse) String

func (s *SearchSongsResponse) String() string

type Song

type Song struct {
	SongId     string `json:"song_id"`
	Title      string `json:"title"`
	TingUid    string `json:"ting_uid"`
	Author     string `json:"author"`
	AlbumId    string `json:"album_id"`
	AlbumTitle string `json:"album_title"`
	PicBig     string `json:"pic_big"`
	LrcLink    string `json:"lrclink"`
	CopyType   string `json:"copy_type"`
	URL        string `json:"-"`
	Lyric      string `json:"-"`
}

type SongLyricResponse

type SongLyricResponse struct {
	CommonResponse
	Title      string `json:"title"`
	LrcContent string `json:"lrcContent"`
}

func (*SongLyricResponse) String

func (s *SongLyricResponse) String() string

type SongResponse

type SongResponse struct {
	CommonResponse
	SongInfo Song `json:"songinfo"`
	SongURL  struct {
		URL []URL `json:"url"`
	} `json:"songurl"`
}

func (*SongResponse) String

func (s *SongResponse) String() string

type SongsResponse

type SongsResponse struct {
	ErrorCode int `json:"errorCode"`
	Data      struct {
		SongList []*struct {
			SongId     int    `json:"songId"`
			SongName   string `json:"songName"`
			ArtistId   string `json:"artistId"`
			ArtistName string `json:"artistName"`
			AlbumId    int    `json:"albumId"`
			AlbumName  string `json:"albumName"`
			SongPicBig string `json:"songPicBig"`
			LrcLink    string `json:"lrcLink"`
			CopyType   int    `json:"copyType"`
			SongLink   string `json:"songLink"`
			ShowLink   string `json:"showLink"`
			Format     string `json:"format"`
			Rate       int    `json:"rate"`
		} `json:"songList"`
	} `json:"data"`
}

func (*SongsResponse) String

func (s *SongsResponse) String() string

type URL

type URL struct {
	ShowLink    string `json:"show_link"`
	FileFormat  string `json:"file_format"`
	FileBitrate int    `json:"file_bitrate"`
	FileLink    string `json:"file_link"`
}

Jump to

Keyboard shortcuts

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