Skip to content

Commit 1628e4b

Browse files
authored
Merge pull request #2 from Daksh777/copilot/update-youtubei-js-version
Upgrade youtubei.js to 16.0.1 and fix downloader plugin
2 parents 430226a + 3cc8294 commit 1628e4b

File tree

9 files changed

+41
-27
lines changed

9 files changed

+41
-27
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
"virtua": "0.42.3",
136136
"vudio": "2.1.1",
137137
"x11": "2.3.0",
138-
"youtubei.js": "15.0.1",
138+
"youtubei.js": "^16.0.1",
139139
"zod": "4.1.5"
140140
},
141141
"devDependencies": {

pnpm-lock.yaml

Lines changed: 12 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/plugins/custom-output-device/renderer.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,14 @@ export const renderer = createRenderer<
5454
navigator.mediaDevices.ondevicechange = async () =>
5555
await updateDeviceList(context);
5656

57-
document.addEventListener('peard:audio-can-play', this.audioCanPlayHandler, {
58-
once: true,
59-
passive: true,
60-
});
57+
document.addEventListener(
58+
'peard:audio-can-play',
59+
this.audioCanPlayHandler,
60+
{
61+
once: true,
62+
passive: true,
63+
},
64+
);
6165
await updateDeviceList(context);
6266
},
6367

src/plugins/downloader/main/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { randomBytes } from 'node:crypto';
55
import { app, type BrowserWindow, dialog, ipcMain } from 'electron';
66
import {
77
Innertube,
8+
Platform,
89
UniversalCache,
910
Utils,
1011
YTNodes,
@@ -129,9 +130,14 @@ export const onMainLoad = async ({
129130
win = _win;
130131
config = await getConfig();
131132

133+
// Set up Platform shim for signature function evaluation
134+
Platform.shim.eval = (code: string) => {
135+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
136+
return eval(code);
137+
};
138+
132139
yt = await Innertube.create({
133140
cache: new UniversalCache(false),
134-
player_id: '0004de42',
135141
cookie: await getCookieFromWindow(win),
136142
generate_session_locally: true,
137143
fetch: getNetFetchAsFetch(),
@@ -405,8 +411,7 @@ async function downloadSongUnsafe(
405411
let targetFileExtension: string;
406412
if (!presetSetting?.extension) {
407413
targetFileExtension =
408-
VideoFormatList.find((it) => it.itag === format.itag)?.container ??
409-
'mp3';
414+
VideoFormatList.find((it) => it.itag === format.itag)?.container ?? 'mp3';
410415
} else {
411416
targetFileExtension = presetSetting?.extension ?? 'mp3';
412417
}

src/plugins/notifications/interactive.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ export default (
260260
songControls = getSongControls(win);
261261

262262
let currentSeconds = 0;
263-
on('peard:player-api-loaded', () => send('peard:setup-time-changed-listener'));
263+
on('peard:player-api-loaded', () =>
264+
send('peard:setup-time-changed-listener'),
265+
);
264266

265267
let savedSongInfo: SongInfo;
266268
let lastUrl: string | undefined;

src/plugins/synced-lyrics/renderer/components/LyricsPicker.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ const shouldSwitchProvider = (providerData: ProviderState) => {
5959
const providerBias = (p: ProviderName) =>
6060
(lyricsStore.lyrics[p].state === 'done' ? 1 : -1) +
6161
(lyricsStore.lyrics[p].data?.lines?.length ? 2 : -1) +
62-
// eslint-disable-next-line prettier/prettier
6362
(lyricsStore.lyrics[p].data?.lines?.length && p === ProviderNames.YTMusic
6463
? 1
6564
: 0) +

src/plugins/touchbar/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { nativeImage, type NativeImage, TouchBar } from 'electron';
22

3+
import musicPlayerIcon from '@assets/icon.png?asset&asarUnpack';
4+
35
import { createPlugin } from '@/utils';
46
import { getSongControls } from '@/providers/song-controls';
57
import { registerCallback, SongInfoEvent } from '@/providers/song-info';
68
import { t } from '@/i18n';
79

8-
import musicPlayerIcon from '@assets/icon.png?asset&asarUnpack';
910
import { Platform } from '@/types/plugins';
1011

1112
export default createPlugin({

src/providers/app-controls.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export const setupAppControls = () => {
1212
ipcMain.on('peard:reload', () =>
1313
BrowserWindow.getFocusedWindow()?.webContents.loadURL(config.get('url')),
1414
);
15-
ipcMain.handle('peard:get-path', (_, ...args: string[]) => path.join(...args));
15+
ipcMain.handle('peard:get-path', (_, ...args: string[]) =>
16+
path.join(...args),
17+
);
1618
};
1719

1820
function restartInternal() {

src/providers/song-controls.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ export const getSongControls = (win: BrowserWindow) => {
8585
const isFullscreenValue = parseBooleanFromArgsType(isFullscreen);
8686
if (isFullscreenValue !== null) {
8787
win.setFullScreen(isFullscreenValue);
88-
win.webContents.send('peard:click-fullscreen-button', isFullscreenValue);
88+
win.webContents.send(
89+
'peard:click-fullscreen-button',
90+
isFullscreenValue,
91+
);
8992
}
9093
},
9194
requestFullscreenInformation: () => {

0 commit comments

Comments
 (0)