Skip to content

Commit

Permalink
Send back metadata to front
Browse files Browse the repository at this point in the history
  • Loading branch information
th-ch committed Mar 29, 2021
1 parent 6987a0a commit 7ac9fda
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions providers/song-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) => {
Expand All @@ -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;
};
Expand Down

0 comments on commit 7ac9fda

Please sign in to comment.