Merge branch 'master' into update-custom-electron-titlebar

This commit is contained in:
Araxeus
2022-02-10 23:13:55 +02:00
committed by GitHub
18 changed files with 242 additions and 117 deletions

View File

@ -0,0 +1,6 @@
const app = require("electron").app || require('@electron/remote').app;
module.exports.restart = () => {
app.relaunch();
app.exit();
};

View File

@ -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);
@ -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));

View File

@ -112,13 +112,12 @@ const suffixesToRemove = [
" - topic",
"vevo",
" (performance video)",
" (official music video)",
" (official video)",
" (clip officiel)",
];
function cleanupName(name) {
if (!name) return name;
name = name.replace(/\((?:official)?[ ]?(?:music)?[ ]?(?:lyric[s]?)?[ ]?(?:video)?\)$/i, '')
const lowCaseName = name.toLowerCase();
for (const suffix of suffixesToRemove) {
if (lowCaseName.endsWith(suffix)) {