Merge remote-tracking branch 'upstream/master' into styled-bars-download-chooser

This commit is contained in:
Araxeus
2021-04-01 02:56:11 +03:00
13 changed files with 123 additions and 106 deletions

View File

@ -24,7 +24,10 @@ module.exports = (win, {activityTimoutEnabled, activityTimoutTime}) => {
details: songInfo.title,
state: songInfo.artist,
largeImageKey: "logo",
largeImageText: songInfo.views + " - " + songInfo.likes,
largeImageText: [
songInfo.uploadDate,
songInfo.views.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " views"
].join(' || '),
};
if (songInfo.isPaused) {
@ -50,8 +53,7 @@ module.exports = (win, {activityTimoutEnabled, activityTimoutTime}) => {
});
// Startup the rpc client
rpc
.login({
rpc.login({
clientId,
})
.catch(console.error);

View File

@ -2,15 +2,14 @@ const { existsSync, mkdirSync } = require("fs");
const { join } = require("path");
const { URL } = require("url");
const { ipcMain } = require("electron");
const { dialog, ipcMain } = require("electron");
const is = require("electron-is");
const ytpl = require("ytpl");
const { setOptions } = require("../../config/plugins");
const { sendError } = require("./back");
const { defaultMenuDownloadLabel, getFolder } = require("./utils");
const { setOptions } = require('../../config/plugins')
const { dialog } = require('electron');
let downloadLabel = defaultMenuDownloadLabel;
module.exports = (win, options, refreshMenu) => [
@ -63,16 +62,17 @@ module.exports = (win, options, refreshMenu) => [
},
},
{
label: 'Choose download folder:',
label: "Choose download folder",
click: () => {
let result = dialog.showOpenDialogSync({
properties: ['openDirectory', 'createDirectory'],
let result = dialog.showOpenDialogSync({
properties: ["openDirectory", "createDirectory"],
defaultPath: getFolder(options.downloadFolder),
})
if(result) {
options.downloadFolder = result[0]
setOptions("downloader", options)
} //else = user pressed cancel
}
});
if (result) {
options.downloadFolder = result[0];
setOptions("downloader", options);
} // else = user pressed cancel
},
},
];

View File

@ -120,7 +120,7 @@ const toMP3 = async (
);
const folder = getFolder(options.downloadFolder);
const name = metadata
const name = metadata.title
? `${metadata.artist ? `${metadata.artist} - ` : ""}${metadata.title}`
: videoName;
const filename = filenamify(name + "." + extension, {

View File

@ -1,7 +1,7 @@
const { Notification } = require("electron");
const getSongInfo = require("../../providers/song-info");
const notify = info => {
const notify = (info, options) => {
let notificationImage = "assets/youtube-music.png";
if (info.image) {
@ -14,27 +14,28 @@ const notify = info => {
body: info.artist,
icon: notificationImage,
silent: true,
urgency: options.urgency,
};
// Send the notification
currentNotification = new Notification(notification);
currentNotification.show()
return currentNotification;
};
module.exports = (win) => {
module.exports = (win, options) => {
const registerCallback = getSongInfo(win);
let oldNotification;
win.on("ready-to-show", () => {
// Register the callback for new song information
registerCallback(songInfo => {
// If song is playing send notification
if (!songInfo.isPaused) {
if (!songInfo.isPaused) {
// Close the old notification
oldNotification?.close();
// This fixes a weird bug that would cause the notification to be updated instead of showing
setTimeout(()=>{ oldNotification = notify(songInfo) }, 10);
setTimeout(()=>{ oldNotification = notify(songInfo, options) }, 10);
}
});
});

View File

@ -0,0 +1,13 @@
const {urgencyLevels, setUrgency} = require("./utils");
module.exports = (win, options) => [
{
label: "Notification Priority",
submenu: urgencyLevels.map(level => ({
label: level.name,
type: "radio",
checked: options.urgency === level.value,
click: () => setUrgency(options, level.value)
})),
},
];

View File

@ -0,0 +1,11 @@
const {setOptions} = require("../../config/plugins");
module.exports.urgencyLevels = [
{name: "Low", value: "low"},
{name: "Normal", value: "normal"},
{name: "High", value: "critical"},
];
module.exports.setUrgency = (options, level) => {
options.urgency = level
setOptions("notifications", options)
};

View File

@ -11,7 +11,7 @@ mainMenuTemplate = function (winHook) {
//get template
let template = originTemplate(winHook);
//fix checkbox and roles
fixCheck(template);
fixMenu(template);
//return as normal
return template;
}
@ -52,12 +52,12 @@ function switchMenuVisibility() {
}
//go over each item in menu
function fixCheck(ogTemplate) {
for (let position in ogTemplate) {
let item = ogTemplate[position];
function fixMenu(template) {
for (let index in template) {
let item = template[index];
//apply function on submenu
if (item.submenu != null) {
fixCheck(item.submenu);
fixMenu(item.submenu);
}
//change onClick of checkbox+radio
else if (item.type === 'checkbox' || item.type === 'radio') {
@ -98,7 +98,7 @@ function fixRoles(MenuItem) {
MenuItem.click = () => { win.webContents.setZoomLevel(0); }
break;
default:
console.log(MenuItem.role + ' was not expected');
console.log(`Error fixing MenuRoles: "${MenuItem.role}" was not expected`);
}
delete MenuItem.role;
}

View File

@ -1,3 +1,8 @@
/* increase font size for menu and menuItems */
.titlebar, .menubar-menu-container .action-label{
font-size: 14px !important;
}
/* allow submenu's to show correctly */
.menubar-menu-container{
overflow-y: visible !important;