mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 03:11:46 +00:00
differentiate names of different metadata sources
This commit is contained in:
@ -22,13 +22,13 @@ const sendError = (win, err) => {
|
||||
dialog.showMessageBox(dialogOpts);
|
||||
};
|
||||
|
||||
let metadata = {};
|
||||
let nowPlayingMetadata = {};
|
||||
|
||||
function handle(win) {
|
||||
injectCSS(win.webContents, join(__dirname, "style.css"));
|
||||
const registerCallback = getSongInfo(win);
|
||||
registerCallback((info) => {
|
||||
metadata = info;
|
||||
nowPlayingMetadata = info;
|
||||
});
|
||||
|
||||
listenAction(CHANNEL, (event, action, arg) => {
|
||||
@ -37,7 +37,7 @@ function handle(win) {
|
||||
sendError(win, arg);
|
||||
break;
|
||||
case ACTIONS.METADATA:
|
||||
event.returnValue = JSON.stringify(metadata);
|
||||
event.returnValue = JSON.stringify(nowPlayingMetadata);
|
||||
break;
|
||||
case ACTIONS.PROGRESS: //arg = progress
|
||||
win.setProgressBar(arg);
|
||||
@ -50,13 +50,13 @@ function handle(win) {
|
||||
ipcMain.on("add-metadata", async (event, filePath, songBuffer, currentMetadata) => {
|
||||
let fileBuffer = songBuffer;
|
||||
let songMetadata;
|
||||
if (currentMetadata.imageSrc) { // means metadata come from ytpl.getInfo();
|
||||
if (currentMetadata.imageSrcYTPL) { // means metadata come from ytpl.getInfo();
|
||||
songMetadata = {
|
||||
...currentMetadata,
|
||||
image: cropMaxWidth(await getImage(currentMetadata.imageSrc))
|
||||
image: cropMaxWidth(await getImage(currentMetadata.imageSrcYTPL))
|
||||
};
|
||||
} else {
|
||||
songMetadata = { ...metadata, ...currentMetadata };
|
||||
songMetadata = { ...nowPlayingMetadata, ...currentMetadata };
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@ -42,7 +42,7 @@ const downloadVideoToMP3 = async (
|
||||
metadata = {
|
||||
artist: videoDetails?.media?.artist || cleanupArtistName(videoDetails?.author?.name) || "",
|
||||
title: videoDetails?.media?.song || videoDetails?.title || "",
|
||||
imageSrc: thumbnails ?
|
||||
imageSrcYTPL: thumbnails ?
|
||||
UrlToJPG(thumbnails[thumbnails.length - 1].url, videoDetails?.videoId)
|
||||
: ""
|
||||
}
|
||||
@ -149,7 +149,7 @@ const toMP3 = async (
|
||||
ipcRenderer.send("add-metadata", filePath, fileBuffer, {
|
||||
artist: metadata.artist,
|
||||
title: metadata.title,
|
||||
imageSrc: metadata.imageSrc
|
||||
imageSrcYTPL: metadata.imageSrcYTPL
|
||||
});
|
||||
ipcRenderer.once("add-metadata-done", reinit);
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user