apitypes

package
v0.0.0-...-68d1c55 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 5 Imported by: 6

Documentation

Index

Constants

View Source
const (
	SearchTypeSong       = 1
	SearchTypeAlbum      = 10
	SearchTypeArtist     = 100
	SearchTypeCollection = 1000
	SearchTypeUser       = 1002
	SearchTypeMV         = 1004
	SearchTypeLyric      = 1006
	SearchTypePodcast    = 1009
	SearchTypeVideo      = 1014
)

1: 单曲, 10: 专辑, 100: 歌手, 1000: 歌单, 1002: 用户, 1004: MV, 1006: 歌词, 1009: 电台, 1014: 视频

Variables

This section is empty.

Functions

This section is empty.

Types

type APIRequest

type APIRequest struct {
	Method string
	URL    string

	Data H

	Option *RequestOption
}

func NewAPIRequest

func NewAPIRequest(method, url string, data H, opt *RequestOption) *APIRequest

func (*APIRequest) ID

func (r *APIRequest) ID() string

type APIResponse

type APIResponse struct {
	// kind of useless, reserve for future using
	Header *http.Header

	// bytes of http.Response.Body
	Data []byte
}

func NewAPIResponse

func NewAPIResponse(header *http.Header, data []byte) *APIResponse

func (*APIResponse) Deserialize

func (r *APIResponse) Deserialize(v interface{}) error

func (*APIResponse) DeserializeToImplicitResult

func (r *APIResponse) DeserializeToImplicitResult() (*ImplicitResult, error)

4 testing, otherwise had better return []byte ? remind me never ever do this aggin

func (*APIResponse) String

func (r *APIResponse) String() string

type Account

type Account struct {
	ID                 int    `json:"id"`
	Username           string `json:"userName"`
	Type               int    `json:"type"`
	Status             int    `json:"status"`
	WhitelistAuthority int    `json:"whitelistAuthority"`
	CreateTime         int    `json:"createTime"`
	Salt               string `json:"salt"`
	TokenVersion       int    `json:"tokenVersion"`
	Ban                int    `json:"ban"`
	BaoyueVersion      int    `json:"baoyueVersion"`
	DonateVersion      int    `json:"donateVersion"`
	VipType            int    `json:"vipType"`
	ViptypeVersion     int    `json:"viptypeVersion"`
	AnonimousUser      bool   `json:"anonimousUser"`
}

type Album

type Album struct {
	ID    int    `json:"id"`
	Name  string `json:"name"`
	Cover string `json:"picUrl"`
	Size  int    `json:"size"`
	Tags  string `json:"tags"`
	Type  string `json:"type"`
}

type Artist

type Artist struct {
	ID        int    `json:"id"`
	Name      string `json:"name"`
	AccountID int    `json:"accountId"`
	Cover     string `json:"picUrl"`
	AlbumSize int    `json:"albumSize"`
	MvSize    int    `json:"mvSize"`
	Followed  bool   `json:"followed"`
}

type Binding

type Binding struct {
	ExpiresIn    int    `json:"expiresIn"`
	TokenJsonStr string `json:"tokenJsonStr"`
	RefreshTime  int    `json:"refreshTime"`
	BindingTime  int    `json:"bindingTime"`
	Expired      bool   `json:"expired"`
	UserId       int    `json:"userId"`
	Url          string `json:"url"`
	Id           int    `json:"id"`
	Type         int    `json:"type"`
}

type Collection

type Collection struct {
	ID     int    `json:"id"`
	Name   string `json:"name"`
	UserID int    `json:"userId"`

	Cover       string `json:"coverImgUrl"`
	Subscribers int    `json:"bookCount"`
	Description string `json:"description"`

	Subscribed  bool `json:"subscribed"`
	SongCount   int  `json:"trackCount"`
	SpecialType int  `json:"specialType"`

	HighQuality bool `json:"highQuality"`
	PlayCount   int  `json:"playCount"`
}

type H

type H map[string]interface{}

func (H) Json

func (h H) Json() []byte

func (H) Merge

func (h H) Merge(hs ...H) H

func (H) Set

func (h H) Set(k string, v interface{}) H

type ImplicitResult

type ImplicitResult struct {
	Code    int         `json:"code"`
	Msg     string      `json:"msg"`
	Message string      `json:"message"`
	Time    int         `json:"time"`
	Result  interface{} `json:"result"`
	Data    interface{} `json:"data"`
}

basic json response

type LoginResult

type LoginResult struct {
	Code    int     `json:"code"`
	Account Account `json:"account"`
	Token   string  `json:"token"`
	Profile Profile `json:"profile"`

	Bindings []Binding `json:"bindings"`
	Cookie   string    `json:"cookie"`
}

type Profile

