From 22fdfe3342886dd075ac40cbfaf92c33a28a64bd Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Fri, 27 Dec 2024 00:50:18 +0900 Subject: [PATCH] fix(downloader): fix #2769 --- src/plugins/downloader/main/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/downloader/main/index.ts b/src/plugins/downloader/main/index.ts index 3bb4b76e..92d47b18 100644 --- a/src/plugins/downloader/main/index.ts +++ b/src/plugins/downloader/main/index.ts @@ -63,6 +63,11 @@ let yt: Innertube; let win: BrowserWindow; let playingUrl: string; +const isYouTubePremium = () => + win.webContents.executeJavaScript( + '!document.querySelector(\'#endpoint[href="/music_premium"]\')', + ) as Promise; + const sendError = (error: Error, source?: string) => { win.setProgressBar(-1); // Close progress bar setBadge(0); // Close badge @@ -313,7 +318,7 @@ async function downloadSongUnsafe( } const downloadOptions: FormatOptions = { - type: 'audio', // Audio, video or video+audio + type: (await isYouTubePremium()) ? 'audio' : 'video+audio', // Audio, video or video+audio quality: 'best', // Best, bestefficiency, 144p, 240p, 480p, 720p and so on. format: 'any', // Media container format };