neteaseapi

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IsTest = os.Getenv("IS_TEST")

IsTest 是否测试环境

View Source
var NetEaseAPIBaseURL = "http://netease-api:3335"

NetEaseAPIBaseURL 网易云API基础URL

View Source
var NetEaseGCtx = &NetEaseContext{}

NetEaseGCtx 网易云全局API调用封装

Functions

This section is empty.

Types

type Album

type Album struct {
	Name        string `json:"name"`
	IDStr       string `json:"idStr"`
	Type        string `json:"type"`
	PicURL      string `json:"picUrl"`
	PublishTime int64  `json:"publishTime"`
	Artist      struct {
		Name string `json:"name"`
	} `json:"artist"`
}

type AlbumDetail

type AlbumDetail struct {
	Songs []Song `json:"songs"`
}

type CommentResult

type CommentResult struct {
	Data struct {
		CommentsTitle string `json:"commentsTitle"`
		Comments      []struct {
			Content string `json:"content"`
			TimeStr string `json:"timeStr"`
		}
	} `json:"data"`
	Message string `json:"message"`
}

type CommentType

type CommentType string
const (
	CommentTypeSong  CommentType = "0"
	CommentTypeAlbum CommentType = "3"
)

type GlobRecommendMusicRes

type GlobRecommendMusicRes struct {
	Result []struct {
		PicURL string `json:"picUrl"`
		Song   struct {
			Name    string `json:"name"`
			ID      int    `json:"id"`
			Artists []struct {
				Name string `json:"name"`
				ID   int    `json:"id"`
			} `json:"artists"`
		} `json:"song"`
	} `json:"result"`
}

GlobRecommendMusicRes 推荐音乐返回结果

type LoginStatusStruct

type LoginStatusStruct struct {
	Data struct {
		Code    int                    `json:"code"`
		Account map[string]interface{} `json:"account"`
		Profile map[string]interface{} `json:"profile"`
	} `json:"data"`
}

LoginStatusStruct 登录状态

type MusicDetail

