From 451d33707ad43209dc3a4472a11a00e6a50dac6e Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Mon, 4 Sep 2023 18:01:54 +0900 Subject: [PATCH] fix: downloader For example, in South Korea, YouTube Music is only available to YT premium users. Therefore, calling getInfo without passing a cookie will always return `UNPLAYABLE`. --- plugins/downloader/back.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/downloader/back.ts b/plugins/downloader/back.ts index 46959323..f627c105 100644 --- a/plugins/downloader/back.ts +++ b/plugins/downloader/back.ts @@ -69,8 +69,12 @@ export default async (win_: BrowserWindow) => { win = win_; injectCSS(win.webContents, join(__dirname, 'style.css')); + const cookie = (await win.webContents.session.cookies.get({ url: 'https://music.youtube.com' })).map((it) => + it.name + '=' + it.value + ';' + ).join(''); yt = await Innertube.create({ cache: new UniversalCache(false), + cookie, generate_session_locally: true, }); ipcMain.on('download-song', (_, url: string) => downloadSong(url));