@khang07/zing-mp3-api 1.3.6 → 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +388 -328
- package/dist/cjs/index.cjs +67 -60
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +67 -61
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +6 -6
- package/dist/types/types/response.d.ts +5 -5
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,328 +1,388 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
##
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
```ts
|
|
78
|
-
import { Client } from "@khang07/zing-mp3-api";
|
|
79
|
-
import { Cookies } from "@khang07/zing-mp3-api/utils/cookies";
|
|
80
|
-
|
|
81
|
-
const client = new Client({
|
|
82
|
-
maxLoad:
|
|
83
|
-
maxHighWaterMark: 16 * 1024,
|
|
84
|
-
userAgent:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
|
224
|
-
|
|
|
225
|
-
| `
|
|
226
|
-
| `
|
|
227
|
-
| `
|
|
228
|
-
| `
|
|
229
|
-
| `
|
|
230
|
-
| `
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
```ts
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
1
|
+
# @khang07/zing-mp3-api
|
|
2
|
+
|
|
3
|
+
A TypeScript library for working with Zing MP3 resources from Node.js.
|
|
4
|
+
It can search songs, videos, playlists, and artists; fetch detailed metadata;
|
|
5
|
+
and return readable streams for music and video playback or download.
|
|
6
|
+
|
|
7
|
+
For the source code, releases, and package metadata, visit the
|
|
8
|
+
[GitHub repository](https://github.com/GiaKhang1810/zing-mp3-api) and the
|
|
9
|
+
[npm package](https://www.npmjs.com/package/@khang07/zing-mp3-api).
|
|
10
|
+
Report bugs or request features in the
|
|
11
|
+
[issue tracker](https://github.com/GiaKhang1810/zing-mp3-api/issues).
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## Table of contents
|
|
15
|
+
|
|
16
|
+
- [Requirement](#requirements)
|
|
17
|
+
- [Installation](#installation)
|
|
18
|
+
- [Configuration](#configuration)
|
|
19
|
+
- [Usage](#usage)
|
|
20
|
+
- [API reference](#api-reference)
|
|
21
|
+
- [Public exports](#public-exports)
|
|
22
|
+
- [Error handling](#error-handling)
|
|
23
|
+
- [Troubleshooting & FAQ](#troubleshooting--faq)
|
|
24
|
+
- [Maintainers](#maintainers)
|
|
25
|
+
- [License](#license)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## Requirements
|
|
29
|
+
|
|
30
|
+
This package has no special runtime requirements beyond a modern Node.js
|
|
31
|
+
environment and network access to [Zing MP3](https://zingmp3.vn).
|
|
32
|
+
|
|
33
|
+
Project dependencies:
|
|
34
|
+
|
|
35
|
+
- [axios](https://www.npmjs.com/package/axios)
|
|
36
|
+
- [m3u8stream](https://www.npmjs.com/package/m3u8stream)
|
|
37
|
+
|
|
38
|
+
Development tooling used by the project:
|
|
39
|
+
|
|
40
|
+
- [TypeScript](https://www.npmjs.com/package/typescript)
|
|
41
|
+
- [Rollup](https://www.npmjs.com/package/rollup)
|
|
42
|
+
- [Mocha](https://www.npmjs.com/package/mocha)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
Install the package with npm:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install @khang07/zing-mp3-api
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Build the project from source:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm run build
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Run tests:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm test
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Run live integration tests:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
ZING_MP3_LIVE=1 npm test
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
## Configuration
|
|
73
|
+
|
|
74
|
+
The library works out of the box with the default exported client.
|
|
75
|
+
If you need more control, create a `Client` instance with custom options.
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
import { Client } from "@khang07/zing-mp3-api";
|
|
79
|
+
import { Cookies } from "@khang07/zing-mp3-api/utils/cookies";
|
|
80
|
+
|
|
81
|
+
const client = new Client({
|
|
82
|
+
maxLoad: 1024 * 1024,
|
|
83
|
+
maxHighWaterMark: 16 * 1024,
|
|
84
|
+
userAgent:
|
|
85
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
|
|
86
|
+
"(KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3",
|
|
87
|
+
jar: new Cookies()
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`ClientOptions` fields:
|
|
92
|
+
|
|
93
|
+
- `maxLoad`: request rate limit passed to Axios as `maxRate`
|
|
94
|
+
- `maxHighWaterMark`: stream buffer size used by `musicSync()` and `videoSync()`
|
|
95
|
+
- `userAgent`: custom request user-agent string
|
|
96
|
+
- `jar`: custom cookie jar instance
|
|
97
|
+
|
|
98
|
+
There is no additional post-install configuration required.
|
|
99
|
+
The client automatically fetches and stores cookies before protected requests.
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
## Usage
|
|
103
|
+
|
|
104
|
+
### ESM
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import client, { Client } from "@khang07/zing-mp3-api";
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### CommonJS
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
const zing = require("@khang07/zing-mp3-api");
|
|
114
|
+
|
|
115
|
+
const client = zing.default;
|
|
116
|
+
const { Client } = zing;
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Search for songs
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
import client from "@khang07/zing-mp3-api";
|
|
123
|
+
|
|
124
|
+
const items = await client.searchMusic("Skyfall");
|
|
125
|
+
console.log(items[0]);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Fetch playlist details
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
import client from "@khang07/zing-mp3-api";
|
|
132
|
+
|
|
133
|
+
const playlist = await client.playlist(
|
|
134
|
+
"https://zingmp3.vn/album/example/ZWZB9WAB.html"
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
console.log(playlist.name);
|
|
138
|
+
console.log(playlist.mediaCount);
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Fetch artist details
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import client from "@khang07/zing-mp3-api";
|
|
145
|
+
|
|
146
|
+
const artist = await client.artist("https://zingmp3.vn/Obito");
|
|
147
|
+
|
|
148
|
+
console.log(artist.name);
|
|
149
|
+
console.log(artist.followCount);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Download a music stream
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import { createWriteStream } from "node:fs";
|
|
156
|
+
import client from "@khang07/zing-mp3-api";
|
|
157
|
+
|
|
158
|
+
const items = await client.searchMusic("Example");
|
|
159
|
+
const stream = await client.music(items[0].id);
|
|
160
|
+
|
|
161
|
+
stream.pipe(createWriteStream("music.mp3"));
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Download a video stream
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
import { createWriteStream } from "node:fs";
|
|
168
|
+
import client from "@khang07/zing-mp3-api";
|
|
169
|
+
|
|
170
|
+
const items = await client.searchVideo("Example");
|
|
171
|
+
const stream = await client.video(items[0].id);
|
|
172
|
+
|
|
173
|
+
stream.pipe(createWriteStream("video.ts"));
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Use the immediate stream APIs
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
import { createWriteStream } from "node:fs";
|
|
180
|
+
import client from "@khang07/zing-mp3-api";
|
|
181
|
+
|
|
182
|
+
const stream = client.musicSync("Example ID");
|
|
183
|
+
stream.pipe(createWriteStream("music.mp3"));
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Handle library errors
|
|
187
|
+
|
|
188
|
+
```ts
|
|
189
|
+
import client from "@khang07/zing-mp3-api";
|
|
190
|
+
import { Lapse } from "@khang07/zing-mp3-api/utils/lapse";
|
|
191
|
+
|
|
192
|
+
try {
|
|
193
|
+
await client.playlist("");
|
|
194
|
+
} catch (error) {
|
|
195
|
+
if (error instanceof Lapse) {
|
|
196
|
+
console.error(error.name);
|
|
197
|
+
console.error(error.code);
|
|
198
|
+
console.error(error.status);
|
|
199
|
+
console.error(error.cause);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
## API reference
|
|
206
|
+
|
|
207
|
+
### `new Client(options?)`
|
|
208
|
+
|
|
209
|
+
Creates a new client instance.
|
|
210
|
+
|
|
211
|
+
### `Client.getIDFromURL(url)`
|
|
212
|
+
|
|
213
|
+
Extracts a resource token or alias from a Zing MP3 URL.
|
|
214
|
+
Throws `ERROR_INVALID_URL` when the input is empty or unsupported.
|
|
215
|
+
|
|
216
|
+
### Instance methods
|
|
217
|
+
|
|
218
|
+
| Method | Returns | Description |
|
|
219
|
+
| --- | --- | --- |
|
|
220
|
+
| `video(videoID)` | `Promise<Readable>` | Fetch a video stream from a raw ID, URL string, or `URL` object. |
|
|
221
|
+
| `videoSync(videoID)` | `Readable` | Return a `PassThrough` immediately and pipe the resolved video stream into it. |
|
|
222
|
+
| `music(musicID)` | `Promise<Readable>` | Fetch a music stream from a raw ID, URL string, or `URL` object. |
|
|
223
|
+
| `musicSync(musicID)` | `Readable` | Return a `PassThrough` immediately and pipe the resolved music stream into it. |
|
|
224
|
+
| `playlist(playlistID)` | `Promise<PlayList>` | Fetch playlist details. |
|
|
225
|
+
| `artist(aliasID)` | `Promise<Artist>` | Fetch artist details. |
|
|
226
|
+
| `mediaDetails(mediaID)` | `Promise<Media>` | Fetch song details. |
|
|
227
|
+
| `searchMusic(query)` | `Promise<SearchMedia[]>` | Search songs. |
|
|
228
|
+
| `searchVideo(query)` | `Promise<SearchMedia[]>` | Search videos. |
|
|
229
|
+
| `searchList(query)` | `Promise<SearchPlayList[]>` | Search playlists. |
|
|
230
|
+
| `searchArtist(query)` | `Promise<SearchArtist[]>` | Search artists. |
|
|
231
|
+
|
|
232
|
+
### Method notes
|
|
233
|
+
|
|
234
|
+
- `video()` prefers `720p` and falls back to `360p`
|
|
235
|
+
- `music()` prefers `320` when available and falls back to `128`
|
|
236
|
+
- If the main music endpoint returns a VIP-only response, `music()` retries the
|
|
237
|
+
extra music endpoint before throwing `ERROR_MUSIC_VIP_ONLY`
|
|
238
|
+
- Search methods currently request the first page with `count: 20`
|
|
239
|
+
- `musicSync()` and `videoSync()` forward stream failures to the returned
|
|
240
|
+
`PassThrough` and destroy the source stream when the output is closed
|
|
241
|
+
|
|
242
|
+
### Data types
|
|
243
|
+
|
|
244
|
+
Public type exports from the root entry:
|
|
245
|
+
|
|
246
|
+
- `ClientOptions`
|
|
247
|
+
- `Artist`
|
|
248
|
+
- `Media`
|
|
249
|
+
- `PlayList`
|
|
250
|
+
- `SearchArtist`
|
|
251
|
+
- `SearchMedia`
|
|
252
|
+
- `SearchPlayList`
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
## Public exports
|
|
256
|
+
|
|
257
|
+
### Root export
|
|
258
|
+
|
|
259
|
+
Runtime exports:
|
|
260
|
+
|
|
261
|
+
- `default`: a ready-to-use `Client` instance
|
|
262
|
+
- `Client`: the client class
|
|
263
|
+
|
|
264
|
+
Type exports:
|
|
265
|
+
|
|
266
|
+
- `ClientOptions`
|
|
267
|
+
- `Artist`
|
|
268
|
+
- `Media`
|
|
269
|
+
- `PlayList`
|
|
270
|
+
- `SearchArtist`
|
|
271
|
+
- `SearchMedia`
|
|
272
|
+
- `SearchPlayList`
|
|
273
|
+
|
|
274
|
+
### Public utility subpaths
|
|
275
|
+
|
|
276
|
+
```ts
|
|
277
|
+
import { Cookies } from "@khang07/zing-mp3-api/utils/cookies";
|
|
278
|
+
import { createSignature } from "@khang07/zing-mp3-api/utils/encrypt";
|
|
279
|
+
import { Lapse } from "@khang07/zing-mp3-api/utils/lapse";
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### `Cookies` helper
|
|
283
|
+
|
|
284
|
+
Methods:
|
|
285
|
+
|
|
286
|
+
- `setCookie(setCookie, requestUrl)`
|
|
287
|
+
- `setCookies(setCookies, requestUrl)`
|
|
288
|
+
- `getCookies(requestUrl)`
|
|
289
|
+
- `getCookieHeader(requestUrl)`
|
|
290
|
+
- `applyToHeaders(requestUrl, headers?)`
|
|
291
|
+
- `deleteCookie(domain, path, name)`
|
|
292
|
+
- `cleanup()`
|
|
293
|
+
- `toJSON()`
|
|
294
|
+
- `fromJSON(cookies)`
|
|
295
|
+
|
|
296
|
+
Cookie record shape:
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
interface CookieRecord {
|
|
300
|
+
name: string;
|
|
301
|
+
value: string;
|
|
302
|
+
domain: string;
|
|
303
|
+
path: string;
|
|
304
|
+
expiresAt?: number;
|
|
305
|
+
secure: boolean;
|
|
306
|
+
httpOnly: boolean;
|
|
307
|
+
sameSite?: "Strict" | "Lax" | "None";
|
|
308
|
+
hostOnly: boolean;
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Example:
|
|
313
|
+
|
|
314
|
+
```ts
|
|
315
|
+
import { Cookies } from "@khang07/zing-mp3-api/utils/cookies";
|
|
316
|
+
|
|
317
|
+
const jar = new Cookies();
|
|
318
|
+
jar.setCookie("sid=abc; Path=/; HttpOnly", "https://zingmp3.vn/");
|
|
319
|
+
|
|
320
|
+
console.log(jar.getCookieHeader("https://zingmp3.vn/"));
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
## Error handling
|
|
325
|
+
|
|
326
|
+
The library throws `Lapse`, a custom error type with the following fields:
|
|
327
|
+
|
|
328
|
+
- `name`
|
|
329
|
+
- `message`
|
|
330
|
+
- `code`
|
|
331
|
+
- `status`
|
|
332
|
+
- `cause`
|
|
333
|
+
|
|
334
|
+
Known library error codes:
|
|
335
|
+
|
|
336
|
+
- `ERROR_ARTIST_FETCH`
|
|
337
|
+
- `ERROR_ARTIST_NOT_FOUND`
|
|
338
|
+
- `ERROR_INVALID_ID`
|
|
339
|
+
- `ERROR_INVALID_QUERY`
|
|
340
|
+
- `ERROR_INVALID_URL`
|
|
341
|
+
- `ERROR_MEDIA_FETCH`
|
|
342
|
+
- `ERROR_MEDIA_NOT_FOUND`
|
|
343
|
+
- `ERROR_MUSIC_FETCH`
|
|
344
|
+
- `ERROR_MUSIC_VIP_ONLY`
|
|
345
|
+
- `ERROR_PLAYLIST_FETCH`
|
|
346
|
+
- `ERROR_PLAYLIST_NOT_FOUND`
|
|
347
|
+
- `ERROR_SEARCH_FAILED`
|
|
348
|
+
- `ERROR_SEARCH_FETCH`
|
|
349
|
+
- `ERROR_STREAM_DOWNLOAD`
|
|
350
|
+
- `ERROR_STREAM_URL_NOT_FOUND`
|
|
351
|
+
- `ERROR_VIDEO_FETCH`
|
|
352
|
+
- `ERROR_VIDEO_NOT_FOUND`
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
## Troubleshooting & FAQ
|
|
356
|
+
|
|
357
|
+
### `video()` returns a stream, but saved files do not open as MP4
|
|
358
|
+
|
|
359
|
+
Video playback is fetched from an HLS source via `m3u8stream`. If you write the
|
|
360
|
+
stream directly to disk, save it as a transport-stream style output such as
|
|
361
|
+
`.ts`, or post-process it with your own media pipeline.
|
|
362
|
+
|
|
363
|
+
### Music lookup fails with `ERROR_MUSIC_VIP_ONLY`
|
|
364
|
+
|
|
365
|
+
Some tracks are restricted. The client already retries the fallback music
|
|
366
|
+
endpoint, but a playable URL may still be unavailable.
|
|
367
|
+
|
|
368
|
+
### I want to reuse cookies between sessions
|
|
369
|
+
|
|
370
|
+
Use `jar.toJSON()` to persist cookies and `jar.fromJSON()` to restore them.
|
|
371
|
+
This is useful if you want to avoid starting from an empty cookie jar each time.
|
|
372
|
+
|
|
373
|
+
### Input URLs fail with `ERROR_INVALID_URL`
|
|
374
|
+
|
|
375
|
+
Use either a standard Zing MP3 HTML URL such as
|
|
376
|
+
`https://zingmp3.vn/bai-hat/test/ZWZB9WAB.html` or a root-style artist URL such
|
|
377
|
+
as `https://zingmp3.vn/mono`.
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
## Maintainers
|
|
381
|
+
|
|
382
|
+
- GiaKhang - [GiaKhang1810](https://github.com/GiaKhang1810)
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
## License
|
|
386
|
+
|
|
387
|
+
This project is licensed under the MIT License.
|
|
388
|
+
See the [LICENSE](./LICENSE) file for details.
|