type MusicDetail struct {
	Songs []struct {
		Name string `json:"name"`
		ID   int    `json:"id"`
		Pst  int    `json:"pst"`
		T    int    `json:"t"`
		Ar   []struct {
			ID    int           `json:"id"`
			Name  string        `json:"name"`
			Tns   []interface{} `json:"tns"`
			Alias []interface{} `json:"alias"`
		} `json:"ar"`
		Alia []interface{} `json:"alia"`
		Pop  int           `json:"pop"`
		St   int           `json:"st"`
		Rt   string        `json:"rt"`
		Fee  int           `json:"fee"`
		V    int           `json:"v"`
		Crbt interface{}   `json:"crbt"`
		Cf   string        `json:"cf"`
		Al   struct {
			ID     int           `json:"id"`
			Name   string        `json:"name"`
			PicURL string        `json:"picUrl"`
			Tns    []interface{} `json:"tns"`
			PicStr string        `json:"pic_str"`
			Pic    int64         `json:"pic"`
		} `json:"al"`
		Dt int `json:"dt"`
		H  struct {
			Br   int `json:"br"`
			Fid  int `json:"fid"`
			Size int `json:"size"`
			Vd   int `json:"vd"`
			Sr   int `json:"sr"`
		} `json:"h"`
		M struct {
			Br   int `json:"br"`
			Fid  int `json:"fid"`
			Size int `json:"size"`
			Vd   int `json:"vd"`
			Sr   int `json:"sr"`
		} `json:"m"`
		L struct {
			Br   int `json:"br"`
			Fid  int `json:"fid"`
			Size int `json:"size"`
			Vd   int `json:"vd"`
			Sr   int `json:"sr"`
		} `json:"l"`
		Sq                   interface{}   `json:"sq"`
		Hr                   interface{}   `json:"hr"`
		A                    interface{}   `json:"a"`
		Cd                   string        `json:"cd"`
		No                   int           `json:"no"`
		RtURL                interface{}   `json:"rtUrl"`
		Ftype                int           `json:"ftype"`
		RtUrls               []interface{} `json:"rtUrls"`
		DjID                 int           `json:"djId"`
		Copyright            int           `json:"copyright"`
		SID                  int           `json:"s_id"`
		Mark                 int           `json:"mark"`
		OriginCoverType      int           `json:"originCoverType"`
		OriginSongSimpleData interface{}   `json:"originSongSimpleData"`
		TagPicList           interface{}   `json:"tagPicList"`
		ResourceState        bool          `json:"resourceState"`
		Version              int           `json:"version"`
		SongJumpInfo         interface{}   `json:"songJumpInfo"`
		EntertainmentTags    interface{}   `json:"entertainmentTags"`
		AwardTags            interface{}   `json:"awardTags"`
		Single               int           `json:"single"`
		NoCopyrightRcmd      interface{}   `json:"noCopyrightRcmd"`
		Mv                   int           `json:"mv"`
		Rtype                int           `json:"rtype"`
		Rurl                 interface{}   `json:"rurl"`
		Mst                  int           `json:"mst"`
		Cp                   int           `json:"cp"`
		PublishTime          int           `json:"publishTime"`
	} `json:"songs"`
	Privileges []struct {
		ID                 int         `json:"id"`
		Fee                int         `json:"fee"`
		Payed              int         `json:"payed"`
		St                 int         `json:"st"`
		Pl                 int         `json:"pl"`
		Dl                 int         `json:"dl"`
		Sp                 int         `json:"sp"`
		Cp                 int         `json:"cp"`
		Subp               int         `json:"subp"`
		Cs                 bool        `json:"cs"`
		Maxbr              int         `json:"maxbr"`
		Fl                 int         `json:"fl"`
		Toast              bool        `json:"toast"`
		Flag               int         `json:"flag"`
		PreSell            bool        `json:"preSell"`
		PlayMaxbr          int         `json:"playMaxbr"`
		DownloadMaxbr      int         `json:"downloadMaxbr"`
		MaxBrLevel         string      `json:"maxBrLevel"`
		PlayMaxBrLevel     string      `json:"playMaxBrLevel"`
		DownloadMaxBrLevel string      `json:"downloadMaxBrLevel"`
		PlLevel            string      `json:"plLevel"`
		DlLevel            string      `json:"dlLevel"`
		FlLevel            string      `json:"flLevel"`
		Rscl               interface{} `json:"rscl"`
		FreeTrialPrivilege struct {
			ResConsumable      bool        `json:"resConsumable"`
			UserConsumable     bool        `json:"userConsumable"`
			ListenType         interface{} `json:"listenType"`
			CannotListenReason interface{} `json:"cannotListenReason"`
			PlayReason         interface{} `json:"playReason"`
		} `json:"freeTrialPrivilege"`
		RightSource    int `json:"rightSource"`
		ChargeInfoList []struct {
			Rate          int         `json:"rate"`
			ChargeURL     interface{} `json:"chargeUrl"`
			ChargeMessage interface{} `json:"chargeMessage"`
			ChargeType    int         `json:"chargeType"`
		} `json:"chargeInfoList"`
	} `json:"privileges"`
	Code int `json:"code"`
}

type MusicIDName

type MusicIDName struct {
	ID   string
	Name string
}

type MusicInfo

type MusicInfo struct {
	ID   string
	URL  string
	Name string
}

MusicInfo 网易云音乐信息

type NetEaseContext

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

NetEaseContext 网易云API调用封装

func (*NetEaseContext) AsyncGetSearchRes

func (neteaseCtx *NetEaseContext) AsyncGetSearchRes(ctx context.Context, searchRes SearchMusic) (result []*SearchMusicItem, err error)

func (*NetEaseContext) CheckIfLogin

func (neteaseCtx *NetEaseContext) CheckIfLogin(ctx context.Context) bool

CheckIfLogin 检查是否登陆

@receiver ctx
@return bool

func (*NetEaseContext) GetAlbumDetail

func (neteaseCtx *NetEaseContext) GetAlbumDetail(ctx context.Context, albumID string) (result *AlbumDetail, err error)

GetAlbumDetail 通过关键字搜索歌曲

