Skip to content

Commit 22fdfe3

Browse files
committed
fix(downloader): fix #2769
1 parent 5ecfa2a commit 22fdfe3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/plugins/downloader/main/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ let yt: Innertube;
6363
let win: BrowserWindow;
6464
let playingUrl: string;
6565

66+
const isYouTubePremium = () =>
67+
win.webContents.executeJavaScript(
68+
'!document.querySelector(\'#endpoint[href="/music_premium"]\')',
69+
) as Promise<boolean>;
70+
6671
const sendError = (error: Error, source?: string) => {
6772
win.setProgressBar(-1); // Close progress bar
6873
setBadge(0); // Close badge
@@ -313,7 +318,7 @@ async function downloadSongUnsafe(
313318
}
314319

315320
const downloadOptions: FormatOptions = {
316-
type: 'audio', // Audio, video or video+audio
321+
type: (await isYouTubePremium()) ? 'audio' : 'video+audio', // Audio, video or video+audio
317322
quality: 'best', // Best, bestefficiency, 144p, 240p, 480p, 720p and so on.
318323
format: 'any', // Media container format
319324
};

0 commit comments

Comments
 (0)