@ziplayer/plugin 0.1.51 → 0.2.1
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/dist/YouTubePlugin.d.ts +4 -0
- package/dist/YouTubePlugin.d.ts.map +1 -1
- package/dist/YouTubePlugin.js +50 -106
- package/dist/YouTubePlugin.js.map +1 -1
- package/dist/index.d.ts +0 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -16
- package/dist/index.js.map +1 -1
- package/dist/utils/sabr-stream-factory.d.ts +27 -8
- package/dist/utils/sabr-stream-factory.d.ts.map +1 -1
- package/dist/utils/sabr-stream-factory.js +164 -27
- package/dist/utils/sabr-stream-factory.js.map +1 -1
- package/dist/utils/stream-converter.d.ts +0 -4
- package/dist/utils/stream-converter.d.ts.map +1 -1
- package/dist/utils/stream-converter.js +0 -35
- package/dist/utils/stream-converter.js.map +1 -1
- package/package.json +46 -45
- package/src/YouTubePlugin.ts +568 -620
- package/src/index.ts +0 -17
- package/src/utils/sabr-stream-factory.ts +282 -96
- package/src/utils/stream-converter.ts +0 -43
- package/tsconfig.json +6 -2
- package/dist/utils/progress-bar.d.ts +0 -8
- package/dist/utils/progress-bar.d.ts.map +0 -1
- package/dist/utils/progress-bar.js +0 -24
- package/dist/utils/progress-bar.js.map +0 -1
- package/src/YTSRPlugin.ts +0 -596
- package/src/types/googlevideo.d.ts +0 -45
|
@@ -3,24 +3,168 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DEFAULT_SABR_OPTIONS = void 0;
|
|
4
4
|
exports.createSabrStream = createSabrStream;
|
|
5
5
|
exports.createOutputStream = createOutputStream;
|
|
6
|
-
exports.
|
|
6
|
+
exports.sanitizeFileName = sanitizeFileName;
|
|
7
|
+
exports.bytesToMB = bytesToMB;
|
|
7
8
|
const fs_1 = require("fs");
|
|
8
9
|
const path_1 = require("path");
|
|
9
10
|
const os_1 = require("os");
|
|
11
|
+
const youtubei_js_1 = require("youtubei.js");
|
|
12
|
+
const sabr_stream_1 = require("googlevideo/sabr-stream");
|
|
13
|
+
const utils_1 = require("googlevideo/utils");
|
|
14
|
+
const bgutils_js_1 = require("bgutils-js");
|
|
15
|
+
const jsdom_1 = require("jsdom");
|
|
16
|
+
const stream_converter_1 = require("./stream-converter");
|
|
10
17
|
/**
|
|
11
|
-
*
|
|
18
|
+
* Generates a web PoToken for YouTube authentication
|
|
19
|
+
* This is required for accessing restricted video content
|
|
12
20
|
*/
|
|
13
|
-
async function
|
|
21
|
+
async function generateWebPoToken(contentBinding) {
|
|
14
22
|
try {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
23
|
+
const requestKey = "O43z0dpjhgX20SCx4KAo";
|
|
24
|
+
if (!contentBinding)
|
|
25
|
+
throw new Error("Could not get visitor data");
|
|
26
|
+
const dom = new jsdom_1.JSDOM();
|
|
27
|
+
Object.assign(globalThis, {
|
|
28
|
+
window: dom.window,
|
|
29
|
+
document: dom.window.document,
|
|
30
|
+
});
|
|
31
|
+
const bgConfig = {
|
|
32
|
+
fetch: (input, init) => fetch(input, init),
|
|
33
|
+
globalObj: globalThis,
|
|
34
|
+
identifier: contentBinding,
|
|
35
|
+
requestKey,
|
|
36
|
+
};
|
|
37
|
+
const bgChallenge = await bgutils_js_1.BG.Challenge.create(bgConfig);
|
|
38
|
+
if (!bgChallenge)
|
|
39
|
+
throw new Error("Could not get challenge");
|
|
40
|
+
const interpreterJavascript = bgChallenge.interpreterJavascript.privateDoNotAccessOrElseSafeScriptWrappedValue;
|
|
41
|
+
if (interpreterJavascript) {
|
|
42
|
+
new Function(interpreterJavascript)();
|
|
43
|
+
}
|
|
44
|
+
else
|
|
45
|
+
throw new Error("Could not load VM");
|
|
46
|
+
const poTokenResult = await bgutils_js_1.BG.PoToken.generate({
|
|
47
|
+
program: bgChallenge.program,
|
|
48
|
+
globalName: bgChallenge.globalName,
|
|
49
|
+
bgConfig,
|
|
50
|
+
});
|
|
51
|
+
const placeholderPoToken = bgutils_js_1.BG.PoToken.generatePlaceholder(contentBinding);
|
|
52
|
+
return {
|
|
53
|
+
visitorData: contentBinding,
|
|
54
|
+
placeholderPoToken,
|
|
55
|
+
poToken: poTokenResult.poToken,
|
|
56
|
+
};
|
|
20
57
|
}
|
|
21
58
|
catch (error) {
|
|
22
|
-
|
|
23
|
-
|
|
59
|
+
console.warn("PoToken generation failed, continuing without it:", error);
|
|
60
|
+
return {
|
|
61
|
+
visitorData: contentBinding,
|
|
62
|
+
placeholderPoToken: "",
|
|
63
|
+
poToken: "",
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Makes a proper player request to YouTube API
|
|
69
|
+
*/
|
|
70
|
+
async function makePlayerRequest(innertube, videoId, reloadPlaybackContext) {
|
|
71
|
+
const watchEndpoint = new youtubei_js_1.YTNodes.NavigationEndpoint({
|
|
72
|
+
watchEndpoint: { videoId },
|
|
73
|
+
});
|
|
74
|
+
const extraArgs = {
|
|
75
|
+
playbackContext: {
|
|
76
|
+
adPlaybackContext: { pyv: true },
|
|
77
|
+
contentPlaybackContext: {
|
|
78
|
+
vis: 0,
|
|
79
|
+
splay: false,
|
|
80
|
+
lactMilliseconds: "-1",
|
|
81
|
+
signatureTimestamp: innertube.session.player?.signature_timestamp,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
contentCheckOk: true,
|
|
85
|
+
racyCheckOk: true,
|
|
86
|
+
};
|
|
87
|
+
if (reloadPlaybackContext) {
|
|
88
|
+
extraArgs.playbackContext.reloadPlaybackContext = reloadPlaybackContext;
|
|
89
|
+
}
|
|
90
|
+
return watchEndpoint.call(innertube.actions, {
|
|
91
|
+
...extraArgs,
|
|
92
|
+
parse: true,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* YouTube VM shim
|
|
97
|
+
* This allows the SABR stream to execute YouTube's custom JavaScript for deciphering signatures and generating tokens
|
|
98
|
+
*/
|
|
99
|
+
youtubei_js_1.Platform.shim.eval = async (data, env) => {
|
|
100
|
+
const properties = [];
|
|
101
|
+
if (env.n)
|
|
102
|
+
properties.push(`n: exportedVars.nFunction("${env.n}")`);
|
|
103
|
+
if (env.sig)
|
|
104
|
+
properties.push(`sig: exportedVars.sigFunction("${env.sig}")`);
|
|
105
|
+
const code = `${data.output}\nreturn { ${properties.join(", ")} }`;
|
|
106
|
+
return new Function(code)();
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Creates a SABR audio stream for YouTube video download
|
|
110
|
+
* This provides better quality and more reliable streaming than standard methods
|
|
111
|
+
*/
|
|
112
|
+
async function createSabrStream(videoId, innertube, options) {
|
|
113
|
+
try {
|
|
114
|
+
// Generate PoToken for authentication
|
|
115
|
+
const webPo = await generateWebPoToken(videoId);
|
|
116
|
+
// Make initial player request
|
|
117
|
+
const player = await makePlayerRequest(innertube, videoId);
|
|
118
|
+
const title = player.video_details?.title || "unknown";
|
|
119
|
+
const serverAbrStreamingUrl = await innertube.session.player?.decipher(player.streaming_data?.server_abr_streaming_url);
|
|
120
|
+
const ustreamerConfig = player.player_config?.media_common_config.media_ustreamer_request_config?.video_playback_ustreamer_config;
|
|
121
|
+
if (!serverAbrStreamingUrl || !ustreamerConfig) {
|
|
122
|
+
throw new Error("Missing SABR streaming config");
|
|
123
|
+
}
|
|
124
|
+
const sabrFormats = player.streaming_data?.adaptive_formats.map((f) => (0, utils_1.buildSabrFormat)(f)) || [];
|
|
125
|
+
const sabr = new sabr_stream_1.SabrStream({
|
|
126
|
+
formats: sabrFormats,
|
|
127
|
+
serverAbrStreamingUrl,
|
|
128
|
+
videoPlaybackUstreamerConfig: ustreamerConfig,
|
|
129
|
+
poToken: webPo.poToken,
|
|
130
|
+
clientInfo: {
|
|
131
|
+
clientName: parseInt(youtubei_js_1.Constants.CLIENT_NAME_IDS[innertube.session.context.client.clientName]),
|
|
132
|
+
clientVersion: innertube.session.context.client.clientVersion,
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
// Handle player response reload events
|
|
136
|
+
sabr.on("reloadPlayerResponse", async (ctx) => {
|
|
137
|
+
try {
|
|
138
|
+
const pr = await makePlayerRequest(innertube, videoId, ctx);
|
|
139
|
+
const url = await innertube.session.player?.decipher(pr.streaming_data?.server_abr_streaming_url);
|
|
140
|
+
const config = pr.player_config?.media_common_config.media_ustreamer_request_config?.video_playback_ustreamer_config;
|
|
141
|
+
if (url && config) {
|
|
142
|
+
sabr.setStreamingURL(url);
|
|
143
|
+
sabr.setUstreamerConfig(config);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
console.error("Failed to reload player response:", error);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
// Start the stream with audio preference
|
|
151
|
+
const { audioStream, selectedFormats } = await sabr.start({
|
|
152
|
+
// audioQuality: options?.audioQuality || "high",
|
|
153
|
+
});
|
|
154
|
+
// Convert Web Stream to Node.js Readable stream
|
|
155
|
+
const nodeStream = (0, stream_converter_1.webStreamToNodeStream)(audioStream);
|
|
156
|
+
return {
|
|
157
|
+
title,
|
|
158
|
+
stream: nodeStream,
|
|
159
|
+
format: {
|
|
160
|
+
mimeType: selectedFormats.audioFormat.mimeType || "audio/webm",
|
|
161
|
+
itag: selectedFormats.audioFormat.itag || 0,
|
|
162
|
+
contentLength: selectedFormats.audioFormat.contentLength || 0,
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
throw new Error(`SABR stream creation failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
24
168
|
}
|
|
25
169
|
}
|
|
26
170
|
/**
|
|
@@ -38,23 +182,16 @@ function createOutputStream(videoTitle, mimeType) {
|
|
|
38
182
|
};
|
|
39
183
|
}
|
|
40
184
|
/**
|
|
41
|
-
*
|
|
185
|
+
* Sanitizes a filename by removing invalid characters
|
|
42
186
|
*/
|
|
43
|
-
function
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
progressBar.increment(chunk.length);
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
close() {
|
|
55
|
-
outputStream.end();
|
|
56
|
-
},
|
|
57
|
-
});
|
|
187
|
+
function sanitizeFileName(name) {
|
|
188
|
+
return name.replace(/[^\w\d]+/g, "_").slice(0, 128);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Converts bytes to megabytes
|
|
192
|
+
*/
|
|
193
|
+
function bytesToMB(bytes) {
|
|
194
|
+
return (bytes / 1024 / 1024).toFixed(2);
|
|
58
195
|
}
|
|
59
196
|
/**
|
|
60
197
|
* Gets file extension from MIME type
|
|
@@ -77,7 +214,7 @@ exports.DEFAULT_SABR_OPTIONS = {
|
|
|
77
214
|
preferWebM: true,
|
|
78
215
|
preferOpus: true,
|
|
79
216
|
videoQuality: "720p",
|
|
80
|
-
audioQuality: "
|
|
217
|
+
audioQuality: "high",
|
|
81
218
|
enabledTrackTypes: "VIDEO_AND_AUDIO",
|
|
82
219
|
};
|
|
83
220
|
//# sourceMappingURL=sabr-stream-factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sabr-stream-factory.js","sourceRoot":"","sources":["../../src/utils/sabr-stream-factory.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"sabr-stream-factory.js","sourceRoot":"","sources":["../../src/utils/sabr-stream-factory.ts"],"names":[],"mappings":";;;AAmJA,4CA4EC;AAKD,gDAYC;AAKD,4CAEC;AAKD,8BAEC;AA9PD,2BAAuC;AACvC,+BAA4B;AAC5B,2BAA4B;AAE5B,6CAA2D;AAG3D,yDAAqD;AACrD,6CAAoD;AAEpD,2CAAgC;AAChC,iCAA8B;AAC9B,yDAA2D;AAwB3D;;;GAGG;AACH,KAAK,UAAU,kBAAkB,CAAC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CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,SAAS,wBAAwB,CAAC,QAAgB;IACjD,MAAM,OAAO,GAA8B;QAC1C,WAAW,EAAE,KAAK;QAClB,YAAY,EAAE,MAAM;QACpB,WAAW,EAAE,KAAK;QAClB,WAAW,EAAE,KAAK;QAClB,YAAY,EAAE,MAAM;QACpB,WAAW,EAAE,KAAK;KAClB,CAAC;IAEF,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC;AACnC,CAAC;AAED;;GAEG;AACU,QAAA,oBAAoB,GAAwB;IACxD,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,MAAM;IACpB,YAAY,EAAE,MAAM;IACpB,iBAAiB,EAAE,iBAAiB;CACpC,CAAC"}
|
|
@@ -3,8 +3,4 @@ import { Readable } from "stream";
|
|
|
3
3
|
* Converts a Web ReadableStream to a Node.js Readable stream
|
|
4
4
|
*/
|
|
5
5
|
export declare function webStreamToNodeStream(webStream: ReadableStream): Readable;
|
|
6
|
-
/**
|
|
7
|
-
* Converts a Web ReadableStream to a Node.js Readable stream with progress tracking
|
|
8
|
-
*/
|
|
9
|
-
export declare function webStreamToNodeStreamWithProgress(webStream: ReadableStream, progressCallback?: (bytesRead: number) => void): Readable;
|
|
10
6
|
//# sourceMappingURL=stream-converter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-converter.d.ts","sourceRoot":"","sources":["../../src/utils/stream-converter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,cAAc,GAAG,QAAQ,CA8BzE
|
|
1
|
+
{"version":3,"file":"stream-converter.d.ts","sourceRoot":"","sources":["../../src/utils/stream-converter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,cAAc,GAAG,QAAQ,CA8BzE"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.webStreamToNodeStream = webStreamToNodeStream;
|
|
4
|
-
exports.webStreamToNodeStreamWithProgress = webStreamToNodeStreamWithProgress;
|
|
5
4
|
const stream_1 = require("stream");
|
|
6
5
|
/**
|
|
7
6
|
* Converts a Web ReadableStream to a Node.js Readable stream
|
|
@@ -34,38 +33,4 @@ function webStreamToNodeStream(webStream) {
|
|
|
34
33
|
pump();
|
|
35
34
|
return nodeStream;
|
|
36
35
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Converts a Web ReadableStream to a Node.js Readable stream with progress tracking
|
|
39
|
-
*/
|
|
40
|
-
function webStreamToNodeStreamWithProgress(webStream, progressCallback) {
|
|
41
|
-
const nodeStream = new stream_1.Readable({
|
|
42
|
-
read() {
|
|
43
|
-
// This will be handled by the Web Stream reader
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
let bytesRead = 0;
|
|
47
|
-
const reader = webStream.getReader();
|
|
48
|
-
const pump = async () => {
|
|
49
|
-
try {
|
|
50
|
-
while (true) {
|
|
51
|
-
const { done, value } = await reader.read();
|
|
52
|
-
if (done) {
|
|
53
|
-
nodeStream.push(null); // End the stream
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
const buffer = Buffer.from(value);
|
|
57
|
-
nodeStream.push(buffer);
|
|
58
|
-
bytesRead += buffer.length;
|
|
59
|
-
if (progressCallback) {
|
|
60
|
-
progressCallback(bytesRead);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
nodeStream.destroy(error);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
pump();
|
|
69
|
-
return nodeStream;
|
|
70
|
-
}
|
|
71
36
|
//# sourceMappingURL=stream-converter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-converter.js","sourceRoot":"","sources":["../../src/utils/stream-converter.ts"],"names":[],"mappings":";;AAKA,sDA8BC;
|
|
1
|
+
{"version":3,"file":"stream-converter.js","sourceRoot":"","sources":["../../src/utils/stream-converter.ts"],"names":[],"mappings":";;AAKA,sDA8BC;AAnCD,mCAAkC;AAElC;;GAEG;AACH,SAAgB,qBAAqB,CAAC,SAAyB;IAC9D,MAAM,UAAU,GAAG,IAAI,iBAAQ,CAAC;QAC/B,IAAI;YACH,gDAAgD;QACjD,CAAC;KACD,CAAC,CAAC;IAEH,sCAAsC;IACtC,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;IAErC,yCAAyC;IACzC,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;QACvB,IAAI,CAAC;YACJ,OAAO,IAAI,EAAE,CAAC;gBACb,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC5C,IAAI,IAAI,EAAE,CAAC;oBACV,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB;oBACxC,MAAM;gBACP,CAAC;gBACD,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YACrC,CAAC;QACF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,UAAU,CAAC,OAAO,CAAC,KAAc,CAAC,CAAC;QACpC,CAAC;IACF,CAAC,CAAC;IAEF,qBAAqB;IACrB,IAAI,EAAE,CAAC;IAEP,OAAO,UAAU,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@ziplayer/plugin",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "A modular Discord voice player with plugin system",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"ZiPlayer",
|
|
7
|
-
"@ziplayer/plugin",
|
|
8
|
-
"discord",
|
|
9
|
-
"music",
|
|
10
|
-
"player",
|
|
11
|
-
"voice"
|
|
12
|
-
],
|
|
13
|
-
"homepage": "https://player.ziji.world",
|
|
14
|
-
"bugs": {
|
|
15
|
-
"url": "https://github.com/ZiProject/ZiPlayer/issues"
|
|
16
|
-
},
|
|
17
|
-
"repository": {
|
|
18
|
-
"type": "git",
|
|
19
|
-
"url": "git+https://github.com/ZiProject/ZiPlayer.git"
|
|
20
|
-
},
|
|
21
|
-
"license": "MIT",
|
|
22
|
-
"author": "Ziji",
|
|
23
|
-
"main": "dist/index.js",
|
|
24
|
-
"types": "dist/index.d.ts",
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "tsc",
|
|
27
|
-
"dev": "tsc --watch",
|
|
28
|
-
"prepare": "npm run build"
|
|
29
|
-
},
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"@zibot/scdl": "^0.0.
|
|
32
|
-
"@zibot/zitts": "^0.0.3",
|
|
33
|
-
"axios": "^1.
|
|
34
|
-
"
|
|
35
|
-
"googlevideo": "^
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"youtubei.js": "^16.0.1",
|
|
39
|
-
"ziplayer": "^0.2.
|
|
40
|
-
},
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"@types/
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@ziplayer/plugin",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "A modular Discord voice player with plugin system",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ZiPlayer",
|
|
7
|
+
"@ziplayer/plugin",
|
|
8
|
+
"discord",
|
|
9
|
+
"music",
|
|
10
|
+
"player",
|
|
11
|
+
"voice"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://player.ziji.world",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/ZiProject/ZiPlayer/issues"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/ZiProject/ZiPlayer.git"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": "Ziji",
|
|
23
|
+
"main": "dist/index.js",
|
|
24
|
+
"types": "dist/index.d.ts",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc",
|
|
27
|
+
"dev": "tsc --watch",
|
|
28
|
+
"prepare": "npm run build"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@zibot/scdl": "^0.0.6",
|
|
32
|
+
"@zibot/zitts": "^0.0.3",
|
|
33
|
+
"axios": "^1.13.2",
|
|
34
|
+
"bgutils-js": "^3.2.0",
|
|
35
|
+
"googlevideo": "^4.0.4",
|
|
36
|
+
"jsdom": "^28.1.0",
|
|
37
|
+
"music-metadata": "^11.9.0",
|
|
38
|
+
"youtubei.js": "^16.0.1",
|
|
39
|
+
"ziplayer": "^0.2.3"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/jsdom": "^27.0.0",
|
|
43
|
+
"@types/node": "^20.0.0",
|
|
44
|
+
"typescript": "^5.0.0"
|
|
45
|
+
}
|
|
46
|
+
}
|