@receiver neteaseCtx *NetEaseContext
@param ctx context.Context
@param albumID
@return result []*Album
@return err error

func (*NetEaseContext) GetComment

func (neteaseCtx *NetEaseContext) GetComment(ctx context.Context, commentType CommentType, id string) (res *CommentResult, err error)

func (*NetEaseContext) GetDailyRecommendID

func (neteaseCtx *NetEaseContext) GetDailyRecommendID() (musicIDs map[string]string, err error)

GetDailyRecommendID 获取当前账号日推

@receiver ctx
@return musicIDs
@return err

func (*NetEaseContext) GetDetail

func (neteaseCtx *NetEaseContext) GetDetail(ctx context.Context, musicID string) (musicDetail *MusicDetail)

func (*NetEaseContext) GetLyrics

func (neteaseCtx *NetEaseContext) GetLyrics(ctx context.Context, songID string) (lyrics string, lyricsURL string)

func (*NetEaseContext) GetMusicURL

func (neteaseCtx *NetEaseContext) GetMusicURL(ctx context.Context, ID string) (url string, err error)

func (*NetEaseContext) GetMusicURLByID

func (neteaseCtx *NetEaseContext) GetMusicURLByID(ctx context.Context, musicIDName []*MusicIDName) (InfoList []MusicInfo, err error)

GetMusicURLByID 依据ID获取URL/Name //TODO: replace this method more generic

@receiver ctx
@param IDName
@return InfoList
@return err

func (*NetEaseContext) GetMusicURLByIDs

func (neteaseCtx *NetEaseContext) GetMusicURLByIDs(ctx context.Context, musicIDs []string) (musicIDURL map[string]string, err error)

GetMusicURLByIDs 依据ID获取URL/Name

@receiver ctx
@param IDName
@return InfoList
@return err

func (*NetEaseContext) GetNewRecommendMusic

func (neteaseCtx *NetEaseContext) GetNewRecommendMusic() (res []SearchMusicItem, err error)

GetNewRecommendMusic 获得新的推荐歌曲

@receiver ctx
@return res
@return err

func (*NetEaseContext) GetQRBase64

func (neteaseCtx *NetEaseContext) GetQRBase64(ctx context.Context) (err error)

func (*NetEaseContext) GetUniKey

func (neteaseCtx *NetEaseContext) GetUniKey(ctx context.Context) (err error)

func (*NetEaseContext) InnerAsyncGetSearchRes

func (neteaseCtx *NetEaseContext) InnerAsyncGetSearchRes(ctx context.Context, searchMusic SearchMusic, err error, urlChan chan *SearchMusicItem)

func (*NetEaseContext) LoginNetEase

func (neteaseCtx *NetEaseContext) LoginNetEase(ctx context.Context) (err error)

LoginNetEase 获取登陆Cookie

@receiver ctx
@return err

func (*NetEaseContext) LoginNetEaseQR

func (neteaseCtx *NetEaseContext) LoginNetEaseQR(ctx context.Context) (err error)

LoginNetEaseQR 通过二维码获取登陆Cookie

@receiver ctx
@return err

func (*NetEaseContext) RefreshLogin

func (neteaseCtx *NetEaseContext) RefreshLogin(ctx context.Context) error

RefreshLogin 刷新登录

@receiver ctx
@return error

func (*NetEaseContext) SaveCookie

func (neteaseCtx *NetEaseContext) SaveCookie(ctx context.Context)

SaveCookie 保存Cookie

@receiver ctx

func (*NetEaseContext) SearchAlbumByKeyWord

func (neteaseCtx *NetEaseContext) SearchAlbumByKeyWord(ctx context.Context, keywords ...string) (result []*Album, err error)

SearchAlbumByKeyWord 通过关键字搜索歌曲

@receiver neteaseCtx *NetEaseContext
@param ctx context.Context
@param keywords ...string
@return result []*Album
@return err error
@author heyuhengmatt
@update 2024-08-07 08:46:58

func (*NetEaseContext) SearchMusicByKeyWord

