netease

package module
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2020 License: MIT Imports: 12 Imported by: 0

README

网易云音乐 API

Go Version GoDoc

一个很简单的 POC package。

使用

直接引入即可 (应该);如果需要手动安装,执行 go get -u github.com/jixunmoe-go/netease

package main

import (
	"fmt"
	"github.com/jixunmoe-go/netease"
)

func main() {
	api := netease.New()
	resp, err := api.Song(37460604)
	if err == nil && resp != nil {
		song := resp.Songs[0]
		fmt.Printf("Song: %s (album: %s), singer: %s\n", song.Name, song.Album.Name, song.Artists[0].Name)
	} else {
		fmt.Printf("Could not fetch song info: %s", err)
	}
}

Go Playground

致谢

本项目参考了以下仓库里的代码与内容:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient interface {
	Request(n *NetEase, result APIResp, method, path string, params interface{}) error
}

type APIResp

type APIResp interface {
	Deserialize(resp string) error
}

type ClientExtension

type ClientExtension interface {
	ExtendRequest(n *NetEase, req *http.Request)
}

type EAPIClientImpl

type EAPIClientImpl struct{}

func (*EAPIClientImpl) ExtendRequest

func (c *EAPIClientImpl) ExtendRequest(n *NetEase, req *http.Request)

func (*EAPIClientImpl) Request

func (c *EAPIClientImpl) Request(n *NetEase, result APIResp, method, path string, params interface{}) error

type LinuxClientImpl

type LinuxClientImpl struct{}

func (*LinuxClientImpl) ExtendRequest

func (c *LinuxClientImpl) ExtendRequest(n *NetEase, req *http.Request)

func (*LinuxClientImpl) Request

func (c *LinuxClientImpl) Request(n *NetEase, result APIResp, method, path string, params interface{}) error

type NetEase

type NetEase struct {
	BaseURL   string
	TunnelURL string
	Cookie    string
	FakeIP    string
	UserAgent string
	Client    APIClient
}

NetEase struct is useful.

func New

func New() NetEase

New creates a new NetEase instance.

func (*NetEase) Album

func (n *NetEase) Album(id uint64) (*types.AlbumResp, error)

func (*NetEase) Artist

func (n *NetEase) Artist(id, limit uint64) (*types.ArtistResp, error)

Artist can get information about a specific artist. limit: the number of "hot" songs to return. a reasonable limit would be 50.

func (*NetEase) Lyric

func (n *NetEase) Lyric(id uint64) (*types.LyricResp, error)

func (*NetEase) Playlist

func (n *NetEase) Playlist(id uint64) (*types.PlayListResp, error)

func (*NetEase) Request

func (n *NetEase) Request(ext ClientExtension, action, path, data string) ([]byte, error)

func (*NetEase) Search

func (n *NetEase) Search(keyword string, category search.Type, offset, limit uint) (*types.SearchResp, error)

Search for a song. keyword: the search phrase category: search category offset: the page to search (starting from 0) limit: the number of items per page

func (*NetEase) SetRandomIP

func (n *NetEase) SetRandomIP()

func (*NetEase) Song

func (n *NetEase) Song(ids ...uint64) (*types.SongResp, error)

func (*NetEase) SongURL

func (n *NetEase) SongURL(bitrate int, ids ...uint64) (*types.SongURLResp, error)

SongURL requests for the MP3 url of a list of song ids. bitrate can be one of the following: 128000, 192000, 320000. Other undocumented bitrate *might* be available (999000 = flac format?).

func (*NetEase) SongURLv1

func (n *NetEase) SongURLv1(level, encodeType string, ids ...uint64) (*types.SongURLResp, error)

SongURL requests for the url of a list of song ids. level: "standard" (128k?), "exhigh" (320k?) encodeType: "aac", "mp3"

func (*NetEase) UseEAPIClient

func (n *NetEase) UseEAPIClient()

func (*NetEase) UseLinuxClient

func (n *NetEase) UseLinuxClient()

func (*NetEase) UseWEAPIClient

func (n *NetEase) UseWEAPIClient()

type WEAPIClientImpl

type WEAPIClientImpl struct{}

func (*WEAPIClientImpl) ExtendRequest

func (c *WEAPIClientImpl) ExtendRequest(n *NetEase, req *http.Request)

func (*WEAPIClientImpl) Request

func (c *WEAPIClientImpl) Request(n *NetEase, result APIResp, method, path string, params interface{}) error

Directories

Path Synopsis
cmd
ip

Jump to

Keyboard shortcuts

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