fix: static: user-menu: convert flac to mp3

This commit is contained in:
coderaiser 2023-01-18 11:11:28 +02:00
parent 09de19b46e
commit fecfa9fa58

View file

@ -1,7 +1,7 @@
'use strict';
const RENAME_FILE = 'Rename file';
const CDN = 'https://cdn.jsdelivr.net/gh/cloudcmd/user-menu@';
const CDN = 'https://cdn.jsdelivr.net/gh/cloudcmd/user-menu@1.1.1';
module.exports = {
'__settings': {
@ -13,29 +13,29 @@ module.exports = {
[`F2 - ${RENAME_FILE}`]: async ({DOM}) => {
await DOM.renameCurrent();
},
'F6 - Copy URL to current file': async ({DOM}) => {
const {copyURLToCurrentFile} = await import(`${CDN}@1.1.0/menu/copy-url-to-current-file.js`);
const {copyURLToCurrentFile} = await import(`${CDN}/menu/copy-url-to-current-file.js`);
await copyURLToCurrentFile({DOM});
},
'R - cd /': async ({CloudCmd}) => {
await CloudCmd.changeDir('/');
},
'Y - Convert YouTube to MP3': async ({CloudCmd, DOM}) => {
const {convertYouTubeToMp3} = await import(`${CDN}@v1.1.0/menu/convert-youtube-to-mp3.js`);
const {convertYouTubeToMp3} = await import(`${CDN}/menu/convert-youtube-to-mp3.js`);
await convertYouTubeToMp3({CloudCmd, DOM});
},
'F - Convert flac to mp3 [ffmpeg]': async ({CloudCmd, DOM}) => {
const {convertFlacToMp3} = await import(`${CDN}@v1.1.0/menu/ffmpeg.js`);
const {convertFlacToMp3} = await import(`${CDN}/menu/ffmpeg.js`);
await convertFlacToMp3({CloudCmd, DOM});
},
'M - Convert mpeg to mp3 [ffmpeg]': async ({CloudCmd, DOM}) => {
const {convertMp4ToMp3} = await import(`${CDN}@v1.1.0/menu/ffmpeg.js`);
const {convertMp4ToMp3} = await import(`${CDN}/menu/ffmpeg.js`);
await convertMp4ToMp3({CloudCmd, DOM});
},
'C - Create User Menu File': async ({DOM, CloudCmd}) => {
const {
Dialog,
@ -45,7 +45,7 @@ module.exports = {
if (currentFile) {
const [cancel] = await Dialog.confirm(`Looks like file '.cloudcmd.menu.js' already exists. Overwrite?`);
if (cancel)
return;
}
@ -69,25 +69,25 @@ module.exports = {
getCurrentByName,
selectFile,
} = DOM;
const {
files,
filesPassive,
panel,
panelPassive,
} = CurrentInfo;
const names = getFilenames(files);
const namesPassive = getFilenames(filesPassive);
const selectedNames = compare(names, namesPassive);
const selectedNamesPassive = compare(namesPassive, names);
selectNames(selectedNames, panel, {
selectFile,
getCurrentByName,
});
selectNames(selectedNamesPassive, panelPassive, {
selectFile,
getCurrentByName,
@ -97,19 +97,19 @@ module.exports = {
async function createDefaultMenu({path, data, DOM, CloudCmd}) {
const {IO} = DOM;
await IO.write(path, data);
await CloudCmd.refresh();
DOM.setCurrentByName('.cloudcmd.menu.js');
await CloudCmd.EditFile.show();
}
async function readDefaultMenu({prefix}) {
const res = await fetch(`${prefix}/api/v1/user-menu/default`);
const data = await res.text();
return data;
}
@ -124,14 +124,14 @@ function selectNames(names, panel, {selectFile, getCurrentByName}) {
module.exports._compare = compare;
function compare(a, b) {
const result = [];
for (const el of a) {
if (b.includes(el))
continue;
result.push(el);
}
return result;
}