aqualink 2.18.1 → 2.19.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/build/handlers/autoplay.js +148 -121
- package/build/handlers/fetchImage.js +152 -148
- package/build/index.d.ts +1401 -1080
- package/build/index.js +23 -12
- package/build/structures/Aqua.js +1085 -896
- package/build/structures/AqualinkEvents.js +43 -45
- package/build/structures/Connection.js +576 -483
- package/build/structures/Filters.js +351 -244
- package/build/structures/Node.js +666 -548
- package/build/structures/Player.js +1143 -904
- package/build/structures/Plugins.js +10 -11
- package/build/structures/Queue.js +129 -111
- package/build/structures/Rest.js +856 -645
- package/build/structures/Track.js +158 -129
- package/package.json +1 -1
|
@@ -1,129 +1,158 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get info() {
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
this.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
this.
|
|
116
|
-
this.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
1
|
+
const YT_ID_REGEX =
|
|
2
|
+
/(?:[?&]v=|youtu\.be\/|\/embed\/|\/shorts\/)([A-Za-z0-9_-]{11})/
|
|
3
|
+
|
|
4
|
+
const _h = {
|
|
5
|
+
str: (v, d = '') => (typeof v === 'string' ? v : d),
|
|
6
|
+
num: (v, d = 0) => (Number.isFinite(v) ? v : d)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
class Track {
|
|
10
|
+
constructor(data = {}, requester = null, node = null) {
|
|
11
|
+
const info = data.info || {}
|
|
12
|
+
|
|
13
|
+
this.track = data.track || data.encoded || null
|
|
14
|
+
this.identifier = _h.str(info.identifier)
|
|
15
|
+
this.isSeekable = Boolean(info.isSeekable)
|
|
16
|
+
this.author = _h.str(info.author)
|
|
17
|
+
this.position = _h.num(info.position)
|
|
18
|
+
this.duration = _h.num(info.length)
|
|
19
|
+
this.isStream = Boolean(info.isStream)
|
|
20
|
+
this.title = _h.str(info.title)
|
|
21
|
+
this.uri = _h.str(info.uri)
|
|
22
|
+
this.sourceName = _h.str(info.sourceName)
|
|
23
|
+
this.artworkUrl = _h.str(info.artworkUrl)
|
|
24
|
+
this.pluginInfo = info.pluginInfo || data.pluginInfo || {}
|
|
25
|
+
|
|
26
|
+
this.playlist = data.playlist || null
|
|
27
|
+
this.node = node || data.node || null
|
|
28
|
+
this.nodes = data.nodes || null
|
|
29
|
+
this.requester = requester || null
|
|
30
|
+
this._infoCache = null
|
|
31
|
+
this._artworkCache = undefined // undefined = not computed, null = computed but no artwork
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get info() {
|
|
35
|
+
if (this._infoCache) return this._infoCache
|
|
36
|
+
this._infoCache = Object.freeze({
|
|
37
|
+
identifier: this.identifier,
|
|
38
|
+
isSeekable: this.isSeekable,
|
|
39
|
+
position: this.position,
|
|
40
|
+
author: this.author,
|
|
41
|
+
length: this.duration,
|
|
42
|
+
isStream: this.isStream,
|
|
43
|
+
title: this.title,
|
|
44
|
+
uri: this.uri,
|
|
45
|
+
sourceName: this.sourceName,
|
|
46
|
+
artworkUrl: this.artworkUrl || this._computeArtwork()
|
|
47
|
+
})
|
|
48
|
+
return this._infoCache
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
get length() {
|
|
52
|
+
return this.duration
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get thumbnail() {
|
|
56
|
+
if (this.artworkUrl) return this.artworkUrl
|
|
57
|
+
if (this._artworkCache !== undefined) return this._artworkCache
|
|
58
|
+
this._artworkCache = this._computeArtwork()
|
|
59
|
+
return this._artworkCache
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async resolve(aqua, opts = {}) {
|
|
63
|
+
if (typeof this.track === 'string' && this.track) return this
|
|
64
|
+
if (!aqua?.resolve) return null
|
|
65
|
+
|
|
66
|
+
const platform =
|
|
67
|
+
opts.platform || aqua?.options?.defaultSearchPlatform || 'ytsearch'
|
|
68
|
+
const node = opts.node || this.node || this.nodes
|
|
69
|
+
|
|
70
|
+
let query = this.uri
|
|
71
|
+
if (!query) {
|
|
72
|
+
if (this.title) {
|
|
73
|
+
query = this.author
|
|
74
|
+
? `${this.author} - ${this.title}`.trim()
|
|
75
|
+
: this.title.trim()
|
|
76
|
+
} else if (
|
|
77
|
+
this.identifier &&
|
|
78
|
+
this.sourceName?.toLowerCase().includes('youtube')
|
|
79
|
+
) {
|
|
80
|
+
query = this.identifier
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (!query) return null
|
|
84
|
+
|
|
85
|
+
const payload = { query, source: platform, requester: this.requester }
|
|
86
|
+
if (node) payload.node = node
|
|
87
|
+
|
|
88
|
+
let result
|
|
89
|
+
try {
|
|
90
|
+
result = await aqua.resolve(payload)
|
|
91
|
+
} catch {
|
|
92
|
+
return null
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const found = result?.tracks?.[0]
|
|
96
|
+
if (!found) return null
|
|
97
|
+
|
|
98
|
+
const fi = found.info || {}
|
|
99
|
+
|
|
100
|
+
this.track =
|
|
101
|
+
typeof found.track === 'string'
|
|
102
|
+
? found.track
|
|
103
|
+
: found.encoded || this.track
|
|
104
|
+
this.identifier = fi.identifier ?? this.identifier
|
|
105
|
+
this.title = fi.title ?? this.title
|
|
106
|
+
this.author = fi.author ?? this.author
|
|
107
|
+
this.uri = fi.uri ?? this.uri
|
|
108
|
+
this.sourceName = fi.sourceName ?? this.sourceName
|
|
109
|
+
this.artworkUrl = fi.artworkUrl ?? this.artworkUrl
|
|
110
|
+
this.pluginInfo = fi.pluginInfo ?? found.pluginInfo ?? this.pluginInfo
|
|
111
|
+
this.isSeekable = fi.isSeekable ?? this.isSeekable
|
|
112
|
+
this.isStream = fi.isStream ?? this.isStream
|
|
113
|
+
this.position = _h.num(fi.position, this.position)
|
|
114
|
+
this.duration = _h.num(fi.length, this.duration)
|
|
115
|
+
this.playlist = found.playlist ?? this.playlist
|
|
116
|
+
this._infoCache = null
|
|
117
|
+
|
|
118
|
+
return this
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
isValid() {
|
|
122
|
+
return Boolean(
|
|
123
|
+
(typeof this.track === 'string' && this.track) ||
|
|
124
|
+
(typeof this.uri === 'string' && this.uri)
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
dispose() {
|
|
129
|
+
this._infoCache =
|
|
130
|
+
this.requester =
|
|
131
|
+
this.node =
|
|
132
|
+
this.nodes =
|
|
133
|
+
this.playlist =
|
|
134
|
+
this.track =
|
|
135
|
+
null
|
|
136
|
+
this.identifier =
|
|
137
|
+
this.author =
|
|
138
|
+
this.title =
|
|
139
|
+
this.uri =
|
|
140
|
+
this.sourceName =
|
|
141
|
+
this.artworkUrl =
|
|
142
|
+
''
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
_computeArtwork() {
|
|
146
|
+
if (this.artworkUrl) return this.artworkUrl
|
|
147
|
+
if (this._artworkCache !== undefined) return this._artworkCache
|
|
148
|
+
const id = this.identifier || (this.uri && YT_ID_REGEX.exec(this.uri)?.[1])
|
|
149
|
+
if (id && this.sourceName?.includes('youtube')) {
|
|
150
|
+
this._artworkCache = `https://i.ytimg.com/vi/${id}/hqdefault.jpg`
|
|
151
|
+
return this._artworkCache
|
|
152
|
+
}
|
|
153
|
+
this._artworkCache = null
|
|
154
|
+
return null
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
module.exports = Track
|