diff --git a/menu.ts b/menu.ts index 0377bb5d..fca99e6d 100644 --- a/menu.ts +++ b/menu.ts @@ -242,7 +242,7 @@ export const mainMenuTemplate = (win: BrowserWindow): MenuTemplate => { { label: 'Enabled + app visible', type: 'radio', - checked: !!(config.get('options.tray') && config.get('options.appVisible')), + checked: config.get('options.tray') && config.get('options.appVisible'), click() { config.setMenuOption('options.tray', true); config.setMenuOption('options.appVisible', true); @@ -251,7 +251,7 @@ export const mainMenuTemplate = (win: BrowserWindow): MenuTemplate => { { label: 'Enabled + app hidden', type: 'radio', - checked: !!(config.get('options.tray') && !config.get('options.appVisible')), + checked: config.get('options.tray') && !config.get('options.appVisible'), click() { config.setMenuOption('options.tray', true); config.setMenuOption('options.appVisible', false); @@ -316,7 +316,7 @@ export const mainMenuTemplate = (win: BrowserWindow): MenuTemplate => { is.macOS() ? { label: 'Toggle DevTools', - // Cannot use "toggleDevTools" role in MacOS + // Cannot use "toggleDevTools" role in macOS click() { const { webContents } = win; if (webContents.isDevToolsOpened()) { diff --git a/plugins/crossfade/back.ts b/plugins/crossfade/back.ts index ff4d1647..56a1355f 100644 --- a/plugins/crossfade/back.ts +++ b/plugins/crossfade/back.ts @@ -1,15 +1,11 @@ import { ipcMain } from 'electron'; import { Innertube } from 'youtubei.js'; -import config from './config'; - export default async () => { const yt = await Innertube.create(); ipcMain.handle('audio-url', async (_, videoID: string) => { const info = await yt.getBasicInfo(videoID); - const url = info.streaming_data?.formats[0].decipher(yt.session.player); - - return url; + return info.streaming_data?.formats[0].decipher(yt.session.player); }); }; diff --git a/plugins/crossfade/fader.ts b/plugins/crossfade/fader.ts index e403100a..c9442ba0 100644 --- a/plugins/crossfade/fader.ts +++ b/plugins/crossfade/fader.ts @@ -63,8 +63,8 @@ interface VolumeFade { // Main class export class VolumeFader { - private media: HTMLMediaElement; - private logger: VolumeLogger | false; + private readonly media: HTMLMediaElement; + private readonly logger: VolumeLogger | false; private scale: { internalToVolume: (level: number) => number; volumeToInternal: (level: number) => number; diff --git a/plugins/downloader/back.ts b/plugins/downloader/back.ts index 90a201c8..46959323 100644 --- a/plugins/downloader/back.ts +++ b/plugins/downloader/back.ts @@ -1,10 +1,4 @@ - -import { - existsSync, - mkdirSync, - createWriteStream, - writeFileSync, -} from 'node:fs'; +import { createWriteStream, existsSync, mkdirSync, writeFileSync, } from 'node:fs'; import { join } from 'node:path'; import { randomBytes } from 'node:crypto'; @@ -12,7 +6,7 @@ import { app, BrowserWindow, dialog, ipcMain } from 'electron'; import { ClientType, Innertube, UniversalCache, Utils } from 'youtubei.js'; import is from 'electron-is'; import ytpl from 'ytpl'; - // REPLACE with youtubei getplaylist https://github.com/LuanRT/YouTube.js#getplaylistid +// REPLACE with youtubei getplaylist https://github.com/LuanRT/YouTube.js#getplaylistid import filenamify from 'filenamify'; import { Mutex } from 'async-mutex'; import { createFFmpeg } from '@ffmpeg/ffmpeg'; @@ -260,11 +254,10 @@ async function iterableStreamToMP3( ) { const chunks = []; let downloaded = 0; - const total = contentLength; for await (const chunk of stream) { downloaded += chunk.length; chunks.push(chunk); - const ratio = downloaded / total; + const ratio = downloaded / contentLength; const progress = Math.floor(ratio * 100); sendFeedback(`Download: ${progress}%`, ratio); // 15% for download, 85% for conversion @@ -552,8 +545,7 @@ const getAndroidTvInfo = async (id: string): Promise => { generate_session_locally: true, retrieve_player: true, }); - const info = await innertube.getBasicInfo(id, 'TV_EMBEDDED'); // GetInfo 404s with the bypass, so we use getBasicInfo instead // that's fine as we only need the streaming data - return info; + return await innertube.getBasicInfo(id, 'TV_EMBEDDED'); }; diff --git a/plugins/navigation/actions.ts b/plugins/navigation/actions.ts index 692ab4e7..32813956 100644 --- a/plugins/navigation/actions.ts +++ b/plugins/navigation/actions.ts @@ -6,10 +6,16 @@ export const ACTIONS = Actions; export function goToNextPage() { triggerAction(CHANNEL, Actions.NEXT); } +// for HTML +// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-explicit-any +(global as any).goToNextPage = goToNextPage; export function goToPreviousPage() { triggerAction(CHANNEL, Actions.BACK); } +// for HTML +// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-explicit-any +(global as any).goToPreviousPage = goToPreviousPage; export default { CHANNEL,