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