From f74ebfe6f40e7cf8bd7b52cbbfe123bb6e6ea9a3 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Thu, 15 Jan 2026 11:37:02 -0500 Subject: [PATCH] Use modal video for source switching --- js/app.js | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/js/app.js b/js/app.js index cde193d9..aaed7860 100644 --- a/js/app.js +++ b/js/app.js @@ -400,18 +400,41 @@ class Application { if (!source) { return; } - if (this.currentVideo) { - this.playVideoWithFallback({ - url: this.currentVideo.url, - magnet: this.currentVideo.magnet, - forcedSource: source, - }).catch((error) => { - devLogger.warn( - "[app] Failed to switch playback source:", - error, - ); - }); + const modalVideo = detail?.video || null; + const fallbackVideo = this.currentVideo || null; + const video = { + ...(fallbackVideo || {}), + ...(modalVideo || {}), + }; + + if (!modalVideo && !fallbackVideo) { + devLogger.warn("[app] Playback source switch missing video data."); + return; } + + const magnetAvailable = + typeof video.magnet === "string" && video.magnet.trim(); + + if (source === "torrent" && !magnetAvailable) { + userLogger.warn( + "[app] Unable to switch to torrent playback: missing magnet.", + ); + this.showError( + "Torrent playback is unavailable for this video. No magnet was provided.", + ); + return; + } + + this.playVideoWithFallback({ + url: video.url, + magnet: video.magnet, + forcedSource: source, + }).catch((error) => { + devLogger.warn( + "[app] Failed to switch playback source:", + error, + ); + }); }); } });