type Profile struct {
	City                      int    `json:"city"`
	Description               string `json:"description"`
	DjStatus                  int    `json:"djStatus"`
	AvatarImgId               int    `json:"avatarImgId"`
	AvatarUrl                 string `json:"avatarUrl"`
	BackgroundImgId           int    `json:"backgroundImgId"`
	VipType                   int    `json:"vipType"`
	Province                  int    `json:"province"`
	AccountStatus             int    `json:"accountStatus"`
	Gender                    int    `json:"gender"`
	Mutual                    bool   `json:"mutual"`
	AuthStatus                int    `json:"authStatus"`
	Birthday                  int    `json:"birthday"`
	DefaultAvatar             bool   `json:"defaultAvatar"`
	Nickname                  string `json:"nickname"`
	Followed                  bool   `json:"followed"`
	BackgroundUrl             string `json:"backgroundUrl"`
	DetailDescription         string `json:"detailDescription"`
	UserId                    int    `json:"userId"`
	UserType                  int    `json:"userType"`
	AvatarImgIdStr            string `json:"avatarImgIdStr"`
	BackgroundImgIdStr        string `json:"backgroundImgIdStr"`
	Signature                 string `json:"signature"`
	Authority                 int    `json:"authority"`
	AvatarImgId_str           string `json:"avatarImgId_str"`
	Followeds                 int    `json:"followeds"`
	Follows                   int    `json:"follows"`
	EventCount                int    `json:"eventCount"`
	PlaylistCount             int    `json:"playlistCount"`
	PlaylistBeSubscribedCount int    `json:"playlistBeSubscribedCount"`
}

type RequestOption

type RequestOption struct {
	Crypto  necmcrypto.Crypto
	UA      UserAgentType
	Cookies []*http.Cookie
	RealIP  string
	URL     string
}

func DefaultRequestOption

func DefaultRequestOption() *RequestOption

func (*RequestOption) AddCookie

func (ro *RequestOption) AddCookie(name, value string) *RequestOption

func (*RequestOption) AddCookies

func (ro *RequestOption) AddCookies(cookies ...*http.Cookie) *RequestOption

func (*RequestOption) Cookie

func (ro *RequestOption) Cookie(name string) string

func (*RequestOption) CookieOr

func (ro *RequestOption) CookieOr(name string, dvalue string) string

func (*RequestOption) SetCookies

func (ro *RequestOption) SetCookies(cookies []*http.Cookie) *RequestOption

func (*RequestOption) SetCrypto

func (ro *RequestOption) SetCrypto(c necmcrypto.Crypto) *RequestOption

func (*RequestOption) SetRealIP

func (ro *RequestOption) SetRealIP(ip string) *RequestOption

func (*RequestOption) SetUA

func (ro *RequestOption) SetUA(ua UserAgentType) *RequestOption

func (*RequestOption) SetURL

func (ro *RequestOption) SetURL(u string) *RequestOption

type ResourceType

type ResourceType uint8
const (
	ResourceTypeSong ResourceType = iota
	ResourceTypeMV
	ResourceTypeCollection
	ResourceTypeAlbum
	ResourceTypePodcast
	ResourceTypeVideo
	ResourceTypeMoment
)

type ResourceTypeCode

type ResourceTypeCode string
const (
	ResourceTypeCodeSong    ResourceTypeCode = "R_SO_4_"
	ResourceTypeCodeMV      ResourceTypeCode = "R_MV_5_"
	ResourceTypeCodeCollect ResourceTypeCode = "A_PL_0_"
	ResourceTypeCodeAlbum   ResourceTypeCode = "R_AL_3_"
	ResourceTypeCodePodcast ResourceTypeCode = "A_DJ_1_"
	ResourceTypeCodeVideo   ResourceTypeCode = "R_VI_62_"
	ResourceTypeCodeMoment  ResourceTypeCode = "A_EV_2_"
)

type SearchAlbumResult

type SearchAlbumResult struct {
	Code   int `json:"code"`
	Result struct {
		Albums []Album `json:"albums"`
	} `json:"result"`
}

type SearchArtistResult

type SearchArtistResult struct {
	Code   int `json:"code"`
	Result struct {
		Artists []Artist `json:"artists"`
	} `json:"result"`
}

type SearchCollectionResult

type SearchCollectionResult struct {
	Code   int `json:"code"`
	Result struct {
		Collection []Song `json:"playlists"`
	} `json:"result"`
}

type SearchResult

type SearchResult struct {
	Code   int `json:"code"`
	Result H   `json:"result"`
}

type SearchSongResult

type SearchSongResult struct {
	Code   int `json:"code"`
	Result struct {
		Songs []Song `json:"songs"`
	} `json:"result"`
}

type Song

type Song struct {
	ID       int      `json:"id"`
	Name     string   `json:"name"`
	Album    Album    `json:"al"`
	Artists  []Artist `json:"ar"`
	Duration int      `json:"dt"`
}

type UserAgentType

type UserAgentType uint8
const (
	UAChrome UserAgentType = iota + 1
	UAFirefox
	UAAndroid
	UASafari
	UAIPhone
)

Jump to

Keyboard shortcuts

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