download progress bar on taskbar

+ Get the best possible artwork
This commit is contained in:
Araxeus
2021-05-08 07:11:54 +03:00
parent 2168cbca30
commit a8ac2c3af9
6 changed files with 62 additions and 19 deletions

View File

@ -25,6 +25,7 @@ const observer = new MutationObserver((mutations, observer) => {
});
const reinit = () => {
triggerAction(CHANNEL, ACTIONS.PROGRESS, -1); // closes progress bar
if (!progress) {
console.warn("Cannot update progress");
} else {
@ -38,6 +39,7 @@ const baseUrl = defaultConfig.url;
// contextBridge.exposeInMainWorld("downloader", {
// download: () => {
global.download = () => {
triggerAction(CHANNEL, ACTIONS.PROGRESS, 2); // starts with indefinite progress bar
let metadata;
let videoUrl = getSongMenu()
?.querySelector('ytmusic-menu-navigation-item-renderer.iron-selected[tabindex="0"]')
@ -53,12 +55,15 @@ global.download = () => {
downloadVideoToMP3(
videoUrl,
(feedback) => {
(feedback, ratio = undefined) => {
if (!progress) {
console.warn("Cannot update progress");
} else {
progress.innerHTML = feedback;
}
if (ratio) {
triggerAction(CHANNEL, ACTIONS.PROGRESS, ratio);
}
},
(error) => {
triggerAction(CHANNEL, ACTIONS.ERROR, error);