mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 02:31:45 +00:00
Set title/artist metadata in downloader
This commit is contained in:
@ -2,6 +2,7 @@ const { join } = require("path");
|
||||
|
||||
const { dialog } = require("electron");
|
||||
|
||||
const getSongInfo = require("../../providers/song-info");
|
||||
const { injectCSS, listenAction } = require("../utils");
|
||||
const { ACTIONS, CHANNEL } = require("./actions.js");
|
||||
|
||||
@ -16,14 +17,26 @@ const sendError = (win, err) => {
|
||||
dialog.showMessageBox(dialogOpts);
|
||||
};
|
||||
|
||||
let metadata = {};
|
||||
|
||||
function handle(win) {
|
||||
injectCSS(win.webContents, join(__dirname, "style.css"));
|
||||
const registerCallback = getSongInfo(win);
|
||||
registerCallback((info) => {
|
||||
metadata = {
|
||||
...info,
|
||||
image: info.image ? info.image.toDataURL() : undefined,
|
||||
};
|
||||
});
|
||||
|
||||
listenAction(CHANNEL, (event, action, error) => {
|
||||
switch (action) {
|
||||
case ACTIONS.ERROR:
|
||||
sendError(win, error);
|
||||
break;
|
||||
case ACTIONS.METADATA:
|
||||
event.returnValue = JSON.stringify(metadata);
|
||||
break;
|
||||
default:
|
||||
console.log("Unknown action: " + action);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user