From 0762f41e33be5ac6ef5ddebd6079896747163c41 Mon Sep 17 00:00:00 2001 From: aandrew-me Date: Thu, 13 Nov 2025 20:13:18 +0300 Subject: [PATCH] Playlist folder name handling --- main.js | 11 +++++++++-- src/playlist.js | 28 +++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/main.js b/main.js index 570b5e9..dc37332 100644 --- a/main.js +++ b/main.js @@ -287,11 +287,18 @@ function registerIpcHandlers() { } }); - ipcMain.on("open-folder", async (_event, folderPath) => { + + ipcMain.handle("open-folder", async (_event, folderPath) => { try { await fs.stat(folderPath); - shell.openPath(folderPath); + const result = await shell.openPath(folderPath); + if (result) { + return {success: false, error: result}; + } else { + return {success: true}; + } } catch (error) { + return {success: false, error: error.message}; } }); diff --git a/src/playlist.js b/src/playlist.js index 6a25119..267b6cf 100644 --- a/src/playlist.js +++ b/src/playlist.js @@ -396,8 +396,25 @@ const playlistDownloader = { if (eventData.includes(playlistTxt)) { this.state.playlistName = eventData .split(playlistTxt)[1] - .trim() - .replaceAll("|", "|") + .trim(); + + this.state.playlistName = this.state.playlistName + .replaceAll("|", "|") + .replaceAll(`"`, `"`) + .replaceAll("*", "*") + .replaceAll("/", "⧸") + .replaceAll("\\", "⧹") + .replaceAll(":", ":") + .replaceAll("?", "?"); + + if ( + os.platform() === "win32" && + this.state.playlistName.endsWith(".") + ) { + this.state.playlistName = + this.state.playlistName.slice(0, -1) + "#"; + } + this.ui.playlistNameDisplay.textContent = `${window.i18n.__( "downloadingPlaylist" )} ${this.state.playlistName}`; @@ -569,7 +586,12 @@ const playlistDownloader = { ) ? path.join(this.state.downloadDir, this.state.playlistName) : this.state.downloadDir; - ipcRenderer.send("open-folder", openPath); + + ipcRenderer.invoke("open-folder", openPath).then((result) => { + if (!result.success) { + ipcRenderer.invoke("open-folder", this.state.downloadDir); + } + }); }, toggleDownloadType(type) {