func (neteaseCtx *NetEaseContext) SearchMusicByKeyWord(ctx context.Context, keywords ...string) (result []*SearchMusicItem, err error)

SearchMusicByKeyWord 通过关键字搜索歌曲

@receiver neteaseCtx
@param ctx
@param keywords
@return result
@return err

func (*NetEaseContext) SearchPlaylistByKeyWord

func (neteaseCtx *NetEaseContext) SearchPlaylistByKeyWord(ctx context.Context, keywords ...string)

func (*NetEaseContext) TryGetLastCookie

func (neteaseCtx *NetEaseContext) TryGetLastCookie(ctx context.Context)

TryGetLastCookie 获取初始化Cookie

@receiver ctx

type Playlist

type Playlist struct {
	Result struct {
		SearchQcReminder interface{} `json:"searchQcReminder"`
		Playlists        []struct {
			ID          int64  `json:"id"`
			Name        string `json:"name"`
			CoverImgURL string `json:"coverImgUrl"`
			Creator     struct {
				Nickname   string      `json:"nickname"`
				UserID     int         `json:"userId"`
				UserType   int         `json:"userType"`
				AvatarURL  interface{} `json:"avatarUrl"`
				AuthStatus int         `json:"authStatus"`
				ExpertTags interface{} `json:"expertTags"`
				Experts    interface{} `json:"experts"`
			} `json:"creator"`
			Subscribed    bool        `json:"subscribed"`
			TrackCount    int         `json:"trackCount"`
			UserID        int         `json:"userId"`
			PlayCount     int         `json:"playCount"`
			BookCount     int         `json:"bookCount"`
			SpecialType   int         `json:"specialType"`
			OfficialTags  interface{} `json:"officialTags"`
			Action        interface{} `json:"action"`
			ActionType    interface{} `json:"actionType"`
			RecommendText interface{} `json:"recommendText"`
			Score         interface{} `json:"score"`
			Description   string      `json:"description"`
			HighQuality   bool        `json:"highQuality"`
		} `json:"playlists"`
		PlaylistCount int `json:"playlistCount"`
	} `json:"result"`
	Code int `json:"code"`
}

type SearchLyrics

type SearchLyrics struct {
	Sgc       bool `json:"sgc"`
	Sfy       bool `json:"sfy"`
	Qfy       bool `json:"qfy"`
	TransUser struct {
		ID       int    `json:"id"`
		Status   int    `json:"status"`
		Demand   int    `json:"demand"`
		Userid   int    `json:"userid"`
		Nickname string `json:"nickname"`
		Uptime   int64  `json:"uptime"`
	} `json:"transUser"`
	LyricUser struct {
		ID       int    `json:"id"`
		Status   int    `json:"status"`
		Demand   int    `json:"demand"`
		Userid   int    `json:"userid"`
		Nickname string `json:"nickname"`
		Uptime   int64  `json:"uptime"`
	} `json:"lyricUser"`
	Lrc struct {
		Version int    `json:"version"`
		Lyric   string `json:"lyric"`
	} `json:"lrc"`
	Klyric struct {
		Version int    `json:"version"`
		Lyric   string `json:"lyric"`
	} `json:"klyric"`
	Tlyric struct {
		Version int    `json:"version"`
		Lyric   string `json:"lyric"`
	} `json:"tlyric"`
	Romalrc struct {
		Version int    `json:"version"`
		Lyric   string `json:"lyric"`
	} `json:"romalrc"`
	Code int `json:"code"`
}

type SearchMusic

type SearchMusic struct {
	Result struct {
		Songs []Song `json:"songs"`
	} `json:"result"`
}

type SearchMusicItem

type SearchMusicItem struct {
	Index      int
	ID         string
	Name       string
	ArtistName string
	SongURL    string
	PicURL     string
	ImageKey   string
}

SearchMusicItem 搜索音乐返回结果

type Song

type Song struct {
	Name string `json:"name"`
	ID   int    `json:"id"`
	Ar   []struct {
		Name string `json:"name"`
	} `json:"ar"`
	Al struct {
		PicURL string `json:"picUrl"`
	} `json:"al"`
}

Jump to

Keyboard shortcuts

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