Programmatic Usage

Music Getter is not just a CLI tool; it can also be integrated into your projects as a Node.js library.

Installation

npm install music-getter

Quick Start

import { 
class Meting
Meting
,
const download: DownloadManager
download
} from 'music-getter';
// Create a Meting instance const
const meting: Meting
meting
= new
new Meting(server?: string): Meting
Meting
('netease');
const meting: Meting
meting
.
Meting.format(enable: boolean): Meting
format
(true);
// Search for songs const
const results: any
results
=
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
JSON.parse(text: string, reviver?: (this: any, key: string, value: any) => any): any

Converts a JavaScript Object Notation (JSON) string into an object.

@paramtext A valid JSON string.@paramreviver A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.@throws{SyntaxError} If text is not valid JSON.
parse
(await
const meting: Meting
meting
.
Meting.search(keyword: string, options?: SearchOptions): Promise<string>
search
('Daylight', {
SearchOptions.limit?: number | undefined
limit
: 10 }));
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
(
const results: any
results
);
// Get song details const
const song: any
song
=
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
JSON.parse(text: string, reviver?: (this: any, key: string, value: any) => any): any

Converts a JavaScript Object Notation (JSON) string into an object.

@paramtext A valid JSON string.@paramreviver A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.@throws{SyntaxError} If text is not valid JSON.
parse
(await
const meting: Meting
meting
.
Meting.song(id: string | number): Promise<string>
song
('1372188635'));
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
(
const song: any
song
);
// Download the song
const download: DownloadManager
download
.
DownloadManager.add(url: string | (() => Promise<string>), output: string): void
add
(
const song: any
song
[0].url_id, './output.mp3');
await
const download: DownloadManager
download
.
DownloadManager.startAll(): Promise<void>
startAll
();

Core Modules

Music Getter provides two core modules:

  • Meting class — Music resource acquisition client, supporting search, song/playlist/lyrics/cover retrieval, etc.
  • download instance — Download manager, supporting queued downloads and progress display

For detailed API reference, see:

  • Meting API Docs — Complete constructor, configuration methods, data methods, and type definitions
  • Download API Docs — Complete download management methods and examples

Example: Batch Download a Playlist

import { 
class Meting
Meting
,
const download: DownloadManager
download
} from 'music-getter';
const
const meting: Meting
meting
= new
new Meting(server?: string): Meting
Meting
('netease');
const meting: Meting
meting
.
Meting.format(enable: boolean): Meting
format
(true);
// Get playlist const
const songs: any
songs
=
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
JSON.parse(text: string, reviver?: (this: any, key: string, value: any) => any): any

Converts a JavaScript Object Notation (JSON) string into an object.

@paramtext A valid JSON string.@paramreviver A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.@throws{SyntaxError} If text is not valid JSON.
parse
(await
const meting: Meting
meting
.
Meting.playlist(id: string | number): Promise<string>
playlist
('7697114803'));
// Add download tasks for (const
const song: any
song
of
const songs: any
songs
) {
const download: DownloadManager
download
.
DownloadManager.add(url: string | (() => Promise<string>), output: string): void
add
(
const song: any
song
.url_id, `./downloads/${
const song: any
song
.name}.mp3`);
} // Start downloading
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
(`Starting download of ${
const download: DownloadManager
download
.
DownloadManager.getCount(): number
getCount
()} songs...`);
await
const download: DownloadManager
download
.
DownloadManager.startAll(): Promise<void>
startAll
();

Custom API

If you need to deploy your own Meting API service, please refer to the Custom API Docs.