Merge branch 'local-upstream/master' into use-ToastXML

This commit is contained in:
Araxeus
2023-01-16 21:36:47 +02:00
11 changed files with 89 additions and 6966 deletions

20
.github/workflows/dependency-review.yml vendored Normal file
View File

@ -0,0 +1,20 @@
# Dependency Review Action
#
# This Action will scan dependency manifest files that change as part of a Pull Reqest, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging.
#
# Source repository: https://github.com/actions/dependency-review-action
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
name: "Dependency Review"
on: [pull_request]
permissions:
contents: read
jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: "Checkout Repository"
uses: actions/checkout@v3
- name: "Dependency Review"
uses: actions/dependency-review-action@v3

View File

@ -183,7 +183,7 @@ function createMainWindow() {
win.webContents.loadURL(urlToLoad); win.webContents.loadURL(urlToLoad);
win.on("closed", onClosed); win.on("closed", onClosed);
const setPiPOptions = config.plugins.isEnabled("picture-in-picture") const setPiPOptions = config.plugins.isEnabled("picture-in-picture")
? (key, value) => require("./plugins/picture-in-picture/back").setOptions({ [key]: value }) ? (key, value) => require("./plugins/picture-in-picture/back").setOptions({ [key]: value })
: () => {}; : () => {};
@ -311,17 +311,6 @@ app.once("browser-window-created", (event, win) => {
win.webContents.on("will-prevent-unload", (event) => { win.webContents.on("will-prevent-unload", (event) => {
event.preventDefault(); event.preventDefault();
}); });
win.webContents.on(
"new-window",
(e, url, frameName, disposition, options) => {
// hook on new opened window
// at now new window in mainWindow renderer process.
// Also, this will automatically get an option `nodeIntegration=false`(not override to true, like in iframe's) - like in regular browsers
options.webPreferences.affinity = "main-window";
}
);
}); });
app.on("window-all-closed", () => { app.on("window-all-closed", () => {

View File

@ -1,7 +1,7 @@
const { existsSync } = require("fs"); const { existsSync } = require("fs");
const path = require("path"); const path = require("path");
const { app, Menu, dialog } = require("electron"); const { app, clipboard, Menu, dialog } = require("electron");
const is = require("electron-is"); const is = require("electron-is");
const { restart } = require("./providers/app-controls"); const { restart } = require("./providers/app-controls");
@ -327,6 +327,13 @@ const mainMenuTemplate = (win) => {
} }
}, },
}, },
{
label: "Copy current URL",
click: () => {
const currentURL = win.webContents.getURL();
clipboard.writeText(currentURL);
},
},
{ {
label: "Restart App", label: "Restart App",
click: restart click: restart

View File

@ -89,7 +89,7 @@
"release:win": "yarn run clean && electron-builder --win -p always" "release:win": "yarn run clean && electron-builder --win -p always"
}, },
"engines": { "engines": {
"node": ">=14.0.0", "node": ">=16.0.0",
"npm": "Please use yarn and not npm" "npm": "Please use yarn and not npm"
}, },
"dependencies": { "dependencies": {
@ -103,7 +103,7 @@
"butterchurn": "^2.6.7", "butterchurn": "^2.6.7",
"butterchurn-presets": "^2.4.7", "butterchurn-presets": "^2.4.7",
"chokidar": "^3.5.3", "chokidar": "^3.5.3",
"custom-electron-prompt": "^1.5.0", "custom-electron-prompt": "^1.5.1",
"custom-electron-titlebar": "^4.1.5", "custom-electron-titlebar": "^4.1.5",
"discord-rpc": "^4.0.1", "discord-rpc": "^4.0.1",
"electron-better-web-request": "^1.0.1", "electron-better-web-request": "^1.0.1",
@ -112,9 +112,9 @@
"electron-localshortcut": "^3.2.1", "electron-localshortcut": "^3.2.1",
"electron-store": "^8.1.0", "electron-store": "^8.1.0",
"electron-unhandled": "^4.0.1", "electron-unhandled": "^4.0.1",
"electron-updater": "^4.6.3", "electron-updater": "^5.3.0",
"filenamify": "^4.3.0", "filenamify": "^4.3.0",
"html-to-text": "^8.2.1", "html-to-text": "^9.0.3",
"md5": "^2.3.0", "md5": "^2.3.0",
"mpris-service": "^2.1.2", "mpris-service": "^2.1.2",
"node-fetch": "^2.6.8", "node-fetch": "^2.6.8",
@ -123,20 +123,20 @@
"ytpl": "^2.3.0" "ytpl": "^2.3.0"
}, },
"devDependencies": { "devDependencies": {
"@playwright/test": "^1.25.1", "@playwright/test": "^1.29.2",
"auto-changelog": "^2.4.0", "auto-changelog": "^2.4.0",
"del-cli": "^5.0.0", "del-cli": "^5.0.0",
"electron": "^20.1.1", "electron": "^22.0.2",
"electron-builder": "^23.0.3", "electron-builder": "^23.6.0",
"electron-devtools-installer": "^3.1.1", "electron-devtools-installer": "^3.2.0",
"electron-icon-maker": "0.0.5", "electron-icon-maker": "0.0.5",
"playwright": "^1.25.1", "playwright": "^1.29.2",
"xo": "^0.45.0" "xo": "^0.53.1"
}, },
"resolutions": { "resolutions": {
"glob-parent": "5.1.2", "glob-parent": "5.1.2",
"minimist": "1.2.6", "minimist": "1.2.7",
"yargs-parser": "18.1.3" "yargs-parser": "21.1.1"
}, },
"auto-changelog": { "auto-changelog": {
"hideCredit": true, "hideCredit": true,

View File

@ -1,15 +1,21 @@
const { ipcMain, dialog } = require("electron"); const { ipcMain } = require("electron");
module.exports = () => { const prompt = require("custom-electron-prompt");
ipcMain.handle('captionsSelector', async (_, captionLabels, currentIndex) => { const promptOptions = require("../../providers/prompt-options");
return await dialog.showMessageBox({
type: "question", module.exports = (win) => {
buttons: captionLabels, ipcMain.handle("captionsSelector", async (_, captionLabels, currentIndex) => {
defaultId: currentIndex, return await prompt(
title: "Choose Caption", {
message: "Choose Caption:", title: "Choose Caption",
detail: `Current Caption: ${captionLabels[currentIndex]}`, label: `Current Caption: ${captionLabels[currentIndex] || "None"}`,
cancelId: -1 type: "select",
}) value: currentIndex,
}) selectOptions: captionLabels,
resizable: true,
...promptOptions(),
},
win
);
});
}; };

View File

@ -4,7 +4,7 @@ const { ipcRenderer } = require("electron");
function $(selector) { return document.querySelector(selector); } function $(selector) { return document.querySelector(selector); }
const captionsSettingsButton = ElementFromFile( const captionsSettingsButton = ElementFromFile(
templatePath(__dirname, "captionsSettingsTemplate.html") templatePath(__dirname, "captions-settings-template.html")
); );
module.exports = (options) => { module.exports = (options) => {
@ -28,33 +28,33 @@ function setup(event, options) {
$(".right-controls-buttons").append(captionsSettingsButton); $(".right-controls-buttons").append(captionsSettingsButton);
captionsSettingsButton.onclick = function chooseQuality() { captionsSettingsButton.onclick = async () => {
api.loadModule("captions"); api.loadModule("captions");
const captionTrackList = api.getOption("captions", "tracklist"); const captionTrackList = api.getOption("captions", "tracklist");
if (captionTrackList?.length) { if (captionTrackList?.length) {
const currentCaptionTrack = api.getOption("captions", "track"); const currentCaptionTrack = api.getOption("captions", "track");
const currentIndex = captionTrackList.indexOf(captionTrackList.find(track => track.languageCode === currentCaptionTrack.languageCode)); let currentIndex = !currentCaptionTrack ?
null :
captionTrackList.indexOf(captionTrackList.find(track => track.languageCode === currentCaptionTrack.languageCode));
const captionLabels = [ const captionLabels = [
...captionTrackList.map(track => track.displayName), ...captionTrackList.map(track => track.displayName),
'None' 'None'
]; ];
ipcRenderer.invoke('captionsSelector', captionLabels, currentIndex).then(promise => { currentIndex = await ipcRenderer.invoke('captionsSelector', captionLabels, currentIndex)
if (promise.response === -1) return; if (currentIndex === null) return;
const newCaptions = captionTrackList[promise.response]; const newCaptions = captionTrackList[currentIndex];
if (newCaptions) { if (newCaptions) {
api.loadModule("captions"); api.setOption("captions", "track", { languageCode: newCaptions.languageCode });
api.setOption("captions", "track", { languageCode: newCaptions.languageCode }); } else {
} else { api.setOption("captions", "track", {});
api.unloadModule("captions"); }
}
setTimeout(() => api.playVideo()); setTimeout(() => api.playVideo());
});
} }
} }
} }

View File

@ -5,6 +5,7 @@ const registerCallback = require("../../providers/song-info");
const secToMilisec = t => Math.round(Number(t) * 1e3); const secToMilisec = t => Math.round(Number(t) * 1e3);
const data = { const data = {
cover: '',
cover_url: '', cover_url: '',
title: '', title: '',
artists: [], artists: [],
@ -43,6 +44,7 @@ module.exports = async (win) => {
data.duration = secToMilisec(songInfo.songDuration) data.duration = secToMilisec(songInfo.songDuration)
data.progress = secToMilisec(songInfo.elapsedSeconds) data.progress = secToMilisec(songInfo.elapsedSeconds)
data.cover = songInfo.imageSrc;
data.cover_url = songInfo.imageSrc; data.cover_url = songInfo.imageSrc;
data.album_url = songInfo.imageSrc; data.album_url = songInfo.imageSrc;
data.title = songInfo.title; data.title = songInfo.title;

View File

@ -64,6 +64,8 @@ winget install th-ch.YouTubeMusic
- **Bypass age restrictions**: bypass YouTube's age verification - **Bypass age restrictions**: bypass YouTube's age verification
- **Captions selector**: Enable captions
- **Disable Autoplay**: Makes every song start in "paused" mode - **Disable Autoplay**: Makes every song start in "paused" mode
- [**Discord**](https://discord.com/): Show your friends what you listen to with [Rich Presence](https://user-images.githubusercontent.com/28219076/104362104-a7a0b980-5513-11eb-9744-bb89eabe0016.png) - [**Discord**](https://discord.com/): Show your friends what you listen to with [Rich Presence](https://user-images.githubusercontent.com/28219076/104362104-a7a0b980-5513-11eb-9744-bb89eabe0016.png)

View File

@ -9,18 +9,27 @@ const appPath = path.resolve(__dirname, "..");
test("YouTube Music App - With default settings, app is launched and visible", async () => { test("YouTube Music App - With default settings, app is launched and visible", async () => {
const app = await electron.launch({ const app = await electron.launch({
cwd: appPath,
args: [ args: [
appPath,
"--no-sandbox", "--no-sandbox",
"--disable-gpu", "--disable-gpu",
"--whitelisted-ips=", "--whitelisted-ips=",
"--disable-dev-shm-usage", "--disable-dev-shm-usage",
appPath,
], ],
}); });
const window = await app.firstWindow(); const window = await app.firstWindow();
const consentForm = await window.$(
"form[action='https://consent.youtube.com/save']"
);
if (consentForm) {
await consentForm.click("button");
}
const title = await window.title(); const title = await window.title();
expect(title).toEqual("YouTube Music"); expect(title.replace(/\s/g, " ")).toEqual("YouTube Music");
const url = window.url(); const url = window.url();
expect(url.startsWith("https://music.youtube.com")).toBe(true); expect(url.startsWith("https://music.youtube.com")).toBe(true);

6912
yarn.lock

File diff suppressed because it is too large Load Diff