magmastream 2.10.2-alpha.8 → 2.10.2-dev.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.
@@ -16,6 +16,7 @@ export declare enum AutoPlayPlatform {
16
16
  Tidal = "tidal",
17
17
  VKMusic = "vkmusic",
18
18
  Qobuz = "qobuz",
19
+ Yandex = "yandex",
19
20
  YouTube = "youtube"
20
21
  }
21
22
  /**
@@ -55,6 +56,7 @@ export declare enum LoadTypes {
55
56
  */
56
57
  export declare enum SearchPlatform {
57
58
  AppleMusic = "amsearch",
59
+ Yandex = "ymsearch",
58
60
  Audius = "audsearch",
59
61
  Bandcamp = "bcsearch",
60
62
  Deezer = "dzsearch",
@@ -103,6 +105,7 @@ export declare enum TrackSourceTypes {
103
105
  TikTok = "TikTok",
104
106
  Flowertts = "Flowertts",
105
107
  Ocremix = "Ocremix",
108
+ Yandex = "Yandex",
106
109
  Mixcloud = "Mixcloud",
107
110
  Soundgasm = "Soundgasm",
108
111
  Reddit = "Reddit",
@@ -21,6 +21,7 @@ var AutoPlayPlatform;
21
21
  AutoPlayPlatform["Tidal"] = "tidal";
22
22
  AutoPlayPlatform["VKMusic"] = "vkmusic";
23
23
  AutoPlayPlatform["Qobuz"] = "qobuz";
24
+ AutoPlayPlatform["Yandex"] = "yandex";
24
25
  AutoPlayPlatform["YouTube"] = "youtube";
25
26
  })(AutoPlayPlatform || (exports.AutoPlayPlatform = AutoPlayPlatform = {}));
26
27
  /**
@@ -63,6 +64,7 @@ var LoadTypes;
63
64
  var SearchPlatform;
64
65
  (function (SearchPlatform) {
65
66
  SearchPlatform["AppleMusic"] = "amsearch";
67
+ SearchPlatform["Yandex"] = "ymsearch";
66
68
  SearchPlatform["Audius"] = "audsearch";
67
69
  SearchPlatform["Bandcamp"] = "bcsearch";
68
70
  SearchPlatform["Deezer"] = "dzsearch";
@@ -113,6 +115,7 @@ var TrackSourceTypes;
113
115
  TrackSourceTypes["TikTok"] = "TikTok";
114
116
  TrackSourceTypes["Flowertts"] = "Flowertts";
115
117
  TrackSourceTypes["Ocremix"] = "Ocremix";
118
+ TrackSourceTypes["Yandex"] = "Yandex";
116
119
  TrackSourceTypes["Mixcloud"] = "Mixcloud";
117
120
  TrackSourceTypes["Soundgasm"] = "Soundgasm";
118
121
  TrackSourceTypes["Reddit"] = "Reddit";
@@ -385,16 +385,17 @@ class Player {
385
385
  const finalOptions = playOptions ? playOptions : isPlayOptions(optionsOrTrack) ? optionsOrTrack : {};
386
386
  await this.node.rest.updatePlayer({
387
387
  guildId: this.guildId,
388
+ noReplace: finalOptions.noReplace,
388
389
  data: {
389
390
  track: {
390
391
  encoded: currentTrack.track,
391
392
  },
392
- ...finalOptions,
393
- position: finalOptions.startTime || 0,
393
+ ...(typeof finalOptions.startTime === "number" && { position: finalOptions.startTime }),
394
+ ...(typeof finalOptions.endTime === "number" && finalOptions.endTime > 0 && { endTime: finalOptions.endTime }),
394
395
  },
395
396
  });
396
397
  this.playing = true;
397
- this.position = finalOptions.startTime || 0;
398
+ this.position = finalOptions.startTime ?? 0;
398
399
  return this;
399
400
  }
400
401
  /**
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JSONUtils = exports.Structure = exports.PlayerUtils = exports.AutoPlayUtils = exports.TrackUtils = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  /* eslint-disable @typescript-eslint/no-require-imports */
6
- const axios_1 = tslib_1.__importDefault(require("axios"));
6
+ const axios_1 = require("axios");
7
7
  const jsdom_1 = require("jsdom");
8
8
  const Enums_1 = require("./Enums");
9
9
  const path_1 = tslib_1.__importDefault(require("path"));
