aqualink 2.9.13 → 2.10.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/README.md +94 -58
- package/build/handlers/autoplay.js +39 -44
- package/build/structures/Aqua.js +483 -493
- package/build/structures/Connection.js +91 -88
- package/build/structures/Filters.js +178 -167
- package/build/structures/Node.js +99 -96
- package/build/structures/Player.js +275 -296
- package/build/structures/Rest.js +265 -146
- package/build/structures/Track.js +51 -126
- package/package.json +17 -2
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { getImageUrl } = require('../handlers/fetchImage')
|
|
3
4
|
|
|
4
5
|
class Track {
|
|
5
6
|
constructor(data = {}, requester, nodes) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
this.identifier = info.identifier || ''
|
|
9
|
-
this.isSeekable = !!info.isSeekable
|
|
10
|
-
this.author = info.author || ''
|
|
11
|
-
this.position = info.position || 0
|
|
12
|
-
this.duration = info.length || 0
|
|
13
|
-
this.isStream = !!info.isStream
|
|
14
|
-
this.title = info.title || ''
|
|
15
|
-
this.uri = info.uri || ''
|
|
16
|
-
this.sourceName = info.sourceName || ''
|
|
17
|
-
this.artworkUrl = info.artworkUrl || ''
|
|
18
|
-
|
|
19
|
-
this.track = encoded
|
|
20
|
-
this.playlist = playlist
|
|
21
|
-
this.requester = requester
|
|
22
|
-
this.nodes = nodes
|
|
23
|
-
|
|
24
|
-
this._infoCache = null
|
|
7
|
+
const info = data.info || {}
|
|
8
|
+
|
|
9
|
+
this.identifier = info.identifier || ''
|
|
10
|
+
this.isSeekable = !!info.isSeekable
|
|
11
|
+
this.author = info.author || ''
|
|
12
|
+
this.position = info.position || 0
|
|
13
|
+
this.duration = info.length || 0
|
|
14
|
+
this.isStream = !!info.isStream
|
|
15
|
+
this.title = info.title || ''
|
|
16
|
+
this.uri = info.uri || ''
|
|
17
|
+
this.sourceName = info.sourceName || ''
|
|
18
|
+
this.artworkUrl = info.artworkUrl || ''
|
|
19
|
+
|
|
20
|
+
this.track = data.encoded || null
|
|
21
|
+
this.playlist = data.playlist || null
|
|
22
|
+
this.requester = requester
|
|
23
|
+
this.nodes = nodes
|
|
24
|
+
|
|
25
|
+
this._infoCache = null
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
get info() {
|
|
@@ -37,140 +38,64 @@ class Track {
|
|
|
37
38
|
uri: this.uri,
|
|
38
39
|
sourceName: this.sourceName,
|
|
39
40
|
artworkUrl: this.artworkUrl
|
|
40
|
-
})
|
|
41
|
+
})
|
|
41
42
|
}
|
|
42
|
-
return this._infoCache
|
|
43
|
+
return this._infoCache
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
get length() {
|
|
46
|
-
return this.duration
|
|
47
|
+
return this.duration
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
get thumbnail() {
|
|
50
|
-
return this.artworkUrl
|
|
51
|
+
return this.artworkUrl
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
resolveThumbnail(url = this.artworkUrl) {
|
|
54
|
-
if (!url) return null
|
|
55
|
-
|
|
55
|
+
if (!url) return null
|
|
56
56
|
try {
|
|
57
|
-
return getImageUrl(url)
|
|
58
|
-
} catch
|
|
59
|
-
|
|
60
|
-
return null;
|
|
57
|
+
return getImageUrl(url)
|
|
58
|
+
} catch {
|
|
59
|
+
return null
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
async resolve(aqua) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
console.warn("No search platform configured for track resolution");
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!this.author || !this.title) {
|
|
72
|
-
console.warn("Cannot resolve track: missing author or title");
|
|
73
|
-
return null;
|
|
64
|
+
if (!aqua?.options?.defaultSearchPlatform || !this.author || !this.title) {
|
|
65
|
+
return null
|
|
74
66
|
}
|
|
75
67
|
|
|
76
68
|
try {
|
|
77
|
-
const query = `${this.author} - ${this.title}`;
|
|
78
|
-
|
|
79
69
|
const result = await aqua.resolve({
|
|
80
|
-
query
|
|
81
|
-
source:
|
|
70
|
+
query: `${this.author} - ${this.title}`,
|
|
71
|
+
source: aqua.options.defaultSearchPlatform,
|
|
82
72
|
requester: this.requester,
|
|
83
73
|
node: this.nodes
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
if (!result?.tracks?.length) {
|
|
87
|
-
console.debug(`No tracks found for query: ${query}`);
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const matchedTrack = this._findBestMatch(result.tracks);
|
|
92
|
-
if (!matchedTrack) {
|
|
93
|
-
console.debug(`No matching track found for: ${query}`);
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
this.identifier = matchedTrack.info.identifier;
|
|
98
|
-
this.track = matchedTrack.track;
|
|
99
|
-
this.playlist = matchedTrack.playlist || null;
|
|
100
|
-
this._infoCache = null;
|
|
101
|
-
|
|
102
|
-
return this;
|
|
103
|
-
} catch (error) {
|
|
104
|
-
if (error.name === 'TimeoutError') {
|
|
105
|
-
console.error(`Timeout resolving track: ${this.title}`);
|
|
106
|
-
} else if (error.name === 'NetworkError') {
|
|
107
|
-
console.error(`Network error resolving track: ${this.title}`);
|
|
108
|
-
} else {
|
|
109
|
-
console.error(`Unexpected error resolving track ${this.title}:`, error.message);
|
|
110
|
-
}
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
74
|
+
})
|
|
114
75
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (info.author?.toLowerCase() === targetAuthor &&
|
|
123
|
-
info.title?.toLowerCase() === targetTitle) {
|
|
124
|
-
|
|
125
|
-
if (!targetDuration || !info.length ||
|
|
126
|
-
Math.abs(info.length - targetDuration) <= 2000) {
|
|
127
|
-
return track;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
for (const track of tracks) {
|
|
133
|
-
const info = track.info;
|
|
134
|
-
if (info.author?.toLowerCase() === targetAuthor) {
|
|
135
|
-
const titleSimilarity = this._calculateSimilarity(
|
|
136
|
-
targetTitle,
|
|
137
|
-
info.title?.toLowerCase() || ''
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
if (titleSimilarity > 0.8) {
|
|
141
|
-
if (!targetDuration || !info.length ||
|
|
142
|
-
Math.abs(info.length - targetDuration) <= 5000) {
|
|
143
|
-
return track;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
76
|
+
const track = result?.tracks?.[0]
|
|
77
|
+
if (!track) return null
|
|
78
|
+
|
|
79
|
+
this.identifier = track.info.identifier
|
|
80
|
+
this.track = track.track
|
|
81
|
+
this.playlist = track.playlist || null
|
|
82
|
+
this._infoCache = null
|
|
151
83
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const words1 = new Set(str1.split(/\s+/));
|
|
157
|
-
const words2 = new Set(str2.split(/\s+/));
|
|
158
|
-
|
|
159
|
-
const intersection = new Set([...words1].filter(x => words2.has(x)));
|
|
160
|
-
const union = new Set([...words1, ...words2]);
|
|
161
|
-
|
|
162
|
-
return intersection.size / union.size;
|
|
84
|
+
return this
|
|
85
|
+
} catch {
|
|
86
|
+
return null
|
|
87
|
+
}
|
|
163
88
|
}
|
|
164
89
|
|
|
165
90
|
isValid() {
|
|
166
|
-
return !!(this.identifier && this.title && (this.track || this.uri))
|
|
91
|
+
return !!(this.identifier && this.title && (this.track || this.uri))
|
|
167
92
|
}
|
|
168
93
|
|
|
169
94
|
dispose() {
|
|
170
|
-
this._infoCache = null
|
|
171
|
-
this.requester = null
|
|
172
|
-
this.nodes = null
|
|
95
|
+
this._infoCache = null
|
|
96
|
+
this.requester = null
|
|
97
|
+
this.nodes = null
|
|
173
98
|
}
|
|
174
99
|
}
|
|
175
100
|
|
|
176
|
-
module.exports = Track
|
|
101
|
+
module.exports = Track
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aqualink",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.1",
|
|
4
4
|
"description": "An Lavalink client, focused in pure performance and features",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -40,14 +40,29 @@
|
|
|
40
40
|
"type": "git",
|
|
41
41
|
"url": "https://github.com/ToddyTheNoobDud/AquaLink"
|
|
42
42
|
},
|
|
43
|
+
"homepage": "https://roddynnn.github.io/",
|
|
43
44
|
"dependencies": {
|
|
44
45
|
"ws": "^8.18.3",
|
|
45
46
|
"tseep": "^1.3.1"
|
|
46
47
|
},
|
|
48
|
+
"contributors": [
|
|
49
|
+
{
|
|
50
|
+
"name": "mushroom0162",
|
|
51
|
+
"url": "https://github.com/ToddyTheNoobDud"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "SoulDevs",
|
|
55
|
+
"url": "https://github.com/SoulDevs"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "bob (asynco)",
|
|
59
|
+
"url": "https://github.com/asynico"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
47
62
|
"maintainers": [
|
|
48
63
|
{
|
|
49
64
|
"name": "mushroom0162",
|
|
50
65
|
"url": "https://github.com/ToddyTheNoobDud"
|
|
51
66
|
}
|
|
52
67
|
]
|
|
53
|
-
}
|
|
68
|
+
}
|