Skip to content

Commit

Permalink
fix(downloader): fix #2769
Browse files Browse the repository at this point in the history
  • Loading branch information
JellyBrick committed Dec 26, 2024
1 parent 5ecfa2a commit 22fdfe3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/plugins/downloader/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>;

const sendError = (error: Error, source?: string) => {
win.setProgressBar(-1); // Close progress bar
setBadge(0); // Close badge
Expand Down Expand Up @@ -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
};
Expand Down

0 comments on commit 22fdfe3

Please sign in to comment.