2.3.3 • Published 2 years ago

@s4p/music-api v2.3.3

Weekly downloads
1
License
MIT
Repository
-
Last release
2 years ago

music-api

npm build coverage

how to use

npm install @s4p/music-api

see test folder to learn more

search

function search(
  query: string | ISearchQuery,
  provider?: Provider | Provider[]
): Promise<ISearchItem[]>;

await search("Aragaki Yui");

getSong

function getSong(id: string, provider: Provider, br?: BitRate): Promise<ISong>;

await getSong("A781023E25C4D09EABCB307BE8BD12E8", Provider.kugou);

rank

function rank(
  provider: Provider,
  rankType: RankType,
  limit?: number,
  skip?: number
): Promise<ISearchItem[]>;

await rank(Provider.kugou, RankType.hot);

playlist

function playlist(provider: Provider, id: string): Promise<ISearchItem[]>;

await playlist(Provider.kugou, "235427");

album

function album(provider: Provider, id: string): Promise<ISearchItem[]>;

await album(Provider.kugou, "976931");

Proxy

if you set environment variable MUSIC_API_PROXY, it will let all provider use this proxy string.

MUSIC_API_PROXY="http://your_proxy" npm run test

if you want to control special provider, you can use setRequestOptions

function setRequestOptions(
  options?: { proxy: string },
  providers = [Provider.kugou, Provider.netease]
): void;

// disable all proxy, use system request
setRequestOptions();

// use proxy for all providers
setRequestOptions({ proxy: "http://your_proxy" });

// use proxy only for kugou
setRequestOptions({ proxy: "http://your_proxy" }, [Provider.kugou]);

Adapter

// https://github.com/jsososo/QQMusicApi
const config = {
  provider: "jsososo",
  search: {
    url: "/search",
    qs: { key: "{{keyword}}" },
    // https://jqplay.org/
    result:
      "[.data.list[] |  { id: .songmid, name: .songname, artists: [.singer[] |  { name: .name, id: .mid }] }]",
  },
  // song...
  // url...
  request: {
    baseUrl: "https://api.qq.jsososo.com",
    json: true,
    timeout: 10000,
    headers: {
      "User-Agent":
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
    },
  },
};
const adapter = new Adapter(config);

await adapter.search("泪了 曾沛慈");
await adapter.getSong("000pnwNj24cMHw");
await adapter.getUrl("000pnwNj24cMHw");

TODO

2.3.3

2 years ago

2.3.0

2 years ago

2.3.2

2 years ago

2.3.1

2 years ago

2.2.0

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.17.0

4 years ago

1.15.4-0

4 years ago

1.16.2

4 years ago

1.16.1

4 years ago

1.16.0

4 years ago

1.15.3

4 years ago

1.15.2

4 years ago

1.15.1

5 years ago

1.15.0

5 years ago

1.14.3

5 years ago

1.14.2

5 years ago

1.14.1

5 years ago

1.14.0

5 years ago

1.13.0

5 years ago

1.12.1

5 years ago

1.11.0

5 years ago

1.10.0

5 years ago

1.10.0-7

5 years ago

1.10.0-5

5 years ago

1.10.0-4

5 years ago

1.10.0-3

5 years ago

1.10.0-2

5 years ago

1.10.0-1

5 years ago

1.10.0-0

5 years ago

1.9.0

5 years ago

1.8.1

5 years ago

1.8.0

5 years ago

1.7.2

5 years ago

1.7.1

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.0

5 years ago

1.4.1

5 years ago

1.3.0

5 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago