Skip to content

Commit

Permalink
Merge pull request #588 from Araxeus/fix-album-name
Browse files Browse the repository at this point in the history
get album name from DOM
  • Loading branch information
th-ch authored Feb 9, 2022
2 parents 4d890c4 + 9b8d9c4 commit 621c5de
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions providers/song-info-front.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const config = require("../config");

global.songInfo = {};

function $(selector) { return document.querySelector(selector); }
const $ = s => document.querySelector(s);
const $$ = s => Array.from(document.querySelectorAll(s));

ipcRenderer.on("update-song-info", async (_, extractedSongInfo) => {
global.songInfo = JSON.parse(extractedSongInfo);
Expand Down Expand Up @@ -43,7 +44,11 @@ module.exports = () => {

function sendSongInfo() {
const data = apiEvent.detail.getPlayerResponse();
data.videoDetails.album = $('ytmusic-player-page')?.__data?.playerPageWatchMetadata?.albumName?.runs[0].text

data.videoDetails.album = $$(
".byline.ytmusic-player-bar > .yt-simple-endpoint"
).find(e => e.href?.includes("browse"))?.textContent;

data.videoDetails.elapsedSeconds = Math.floor(video.currentTime);
data.videoDetails.isPaused = false;
ipcRenderer.send("video-src-changed", JSON.stringify(data));
Expand Down

0 comments on commit 621c5de

Please sign in to comment.