mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 02:31:45 +00:00
42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
const { dialog } = require("electron");
|
|
|
|
const { setMenuOptions } = require("../../config/plugins");
|
|
const { downloadPlaylist } = require("./back-downloader");
|
|
const { defaultMenuDownloadLabel, getFolder, presets } = require("./utils");
|
|
|
|
let downloadLabel = defaultMenuDownloadLabel;
|
|
|
|
module.exports = (win, options) => {
|
|
return [
|
|
{
|
|
label: downloadLabel,
|
|
click: () => downloadPlaylist(undefined, win, options),
|
|
},
|
|
{
|
|
label: "Choose download folder",
|
|
click: () => {
|
|
let result = dialog.showOpenDialogSync({
|
|
properties: ["openDirectory", "createDirectory"],
|
|
defaultPath: getFolder(options.downloadFolder),
|
|
});
|
|
if (result) {
|
|
options.downloadFolder = result[0];
|
|
setMenuOptions("downloader", options);
|
|
} // else = user pressed cancel
|
|
},
|
|
},
|
|
{
|
|
label: "Presets",
|
|
submenu: Object.keys(presets).map((preset) => ({
|
|
label: preset,
|
|
type: "radio",
|
|
click: () => {
|
|
options.preset = preset;
|
|
setMenuOptions("downloader", options);
|
|
},
|
|
checked: options.preset === preset,
|
|
})),
|
|
},
|
|
];
|
|
};
|