aqualink 2.2.0 → 2.3.0

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 CHANGED
@@ -24,38 +24,35 @@ This code is based in riffy, but its an 100% Rewrite made from scratch...
24
24
  - https://github.com/DuncteBot/java-timed-lyrics (RECOMMENDED)
25
25
 
26
26
 
27
- # Tralalero Tralala 2.2.0 Released
27
+ # Tralalero Tralala 2.3.0 Released
28
28
  ---
29
- - Improved the `AQUA` module
30
- - Added Fast path in getRequestNode ( Reduces unnecessary type checks )
31
- - Early return in handleNoMatches ( Avoids unnecessary Spotify requests )
32
- - Rewrite to use manual loops on constructResponse ( faster than Array.prototype.map, makes the playlists and tracks load way faster and less recourses )
33
- - Pre-allocated arrays ( Avoids dynamic resizing )
34
- - Also fixed it sending double requests to lavalink.
35
29
 
30
+ - now is ~21% more lightweight, reduced disk space
36
31
 
37
- - Remade the `Player` module
38
- - More efficient track addition, void Array re-call
39
- - faster event handling with direct states
40
- - Faster autoplay system and more efficient by map()
41
- - Reduced Object Creation
42
- - Rewrite destroy() method
43
- - Also improved Resource Cleanup
44
- - Now emit TrackEnd and queueEnd correctly
45
-
46
- - Rewrite the `autoplay` system
47
- - Added redirect handling
48
- - More efficient regex processing
49
- - Set for unique URLs to avoid duplicate
50
- - Use array chunks for better performance
51
- - About ~30%-40% faster for resolving now.
52
-
53
- - Rewrite the Filter system
54
- - Uses Direct Assigments
55
- - Avoid recreating objects on each update
56
- - Property reuse in updateFilters()
57
- - Uses traditional for loop
32
+ - Improved the `AQUA` module
33
+ - 3x better cleanup system
34
+ - Fixed some memory leaks
35
+ - Improved long process support
36
+ - Faster node caching
58
37
 
38
+ - Remade the `Player` module
39
+ - Added circular buffer for previousTracks (way more memory efficient)
40
+ - Reorganized the event handlings
41
+ - Way better Memory management
42
+
43
+ - Rewrite the `Node` system
44
+ - Fixed an memory leak in connections
45
+ - Improved the overal speed
46
+ - Improved code readbility / modules
47
+ - improved cleanup System
48
+ - Better long runtime
49
+ - Rewrite the Filter system
50
+
51
+ - Improved `Rest` code
52
+ - Fixed lyrics (both search and get)
53
+ - Better chunks system for more performance
54
+
55
+ - Improved `fetchImage` speed and recourses
59
56
 
60
57
  # Docs (Wiki)
61
58
  - https://toddythenoobdud.github.io/aqualink.github.io/
@@ -1,10 +1,11 @@
1
- const http2 = require('http2');
1
+ const https = require('https');
2
2
  const sourceHandlers = new Map([
3
3
  ['spotify', uri => fetchThumbnail(`https://open.spotify.com/oembed?url=${uri}`)],
4
4
  ['youtube', identifier => fetchYouTubeThumbnail(identifier)]
5
5
  ]);
6
6
  const YOUTUBE_URL_TEMPLATE = (quality) => (id) => `https://img.youtube.com/vi/${id}/${quality}.jpg`;
7
7
  const YOUTUBE_QUALITIES = ['maxresdefault', 'hqdefault', 'mqdefault', 'default'].map(YOUTUBE_URL_TEMPLATE);
8
+
8
9
  async function getImageUrl(info) {
9
10
  if (!info?.sourceName || !info?.uri) return null;
10
11
  const handler = sourceHandlers.get(info.sourceName.toLowerCase());
@@ -16,42 +17,34 @@ async function getImageUrl(info) {
16
17
  return null;
17
18
  }
18
19
  }
20
+
19
21
  function fetchThumbnail(url) {
20
22
  return new Promise((resolve, reject) => {
21
- const client = http2.connect(url);
22
-
23
- const req = client.request({ ':path': '/' });
24
-
25
- let data = '';
26
-
27
- req.on('response', (headers, flags) => {
28
- if (headers[':status'] !== 200) {
29
- return reject(`Failed to fetch: ${headers[':status']}`);
23
+ https.get(url, (res) => {
24
+ if (res.statusCode !== 200) {
25
+ res.resume();
26
+ return reject(`Failed to fetch: ${res.statusCode}`);
30
27
  }
31
- });
32
- req.on('data', chunk => {
33
- data += chunk;
34
- });
35
- req.on('end', () => {
36
- try {
37
- const json = JSON.parse(data);
38
- resolve(json.thumbnail_url || null);
39
- } catch (error) {
40
- reject(`JSON parse error: ${error.message}`);
41
- } finally {
42
- client.close();
43
- }
44
- });
45
- req.on('error', (error) => {
28
+ let data = '';
29
+ res.on('data', chunk => data += chunk);
30
+ res.on('end', () => {
31
+ try {
32
+ const json = JSON.parse(data);
33
+ resolve(json.thumbnail_url || null);
34
+ } catch (error) {
35
+ reject(`JSON parse error: ${error.message}`);
36
+ }
37
+ });
38
+ }).on('error', (error) => {
46
39
  reject(`Request error: ${error.message}`);
47
- client.close();
48
40
  });
49
- req.end();
50
41
  });
51
42
  }
43
+
52
44
  async function fetchYouTubeThumbnail(identifier) {
53
45
  const promises = YOUTUBE_QUALITIES.map(urlFunc => fetchThumbnail(urlFunc(identifier)));
54
- const results = await Promise.race(promises);
55
- return results || null;
46
+ const firstResult = await Promise.race(promises);
47
+ return firstResult || null;
56
48
  }
57
- module.exports = { getImageUrl };
49
+
50
+ module.exports = { getImageUrl };