Skip to content

Commit

Permalink
minimize getArtist()
Browse files Browse the repository at this point in the history
  • Loading branch information
Araxeus committed May 8, 2021
1 parent 3831e61 commit ccd320d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions providers/song-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,11 @@ const getPausedStatus = async (win) => {
};

const getArtist = async (win) => {
return await win.webContents.executeJavaScript(
`
var bar = document.getElementsByClassName('subtitle ytmusic-player-bar')[0];
var artistName = (bar.getElementsByClassName('yt-formatted-string')[0]) || (bar.getElementsByClassName('byline ytmusic-player-bar')[0]);
if (artistName) {
artistName.textContent;
}
`
);
return await win.webContents.executeJavaScript(`
document.querySelector(".subtitle.ytmusic-player-bar")
?.querySelector(".yt-formatted-string")
?.textContent
`);
}

// Fill songInfo with empty values
Expand Down Expand Up @@ -66,6 +62,8 @@ const handleData = async (responseText, win) => {
songInfo.uploadDate = data?.microformat?.microformatDataRenderer?.uploadDate;
songInfo.url = data?.microformat?.microformatDataRenderer?.urlCanonical;

console.log("updating song-info");

win.webContents.send("update-song-info", JSON.stringify(songInfo));
};

Expand Down

0 comments on commit ccd320d

Please sign in to comment.