mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
Merge branch 'master' into update-custom-electron-titlebar
This commit is contained in:
6
providers/app-controls.js
Normal file
6
providers/app-controls.js
Normal file
@ -0,0 +1,6 @@
|
||||
const app = require("electron").app || require('@electron/remote').app;
|
||||
|
||||
module.exports.restart = () => {
|
||||
app.relaunch();
|
||||
app.exit();
|
||||
};
|
||||
@ -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));
|
||||
|
||||
@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user