@@ -250,7 +250,7 @@ class AutoPlayUtils {
250
250
  if (!title) {
251
251
  // No title provided, search for the artist's top tracks
252
252
  const noTitleUrl = `https://ws.audioscrobbler.com/2.0/?method=artist.getTopTracks&artist=${artist}&autocorrect=1&api_key=${apiKey}&format=json`;
253
- const response = await axios_1.default.get(noTitleUrl);
253
+ const response = await (0, axios_1.get)(noTitleUrl);
254
254
  if (response.data.error || !response.data.toptracks?.track?.length) {
255
255
  return [];
256
256
  }
@@ -263,7 +263,7 @@ class AutoPlayUtils {
263
263
  if (!artist) {
264
264
  // No artist provided, search for the track title
265
265
  const noArtistUrl = `https://ws.audioscrobbler.com/2.0/?method=track.search&track=${title}&api_key=${apiKey}&format=json`;
266
- const response = await axios_1.default.get(noArtistUrl);
266
+ const response = await (0, axios_1.get)(noArtistUrl);
267
267
  artist = response.data.results.trackmatches?.track?.[0]?.artist;
268
268
  if (!artist) {
269
269
  return [];
@@ -274,7 +274,7 @@ class AutoPlayUtils {
274
274
  const url = `https://ws.audioscrobbler.com/2.0/?method=track.getSimilar&artist=${artist}&track=${title}&limit=10&autocorrect=1&api_key=${apiKey}&format=json`;
275
275
  let response;
276
276
  try {
277
- response = await axios_1.default.get(url);
277
+ response = await (0, axios_1.get)(url);
278
278
  }
279
279
  catch (error) {
280
280
  console.error("[AutoPlay] Error fetching similar tracks from Last.fm:", error);
@@ -283,7 +283,7 @@ class AutoPlayUtils {
283
283
  if (response.data.error || !response.data.similartracks?.track?.length) {
284
284
  // Retry the request if the first attempt fails
285
285
  const retryUrl = `https://ws.audioscrobbler.com/2.0/?method=artist.getTopTracks&artist=${artist}&autocorrect=1&api_key=${apiKey}&format=json`;
286
- const retryResponse = await axios_1.default.get(retryUrl);
286
+ const retryResponse = await (0, axios_1.get)(retryUrl);
287
287
  if (retryResponse.data.error || !retryResponse.data.toptracks?.track?.length) {
288
288
  return [];
289
289
  }
@@ -357,7 +357,7 @@ class AutoPlayUtils {
357
357
  track = resolvedTrack;
358
358
  }
359
359
  try {
360
- const recommendedRes = await axios_1.default.get(`${track.uri}/recommended`).catch((err) => {
360
+ const recommendedRes = await (0, axios_1.get)(`${track.uri}/recommended`).catch((err) => {
361
361
  console.error(`[AutoPlay] Failed to fetch SoundCloud recommendations. Status: ${err.response?.status || "Unknown"}`, err.message);
362
362
  return null;
363
363
  });
@@ -465,6 +465,19 @@ class AutoPlayUtils {
465
465
  const tracks = this.buildTracksFromResponse(recommendedResult, requester);
466
466
  return tracks;
467
467
  }
468
+ case Enums_1.AutoPlayPlatform.Yandex: {
469
+ const allowedYandexHosts = ["music.yandex.ru", "yandex.ru", "www.yandex.ru"];
470
+ if (!allowedYandexHosts.includes(parsedURL.host)) {
471
+ const resolvedTrack = await this.resolveFirstTrackFromQuery(`${track.author} - ${track.title}`, Enums_1.SearchPlatform.Yandex, requester);
472
+ if (!resolvedTrack)
473
+ return [];
474
+ track = resolvedTrack;
475
+ }
476
+ const identifier = `ymrec:${track.identifier}`;
477
+ const recommendedResult = (await this.manager.useableNode.rest.get(`/v4/loadtracks?identifier=${encodeURIComponent(identifier)}`));
478
+ const tracks = this.buildTracksFromResponse(recommendedResult, requester);
479
+ return tracks;
480
+ }
468
481
  default:
469
482
  return [];
470
483
  }
@@ -16,7 +16,7 @@ function nodeCheck(options) {
16
16
  });
17
17
  }
18
18
  const { host, identifier, password, port, enableSessionResumeOption, sessionTimeoutSeconds, maxRetryAttempts, retryDelayMs, useSSL, nodePriority } = options;
19
- if (typeof host !== "string" || !/.+/.test(host)) {
19
+ if (!host || typeof host !== "string") {
20
20
  throw new MagmastreamError_1.MagmaStreamError({
21
21
  code: Enums_1.MagmaStreamErrorCode.NODE_INVALID_CONFIG,
22
22
  message: 'Node option "host" must be present and be a non-empty string.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magmastream",
3
- "version": "2.10.2-alpha.8",
3
+ "version": "2.10.2-dev.0",
4
4
  "description": "A user-friendly Lavalink client designed for NodeJS.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",