From 7ac9fda1eb370ffdd2e52375c3c2f39f73efdf74 Mon Sep 17 00:00:00 2001 From: TC Date: Mon, 29 Mar 2021 21:33:07 +0200 Subject: [PATCH] Send back metadata to front --- providers/song-info.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/providers/song-info.js b/providers/song-info.js index 6852ef09..55d87112 100644 --- a/providers/song-info.js +++ b/providers/song-info.js @@ -42,7 +42,7 @@ const songInfo = { url: "", }; -const handleData = async (_event, responseText) => { +const handleData = async (responseText, win) => { let data = JSON.parse(responseText); songInfo.title = data?.videoDetails?.title; songInfo.artist = data?.videoDetails?.author; @@ -52,6 +52,8 @@ const handleData = async (_event, responseText) => { songInfo.image = await getImage(songInfo.imageSrc); songInfo.uploadDate = data?.microformat?.microformatDataRenderer?.uploadDate; songInfo.url = data?.microformat?.microformatDataRenderer?.urlCanonical; + + win.webContents.send("update-song-info", JSON.stringify(songInfo)); }; const registerProvider = (win) => { @@ -77,7 +79,10 @@ const registerProvider = (win) => { }); // This will be called when the song-info-front finds a new request with song data - ipcMain.on("song-info-request", handleData); + ipcMain.on( + "song-info-request", + async (_, responseText) => await handleData(responseText, win) + ); return registerCallback; };