ziplayer 0.2.5 → 0.2.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/AI-Guide.md +956 -0
- package/README.md +206 -175
- package/dist/extensions/index.d.ts +1 -1
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +5 -5
- package/dist/extensions/index.js.map +1 -1
- package/dist/plugins/BasePlugin.d.ts +4 -3
- package/dist/plugins/BasePlugin.d.ts.map +1 -1
- package/dist/plugins/BasePlugin.js +4 -1
- package/dist/plugins/BasePlugin.js.map +1 -1
- package/dist/plugins/index.d.ts +10 -1
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +195 -40
- package/dist/plugins/index.js.map +1 -1
- package/dist/structures/Player.d.ts +0 -9
- package/dist/structures/Player.d.ts.map +1 -1
- package/dist/structures/Player.js +45 -91
- package/dist/structures/Player.js.map +1 -1
- package/dist/types/plugin.d.ts +3 -1
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/plugin.js.map +1 -1
- package/package.json +1 -1
- package/src/extensions/index.ts +5 -9
- package/src/plugins/BasePlugin.ts +4 -3
- package/src/plugins/index.ts +226 -47
- package/src/structures/Player.ts +1693 -1743
- package/src/types/plugin.ts +3 -1
- package/tsconfig.json +2 -2
package/dist/plugins/index.js
CHANGED
|
@@ -4,6 +4,73 @@ exports.PluginManager = exports.BasePlugin = void 0;
|
|
|
4
4
|
const timeout_1 = require("../utils/timeout");
|
|
5
5
|
var BasePlugin_1 = require("./BasePlugin");
|
|
6
6
|
Object.defineProperty(exports, "BasePlugin", { enumerable: true, get: function () { return BasePlugin_1.BasePlugin; } });
|
|
7
|
+
function levenshtein(a, b) {
|
|
8
|
+
const matrix = Array.from({ length: a.length + 1 }, () => new Array(b.length + 1).fill(0));
|
|
9
|
+
for (let i = 0; i <= a.length; i++)
|
|
10
|
+
matrix[i][0] = i;
|
|
11
|
+
for (let j = 0; j <= b.length; j++)
|
|
12
|
+
matrix[0][j] = j;
|
|
13
|
+
for (let i = 1; i <= a.length; i++) {
|
|
14
|
+
for (let j = 1; j <= b.length; j++) {
|
|
15
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
16
|
+
matrix[i][j] = Math.min(matrix[i - 1][j] + 1, matrix[i][j - 1] + 1, matrix[i - 1][j - 1] + cost);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return matrix[a.length][b.length];
|
|
20
|
+
}
|
|
21
|
+
function similarity(a, b) {
|
|
22
|
+
if (!a || !b)
|
|
23
|
+
return 0;
|
|
24
|
+
const dist = levenshtein(a, b);
|
|
25
|
+
const maxLen = Math.max(a.length, b.length);
|
|
26
|
+
return 1 - dist / maxLen; // 0 → 1
|
|
27
|
+
}
|
|
28
|
+
function normalize(str) {
|
|
29
|
+
return str
|
|
30
|
+
.toLowerCase()
|
|
31
|
+
.replace(/\(.*?\)|\[.*?\]/g, "") // remove (remix), [lyrics]
|
|
32
|
+
.replace(/[^a-z0-9\s]/g, "")
|
|
33
|
+
.replace(/\s+/g, " ")
|
|
34
|
+
.trim();
|
|
35
|
+
}
|
|
36
|
+
const MUSIC_KEYWORDS = ["official", "mv", "audio", "lyrics", "remix", "cover", "ft", "feat", "prod", "music video"];
|
|
37
|
+
const NON_MUSIC_KEYWORDS = ["reaction", "review", "podcast", "interview", "vlog", "live stream", "news", "tiktok"];
|
|
38
|
+
function detectContentType(title) {
|
|
39
|
+
const t = title.toLowerCase();
|
|
40
|
+
let score = 0;
|
|
41
|
+
for (const k of MUSIC_KEYWORDS) {
|
|
42
|
+
if (t.includes(k))
|
|
43
|
+
score += 2;
|
|
44
|
+
}
|
|
45
|
+
for (const k of NON_MUSIC_KEYWORDS) {
|
|
46
|
+
if (t.includes(k))
|
|
47
|
+
score -= 3;
|
|
48
|
+
}
|
|
49
|
+
return score;
|
|
50
|
+
}
|
|
51
|
+
function tokenOverlap(a, b) {
|
|
52
|
+
const setA = new Set(a.split(" "));
|
|
53
|
+
const setB = new Set(b.split(" "));
|
|
54
|
+
let match = 0;
|
|
55
|
+
for (const word of setA) {
|
|
56
|
+
if (setB.has(word))
|
|
57
|
+
match++;
|
|
58
|
+
}
|
|
59
|
+
return match / Math.max(setA.size, setB.size);
|
|
60
|
+
}
|
|
61
|
+
function scoreTrack(base, candidate) {
|
|
62
|
+
const titleA = normalize(base.title);
|
|
63
|
+
const titleB = normalize(candidate.title);
|
|
64
|
+
let score = 0;
|
|
65
|
+
// ===== FUZZY =====
|
|
66
|
+
const sim = similarity(titleA, titleB); // 0 → 1
|
|
67
|
+
score += sim * 50;
|
|
68
|
+
// ===== TOKEN MATCH =====
|
|
69
|
+
score += tokenOverlap(titleA, titleB) * 30;
|
|
70
|
+
// ===== CONTENT TYPE =====
|
|
71
|
+
score += detectContentType(candidate.title);
|
|
72
|
+
return score;
|
|
73
|
+
}
|
|
7
74
|
// Plugin factory
|
|
8
75
|
class PluginManager {
|
|
9
76
|
constructor(player, manager, options) {
|
|
@@ -11,11 +78,11 @@ class PluginManager {
|
|
|
11
78
|
this.player = player;
|
|
12
79
|
this.manager = manager;
|
|
13
80
|
this.options = options;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
}
|
|
81
|
+
}
|
|
82
|
+
debug(message, ...optionalParams) {
|
|
83
|
+
if (this.manager.debugEnabled) {
|
|
84
|
+
this.manager.emit("debug", `[Plugins] ${message}`, ...optionalParams);
|
|
85
|
+
}
|
|
19
86
|
}
|
|
20
87
|
register(plugin) {
|
|
21
88
|
this.plugins.set(plugin.name, plugin);
|
|
@@ -36,51 +103,139 @@ class PluginManager {
|
|
|
36
103
|
this.plugins.clear();
|
|
37
104
|
}
|
|
38
105
|
async getStream(track) {
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
42
|
-
this.debug(`
|
|
106
|
+
const timeoutMs = this.options.extractorTimeout ?? 50000;
|
|
107
|
+
const primary = this.get(track.source) || this.findPlugin(track.url);
|
|
108
|
+
if (!primary) {
|
|
109
|
+
this.debug(`No plugin found for track: ${track.title}`);
|
|
43
110
|
return null;
|
|
44
111
|
}
|
|
45
|
-
this.debug(`[Player] Getting stream for track: ${track.title}`);
|
|
46
|
-
this.debug(`[Player] Using plugin: ${plugin.name}`);
|
|
47
|
-
this.debug(`[Track] Track Info:`, track);
|
|
48
|
-
const timeoutMs = this.options.extractorTimeout ?? 50000;
|
|
49
112
|
try {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
113
|
+
const controller = new AbortController();
|
|
114
|
+
const result = await (0, timeout_1.withTimeout)(primary.getStream(track, controller.signal), timeoutMs, "Primary timeout");
|
|
115
|
+
if (result?.stream)
|
|
116
|
+
return result;
|
|
117
|
+
throw new Error("Primary failed");
|
|
54
118
|
}
|
|
55
|
-
catch
|
|
56
|
-
this.debug(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
119
|
+
catch {
|
|
120
|
+
this.debug("Primary failed → fallback parallel");
|
|
121
|
+
}
|
|
122
|
+
// ===== FALLBACK PARALLEL =====
|
|
123
|
+
const plugins = this.getAll()
|
|
124
|
+
.filter((p) => p !== primary)
|
|
125
|
+
.map((p) => {
|
|
126
|
+
p.priority ??= 0;
|
|
127
|
+
return p;
|
|
128
|
+
})
|
|
129
|
+
.sort((a, b) => (a.priority ?? 0) - (b.priority ?? 0));
|
|
130
|
+
// group by priority
|
|
131
|
+
const groups = new Map();
|
|
132
|
+
for (const p of plugins) {
|
|
133
|
+
if (!groups.has(p.priority ?? 0))
|
|
134
|
+
groups.set(p.priority ?? 0, []);
|
|
135
|
+
groups.get(p.priority ?? 0).push(p);
|
|
136
|
+
}
|
|
137
|
+
for (const [priority, group] of groups) {
|
|
138
|
+
this.debug(`Running group priority=${priority}`);
|
|
139
|
+
const controller = new AbortController();
|
|
140
|
+
try {
|
|
141
|
+
const promises = group.map((p) => {
|
|
142
|
+
const run = async () => {
|
|
143
|
+
try {
|
|
144
|
+
let result = null;
|
|
145
|
+
if (p.getStream) {
|
|
146
|
+
try {
|
|
147
|
+
result = await (0, timeout_1.withTimeout)(p.getStream(track, controller.signal), timeoutMs, `Timeout ${p.name}`);
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
// getStream thất bại → log rồi thử getFallback
|
|
151
|
+
this.debug(`getStream failed for ${p.name}, trying getFallback`, err);
|
|
152
|
+
}
|
|
153
|
+
if (result?.stream) {
|
|
154
|
+
this.debug(`Success via ${p.name}`);
|
|
155
|
+
controller.abort();
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (p.getFallback) {
|
|
160
|
+
result = await (0, timeout_1.withTimeout)(p.getFallback(track, controller.signal), timeoutMs, `Fallback timeout ${p.name}`);
|
|
161
|
+
if (result?.stream) {
|
|
162
|
+
this.debug(`Fallback via ${p.name}`);
|
|
163
|
+
controller.abort();
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
throw new Error("No stream");
|
|
65
168
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return streamInfo;
|
|
169
|
+
catch (err) {
|
|
170
|
+
if (controller.signal.aborted)
|
|
171
|
+
throw new Error("Aborted");
|
|
172
|
+
this.debug(`Failed ${p.name}`, err);
|
|
173
|
+
throw err;
|
|
72
174
|
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
175
|
+
};
|
|
176
|
+
return run();
|
|
177
|
+
});
|
|
178
|
+
const result = await Promise.any(promises);
|
|
179
|
+
if (result?.stream)
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
this.debug(`Priority group ${priority} failed`);
|
|
184
|
+
controller.abort();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
throw new Error(`All plugins failed for track: ${track.title}`);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Get related tracks for a given track
|
|
191
|
+
* @param {Track} track Track to find related tracks for
|
|
192
|
+
* @returns {Track[]} Related tracks or empty array
|
|
193
|
+
* @example
|
|
194
|
+
* const related = await player.getRelatedTracks(track);
|
|
195
|
+
* console.log(`Found ${related.length} related tracks`);
|
|
196
|
+
*/
|
|
197
|
+
async getRelatedTracks(track) {
|
|
198
|
+
if (!track)
|
|
199
|
+
return [];
|
|
200
|
+
const timeoutMs = this.options.extractorTimeout ?? 15000;
|
|
201
|
+
const limit = 20;
|
|
202
|
+
const allPlugins = this.getAll()
|
|
203
|
+
.filter((p) => typeof p.getRelatedTracks === "function")
|
|
204
|
+
.sort((a, b) => (a.priority ?? 0) - (b.priority ?? 0));
|
|
205
|
+
const history = this.player.queue.previousTracks;
|
|
206
|
+
const results = [];
|
|
207
|
+
// ===== TRY ALL PLUGINS (NOT JUST FIRST SUCCESS) =====
|
|
208
|
+
await Promise.allSettled(allPlugins.map(async (p) => {
|
|
209
|
+
try {
|
|
210
|
+
this.debug(`[RelatedTracks] Querying ${p.name}`);
|
|
211
|
+
const related = await (0, timeout_1.withTimeout)(p.getRelatedTracks(track, { limit, history }), timeoutMs, `Timeout ${p.name}`);
|
|
212
|
+
if (Array.isArray(related)) {
|
|
213
|
+
results.push(...related);
|
|
77
214
|
}
|
|
78
215
|
}
|
|
79
|
-
|
|
80
|
-
|
|
216
|
+
catch (err) {
|
|
217
|
+
this.debug(`[RelatedTracks] ${p.name} failed`, err);
|
|
218
|
+
}
|
|
219
|
+
}));
|
|
220
|
+
if (results.length === 0) {
|
|
221
|
+
this.debug(`[RelatedTracks] No results`);
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
// ===== DEDUPE =====
|
|
225
|
+
const unique = new Map();
|
|
226
|
+
for (const t of results) {
|
|
227
|
+
if (!unique.has(t.url)) {
|
|
228
|
+
unique.set(t.url, t);
|
|
81
229
|
}
|
|
82
230
|
}
|
|
83
|
-
|
|
231
|
+
// ===== SCORE + SORT =====
|
|
232
|
+
const ranked = Array.from(unique.values())
|
|
233
|
+
.map((t) => ({ track: t, score: scoreTrack(track, t) }))
|
|
234
|
+
.sort((a, b) => b.score - a.score)
|
|
235
|
+
.slice(0, limit)
|
|
236
|
+
.map((x) => x.track);
|
|
237
|
+
this.debug(`[RelatedTracks] Final ${ranked.length} tracks`);
|
|
238
|
+
return ranked;
|
|
84
239
|
}
|
|
85
240
|
}
|
|
86
241
|
exports.PluginManager = PluginManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":";;;AACA,8CAA+C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":";;;AACA,8CAA+C;AAS/C,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AAEnB,SAAS,WAAW,CAAC,CAAS,EAAE,CAAS;IACxC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3F,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACrD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAErD,KAAK,IAAI,CAAC,GAAG,C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AAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;aACxC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;aACvD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;aACjC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;aACf,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAEtB,IAAI,CAAC,KAAK,CAAC,yBAAyB,MAAM,CAAC,MAAM,SAAS,CAAC,CAAC;QAC5D,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AA7LD,sCA6LC"}
|
|
@@ -119,15 +119,6 @@ export declare class Player extends EventEmitter {
|
|
|
119
119
|
pluginCount: number;
|
|
120
120
|
ttsFiltered: boolean;
|
|
121
121
|
};
|
|
122
|
-
/**
|
|
123
|
-
* Get related tracks for a given track
|
|
124
|
-
* @param {Track} track Track to find related tracks for
|
|
125
|
-
* @returns {Track[]} Related tracks or empty array
|
|
126
|
-
* @example
|
|
127
|
-
* const related = await player.getRelatedTracks(track);
|
|
128
|
-
* console.log(`Found ${related.length} related tracks`);
|
|
129
|
-
*/
|
|
130
|
-
getRelatedTracks(track: Track): Promise<Track[]>;
|
|
131
122
|
private generateWillNext;
|
|
132
123
|
/**
|
|
133
124
|
* Play a track, search query, search result, or play from queue
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Player.d.ts","sourceRoot":"","sources":["../../src/structures/Player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAKN,eAAe,EACf,WAAW,IAAI,kBAAkB,EAMjC,MAAM,kBAAkB,CAAC;AAE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D;;;;;;OAMG;IACI,eAAe,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI;IAItD;;;;;;;OAOG;IACI,aAAa,IAAI,SAAS,aAAa,EAAE;IAIhD,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,KAAK;IAMb,OAAO,CAAC,mBAAmB;IA2D3B,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAKrC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQnC;;;;;;;OAOG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;;;;;;OAOG;IACH,IAAI,YAAY,IAAI,KAAK,GAAG,IAAI,CAE/B;IAED;;;;;;;OAOG;IACH,IAAI,aAAa,IAAI,KAAK,GAAG,IAAI,CAEhC;IAED;;;;;;;OAOG;IACH,IAAI,cAAc,IAAI,KAAK,EAAE,CAE5B;IAED;;;;;;;OAOG;IACH,IAAI,cAAc,IAAI,KAAK,EAAE,CAE5B;IAED;;;;;;;OAOG;IACH,IAAI,gBAAgB,IAAI,MAAM,EAAE,CAE/B;IAED;;;;;;;OAOG;IACH,IAAI,aAAa,IAAI,KAAK,EAAE,GAAG,IAAI,CAElC;CAGD"}
|
|
@@ -84,7 +84,7 @@ class Player extends events_1.EventEmitter {
|
|
|
84
84
|
createPlayer: false,
|
|
85
85
|
interrupt: true,
|
|
86
86
|
volume: 100,
|
|
87
|
-
Max_Time_TTS:
|
|
87
|
+
Max_Time_TTS: 60_000,
|
|
88
88
|
...(options?.tts || {}),
|
|
89
89
|
},
|
|
90
90
|
};
|
|
@@ -114,19 +114,13 @@ class Player extends events_1.EventEmitter {
|
|
|
114
114
|
* @private
|
|
115
115
|
*/
|
|
116
116
|
destroyCurrentStream() {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
stream.destroy();
|
|
123
|
-
this.debug(`[Player] Destroyed current stream`);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
this.debug(`[Player] Error destroying current stream:`, error);
|
|
117
|
+
if (!this.currentResource)
|
|
118
|
+
return;
|
|
119
|
+
const stream = this.currentResource?.metadata?.stream ?? this.currentResource?.stream;
|
|
120
|
+
if (stream?.destroy) {
|
|
121
|
+
stream.destroy();
|
|
129
122
|
}
|
|
123
|
+
this.currentResource = null;
|
|
130
124
|
}
|
|
131
125
|
//#region Search
|
|
132
126
|
/**
|
|
@@ -275,45 +269,11 @@ class Player extends events_1.EventEmitter {
|
|
|
275
269
|
ttsFiltered: allPlugins.length > plugins.length,
|
|
276
270
|
};
|
|
277
271
|
}
|
|
278
|
-
/**
|
|
279
|
-
* Get related tracks for a given track
|
|
280
|
-
* @param {Track} track Track to find related tracks for
|
|
281
|
-
* @returns {Track[]} Related tracks or empty array
|
|
282
|
-
* @example
|
|
283
|
-
* const related = await player.getRelatedTracks(track);
|
|
284
|
-
* console.log(`Found ${related.length} related tracks`);
|
|
285
|
-
*/
|
|
286
|
-
async getRelatedTracks(track) {
|
|
287
|
-
if (!track)
|
|
288
|
-
return [];
|
|
289
|
-
const preferred = this.pluginManager.findPlugin(track.url) || this.pluginManager.get(track.source);
|
|
290
|
-
const all = this.pluginManager.getAll();
|
|
291
|
-
const candidates = [...(preferred ? [preferred] : []), ...all.filter((p) => p !== preferred)].filter((p) => typeof p.getRelatedTracks === "function");
|
|
292
|
-
for (const p of candidates) {
|
|
293
|
-
try {
|
|
294
|
-
this.debug(`[Player] Trying related from plugin: ${p.name}`);
|
|
295
|
-
const related = await (0, timeout_1.withTimeout)(p.getRelatedTracks(track.url, {
|
|
296
|
-
limit: 10,
|
|
297
|
-
history: this.queue.previousTracks,
|
|
298
|
-
}), this.options.extractorTimeout ?? 15000, `getRelatedTracks timed out for ${p.name}`);
|
|
299
|
-
if (Array.isArray(related) && related.length > 0) {
|
|
300
|
-
return related; // success
|
|
301
|
-
}
|
|
302
|
-
this.debug(`[Player] ${p.name} returned no related tracks`);
|
|
303
|
-
}
|
|
304
|
-
catch (err) {
|
|
305
|
-
this.debug(`[Player] getRelatedTracks error from ${p.name}:`, err);
|
|
306
|
-
return [];
|
|
307
|
-
// try next candidate
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
return [];
|
|
311
|
-
}
|
|
312
272
|
async generateWillNext() {
|
|
313
273
|
const lastTrack = this.queue.previousTracks[this.queue.previousTracks.length - 1] ?? this.queue.currentTrack;
|
|
314
274
|
if (!lastTrack)
|
|
315
275
|
return;
|
|
316
|
-
const related = await this.getRelatedTracks(lastTrack);
|
|
276
|
+
const related = await this.pluginManager.getRelatedTracks(lastTrack);
|
|
317
277
|
if (!related || related.length === 0)
|
|
318
278
|
return;
|
|
319
279
|
const randomchoice = Math.floor(Math.random() * related.length);
|
|
@@ -542,16 +502,6 @@ class Player extends events_1.EventEmitter {
|
|
|
542
502
|
try {
|
|
543
503
|
// Destroy the old stream and resource before creating a new one
|
|
544
504
|
this.destroyCurrentStream();
|
|
545
|
-
if (this.currentResource) {
|
|
546
|
-
try {
|
|
547
|
-
const oldStream = this.currentResource._readableState?.stream || this.currentResource.stream;
|
|
548
|
-
if (oldStream && typeof oldStream.destroy === "function") {
|
|
549
|
-
oldStream.destroy();
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
catch { }
|
|
553
|
-
this.currentResource = null;
|
|
554
|
-
}
|
|
555
505
|
this.currentResource = await this.createResource(streamInfo, track, 0);
|
|
556
506
|
if (this.volumeInterval) {
|
|
557
507
|
clearInterval(this.volumeInterval);
|
|
@@ -560,7 +510,7 @@ class Player extends events_1.EventEmitter {
|
|
|
560
510
|
this.currentResource.volume?.setVolume(this.volume / 100);
|
|
561
511
|
this.debug(`[Player] Playing resource for track: ${track.title}`);
|
|
562
512
|
this.audioPlayer.play(this.currentResource);
|
|
563
|
-
await (0, voice_1.entersState)(this.audioPlayer, voice_1.AudioPlayerStatus.Playing,
|
|
513
|
+
await (0, voice_1.entersState)(this.audioPlayer, voice_1.AudioPlayerStatus.Playing, 5_000);
|
|
564
514
|
return true;
|
|
565
515
|
}
|
|
566
516
|
catch (resourceError) {
|
|
@@ -578,7 +528,7 @@ class Player extends events_1.EventEmitter {
|
|
|
578
528
|
this.currentResource = fallbackResource;
|
|
579
529
|
this.currentResource.volume?.setVolume(this.volume / 100);
|
|
580
530
|
this.audioPlayer.play(this.currentResource);
|
|
581
|
-
await (0, voice_1.entersState)(this.audioPlayer, voice_1.AudioPlayerStatus.Playing,
|
|
531
|
+
await (0, voice_1.entersState)(this.audioPlayer, voice_1.AudioPlayerStatus.Playing, 5_000);
|
|
582
532
|
return true;
|
|
583
533
|
}
|
|
584
534
|
catch (fallbackError) {
|
|
@@ -606,36 +556,37 @@ class Player extends events_1.EventEmitter {
|
|
|
606
556
|
}
|
|
607
557
|
}
|
|
608
558
|
async playNext() {
|
|
609
|
-
this.debug(`[Player] playNext called`);
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
if (
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
559
|
+
this.debug(`[Player] playNext called by ${new Error().stack?.split("\n")[2]?.trim()}`);
|
|
560
|
+
while (true) {
|
|
561
|
+
const track = this.queue.next(this.skipLoop);
|
|
562
|
+
this.skipLoop = false;
|
|
563
|
+
if (!track) {
|
|
564
|
+
if (this.queue.autoPlay()) {
|
|
565
|
+
const willnext = this.queue.willNextTrack();
|
|
566
|
+
if (willnext) {
|
|
567
|
+
this.queue.addMultiple([willnext]);
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
this.debug(`[Player] No next track in queue`);
|
|
572
|
+
this.isPlaying = false;
|
|
573
|
+
this.emit("queueEnd");
|
|
574
|
+
if (this.options.leaveOnEnd) {
|
|
575
|
+
this.scheduleLeave();
|
|
619
576
|
}
|
|
577
|
+
return false;
|
|
620
578
|
}
|
|
621
|
-
this.
|
|
622
|
-
this.
|
|
623
|
-
this.
|
|
624
|
-
|
|
625
|
-
this.
|
|
579
|
+
this.generateWillNext();
|
|
580
|
+
this.clearLeaveTimeout();
|
|
581
|
+
this.debug(`[Player] playNext called for track: ${track.title}`);
|
|
582
|
+
try {
|
|
583
|
+
return await this.startTrack(track);
|
|
584
|
+
}
|
|
585
|
+
catch (err) {
|
|
586
|
+
this.debug(`[Player] playNext error:`, err);
|
|
587
|
+
this.emit("playerError", err, track);
|
|
588
|
+
continue;
|
|
626
589
|
}
|
|
627
|
-
return false;
|
|
628
|
-
}
|
|
629
|
-
this.generateWillNext();
|
|
630
|
-
// A new track is about to play; ensure we don't leave mid-playback
|
|
631
|
-
this.clearLeaveTimeout();
|
|
632
|
-
try {
|
|
633
|
-
return await this.startTrack(track);
|
|
634
|
-
}
|
|
635
|
-
catch (error) {
|
|
636
|
-
this.debug(`[Player] playNext error:`, error);
|
|
637
|
-
this.emit("playerError", error, track);
|
|
638
|
-
return this.playNext();
|
|
639
590
|
}
|
|
640
591
|
}
|
|
641
592
|
//#endregion
|
|
@@ -694,7 +645,7 @@ class Player extends events_1.EventEmitter {
|
|
|
694
645
|
this.emit("ttsStart", { track });
|
|
695
646
|
ttsPlayer.play(resource);
|
|
696
647
|
// Wait until TTS starts then finishes
|
|
697
|
-
await (0, voice_1.entersState)(ttsPlayer, voice_1.AudioPlayerStatus.Playing,
|
|
648
|
+
await (0, voice_1.entersState)(ttsPlayer, voice_1.AudioPlayerStatus.Playing, 5_000).catch(() => null);
|
|
698
649
|
// Derive timeoutMs from resource/track duration when available, with a sensible cap
|
|
699
650
|
const md = resource?.metadata ?? {};
|
|
700
651
|
const declared = typeof md.duration === "number" ? md.duration
|
|
@@ -705,8 +656,8 @@ class Player extends events_1.EventEmitter {
|
|
|
705
656
|
declared
|
|
706
657
|
: declared * 1000
|
|
707
658
|
: undefined;
|
|
708
|
-
const cap = this.options?.tts?.Max_Time_TTS ??
|
|
709
|
-
const idleTimeout = declaredMs ? Math.min(cap, Math.max(
|
|
659
|
+
const cap = this.options?.tts?.Max_Time_TTS ?? 60_000;
|
|
660
|
+
const idleTimeout = declaredMs ? Math.min(cap, Math.max(1_000, declaredMs + 1_500)) : cap;
|
|
710
661
|
await (0, voice_1.entersState)(ttsPlayer, voice_1.AudioPlayerStatus.Idle, idleTimeout).catch(() => null);
|
|
711
662
|
// Swap back and resume if needed
|
|
712
663
|
this.connection.subscribe(this.audioPlayer);
|
|
@@ -754,7 +705,7 @@ class Player extends events_1.EventEmitter {
|
|
|
754
705
|
selfDeaf: this.options.selfDeaf ?? true,
|
|
755
706
|
selfMute: this.options.selfMute ?? false,
|
|
756
707
|
});
|
|
757
|
-
await (0, voice_1.entersState)(connection, voice_1.VoiceConnectionStatus.Ready,
|
|
708
|
+
await (0, voice_1.entersState)(connection, voice_1.VoiceConnectionStatus.Ready, 50_000);
|
|
758
709
|
this.connection = connection;
|
|
759
710
|
connection.on(voice_1.VoiceConnectionStatus.Disconnected, () => {
|
|
760
711
|
this.debug(`[Player] VoiceConnectionStatus.Disconnected`);
|
|
@@ -825,6 +776,8 @@ class Player extends events_1.EventEmitter {
|
|
|
825
776
|
this.debug(`[Player] stop called`);
|
|
826
777
|
this.queue.clear();
|
|
827
778
|
const result = this.audioPlayer.stop();
|
|
779
|
+
this.destroyCurrentStream();
|
|
780
|
+
this.currentResource = null;
|
|
828
781
|
this.isPlaying = false;
|
|
829
782
|
this.isPaused = false;
|
|
830
783
|
this.emit("playerStop");
|
|
@@ -1256,6 +1209,7 @@ class Player extends events_1.EventEmitter {
|
|
|
1256
1209
|
}
|
|
1257
1210
|
// Destroy current stream before stopping audio
|
|
1258
1211
|
this.destroyCurrentStream();
|
|
1212
|
+
this.audioPlayer.removeAllListeners();
|
|
1259
1213
|
this.audioPlayer.stop(true);
|
|
1260
1214
|
if (this.ttsPlayer) {
|
|
1261
1215
|
try {
|