mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
hotfix
This commit is contained in:
1 parent
8a8925653c
commit
3a72e46775
12 files changed
+77
-33
No files matched your search
@@ -79,6 +79,12 @@ const DisplayMixin = {
|
||||
? `${vid.title} - ${vid.url}`
|
||||
: `[${vid.title}](${vid.url})`;
|
||||
}
|
||||
if (vid.isLive || vid.type === "livestream") {
|
||||
const link = vid.url || "";
|
||||
return code
|
||||
? `${vid.title} (LIVE) - ${link}`
|
||||
: `🔴 [${vid.title}](${link}) — **LIVE**`;
|
||||
}
|
||||
const elapsed = this.getCurrentElapsedDuration();
|
||||
const total = this.getDuration(vid.duration);
|
||||
const link = vid.spotifyUrl || vid.url || "";
|
||||
|
||||
@@ -37,9 +37,7 @@ const PlaybackMixin = {
|
||||
this._lastPlayedTrack = this.queue.getCurrent() ?? songData;
|
||||
this.queue.current = null;
|
||||
this.emit("stopplay");
|
||||
if (!this._is247Enabled()) {
|
||||
this._startInactivityTimer();
|
||||
}
|
||||
this._scheduleRadioReconnect(songData);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -173,6 +171,7 @@ const PlaybackMixin = {
|
||||
this._pausedAt = null;
|
||||
this._queueEndedSent = false;
|
||||
this._consecutiveErrors = 0;
|
||||
this._radioReconnects = 0;
|
||||
|
||||
if (songData.type !== "radio" || !this._radioAnnounced) {
|
||||
this.announceSong(songData);
|
||||
@@ -362,6 +361,31 @@ const PlaybackMixin = {
|
||||
this._skipping = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @private Re-arm the same radio station after its stream drops. Live
|
||||
* streams end on network hiccups, not on purpose — retry twice (3s apart)
|
||||
* before giving the channel back to the inactivity timer. A user-queued
|
||||
* song or an intentional leave during the wait window cancels it.
|
||||
* @this {import('./Player.mjs').Player}
|
||||
* @param {object} track - The radio track object that ended.
|
||||
*/
|
||||
_scheduleRadioReconnect(track) {
|
||||
const maxRetries = 2;
|
||||
if ((this._radioReconnects ?? 0) >= maxRetries || !track?.url) {
|
||||
this._radioReconnects = 0;
|
||||
if (!this._is247Enabled()) this._startInactivityTimer();
|
||||
return;
|
||||
}
|
||||
this._radioReconnects = (this._radioReconnects ?? 0) + 1;
|
||||
logger.player(`[Player] Radio stream ended — reconnecting (${this._radioReconnects}/${maxRetries}) in 3s: ${track.title}`);
|
||||
setTimeout(() => {
|
||||
if (this._destroyed || this.leaving || !this._voiceConn) return;
|
||||
if (this.queue.getCurrent() || !this.queue.isEmpty()) return;
|
||||
this.queue.add(track);
|
||||
this.playNext().catch(e => logger.error("[Player] Radio reconnect playNext error:", e.message));
|
||||
}, 3_000).unref?.();
|
||||
},
|
||||
|
||||
/**
|
||||
* @private Clear the track-end timer.
|
||||
* @this {import('./Player.mjs').Player}
|
||||
|
||||
@@ -148,6 +148,7 @@ const SearchMixin = {
|
||||
videoId: info.identifier ?? "",
|
||||
encoded: track.encoded ?? info.encoded ?? "",
|
||||
sourceName: info.sourceName ?? "unknown",
|
||||
isLive: info.isLive === true,
|
||||
title: Utils.cleanTitle(info.title ?? "Unknown"),
|
||||
url: trackUri,
|
||||
thumbnail: info.artworkUrl ?? null,
|
||||
@@ -292,20 +293,36 @@ const SearchMixin = {
|
||||
}
|
||||
|
||||
if (lcTracks.length === 0) {
|
||||
if (!isUrl && source !== "ytmsearch") {
|
||||
events.emit("message", "No results from primary source, trying YouTube Music...");
|
||||
const fallback = await this._lavalink.search(searchQuery, { source: "ytmsearch" });
|
||||
if (fallback?.tracks?.length > 0) {
|
||||
const video = this._lcTrackToVideo(fallback.tracks[0], trackMeta);
|
||||
if (video) {
|
||||
this.addToQueue(video, top);
|
||||
events.emit("message", "Successfully added [" + video.title + "](" + video.url + ") to the queue.");
|
||||
if (!this.queue.getCurrent()) {
|
||||
this.playNext().catch(e => logger.error("[Player] playNext error:", e.message));
|
||||
if (!isUrl) {
|
||||
const FALLBACKS = [
|
||||
{ source: "ytmsearch", label: "YouTube Music" },
|
||||
{ source: "ytsearch", label: "YouTube" },
|
||||
{ source: "scsearch", label: "SoundCloud" },
|
||||
].filter(f => f.source !== source);
|
||||
|
||||
for (const fb of FALLBACKS) {
|
||||
events.emit("message", "No results yet — trying **" + fb.label + "**...");
|
||||
let fbResult = null;
|
||||
try {
|
||||
fbResult = await this._lavalink.search(searchQuery, { source: fb.source });
|
||||
} catch (_) { fbResult = null; }
|
||||
if (fbResult?.tracks?.length > 0) {
|
||||
const video = this._lcTrackToVideo(fbResult.tracks[0], trackMeta);
|
||||
if (video) {
|
||||
this.addToQueue(video, top);
|
||||
events.emit("message", "Successfully added [" + video.title + "](" + video.url + ") to the queue. *(found on " + fb.label + ")*");
|
||||
if (!this.queue.getCurrent()) {
|
||||
this.playNext().catch(e => logger.error("[Player] playNext error:", e.message));
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const lavasrcHost = /(?:open\.spotify\.com|spotify\.link|music\.apple\.com|tidal\.com|deezer\.com|deezer\.page\.link|music\.youtube\.com\/playlist)/i;
|
||||
try { if (lavasrcHost.test(new URL(query.trim()).hostname)) {
|
||||
events.emit("message", "⚠️ This link needs the **LavaSrc plugin** on the audio node, which isn't available. Try the song/playlist **name** instead — e.g. `%play <name>`.");
|
||||
} } catch (_) {}
|
||||
}
|
||||
events.emit("message", "**No results found for '" + query + "'.**");
|
||||
return;
|
||||
@@ -328,6 +345,9 @@ const SearchMixin = {
|
||||
if (video) {
|
||||
this.addToQueue(video, top);
|
||||
events.emit("message", "Successfully added [" + video.title + "](" + video.url + ") to the queue.");
|
||||
if (playlistQuery) {
|
||||
events.emit("message", "⚠️ Couldn't load the full playlist — added just this video.");
|
||||
}
|
||||
} else {
|
||||
events.emit("message", "**Failed to parse track data.**");
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user