Playlist folder name handling

pull/353/head
aandrew-me 2 weeks ago committed by Andrew
parent 5f9a3845b7
commit 0762f41e33

@ -287,11 +287,18 @@ function registerIpcHandlers() {
} }
}); });
ipcMain.on("open-folder", async (_event, folderPath) => {
ipcMain.handle("open-folder", async (_event, folderPath) => {
try { try {
await fs.stat(folderPath); 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) { } catch (error) {
return {success: false, error: error.message};
} }
}); });

@ -396,8 +396,25 @@ const playlistDownloader = {
if (eventData.includes(playlistTxt)) { if (eventData.includes(playlistTxt)) {
this.state.playlistName = eventData this.state.playlistName = eventData
.split(playlistTxt)[1] .split(playlistTxt)[1]
.trim() .trim();
this.state.playlistName = this.state.playlistName
.replaceAll("|", "") .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.__( this.ui.playlistNameDisplay.textContent = `${window.i18n.__(
"downloadingPlaylist" "downloadingPlaylist"
)} ${this.state.playlistName}`; )} ${this.state.playlistName}`;
@ -569,7 +586,12 @@ const playlistDownloader = {
) )
? path.join(this.state.downloadDir, this.state.playlistName) ? path.join(this.state.downloadDir, this.state.playlistName)
: this.state.downloadDir; : 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) { toggleDownloadType(type) {

Loading…
Cancel
Save