mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 11:21:46 +00:00
fix: remove unnecessary JSON.stringify & JSON.parse
This commit is contained in:
@ -29,7 +29,8 @@ import { isEnabled } from '../../config/plugins';
|
||||
import { cleanupName, getImage, SongInfo } from '../../providers/song-info';
|
||||
import { injectCSS } from '../utils';
|
||||
import { cache } from '../../providers/decorators';
|
||||
import { GetPlayerResponse } from '../../types/get-player-response';
|
||||
|
||||
import type { GetPlayerResponse } from '../../types/get-player-response';
|
||||
|
||||
type CustomSongInfo = SongInfo & { trackId?: string };
|
||||
|
||||
@ -78,8 +79,8 @@ export default async (win_: BrowserWindow) => {
|
||||
generate_session_locally: true,
|
||||
});
|
||||
ipcMain.on('download-song', (_, url: string) => downloadSong(url));
|
||||
ipcMain.on('video-src-changed', (_, data: string) => {
|
||||
playingUrl = (JSON.parse(data) as GetPlayerResponse).microformat.microformatDataRenderer.urlCanonical;
|
||||
ipcMain.on('video-src-changed', (_, data: GetPlayerResponse) => {
|
||||
playingUrl = data.microformat.microformatDataRenderer.urlCanonical;
|
||||
});
|
||||
ipcMain.on('download-playlist-request', async (_event, url: string) =>
|
||||
downloadPlaylist(url),
|
||||
|
||||
@ -24,8 +24,8 @@ export default (win: BrowserWindow, options: LyricGeniusType) => {
|
||||
|
||||
injectCSS(win.webContents, join(__dirname, 'style.css'));
|
||||
|
||||
ipcMain.handle('search-genius-lyrics', async (_, extractedSongInfo: string) => {
|
||||
const metadata = JSON.parse(extractedSongInfo) as SongInfo;
|
||||
ipcMain.handle('search-genius-lyrics', async (_, extractedSongInfo: SongInfo) => {
|
||||
const metadata = extractedSongInfo;
|
||||
return await fetchFromGenius(metadata);
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import { ipcRenderer } from 'electron';
|
||||
import is from 'electron-is';
|
||||
|
||||
import type { SongInfo } from '../../providers/song-info';
|
||||
|
||||
export default () => {
|
||||
ipcRenderer.on('update-song-info', (_, extractedSongInfo: string) => setTimeout(async () => {
|
||||
ipcRenderer.on('update-song-info', (_, extractedSongInfo: SongInfo) => setTimeout(async () => {
|
||||
const tabList = document.querySelectorAll('tp-yt-paper-tab');
|
||||
const tabs = {
|
||||
upNext: tabList[0],
|
||||
|
||||
@ -6,8 +6,8 @@ import { sortSegments } from './segments';
|
||||
import { SkipSegment } from './types';
|
||||
|
||||
import defaultConfig from '../../config/defaults';
|
||||
import { GetPlayerResponse } from '../../types/get-player-response';
|
||||
|
||||
import type { GetPlayerResponse } from '../../types/get-player-response';
|
||||
import type { ConfigType } from '../../config/dynamic';
|
||||
|
||||
let videoID: string;
|
||||
@ -18,8 +18,8 @@ export default (win: BrowserWindow, options: ConfigType<'sponsorblock'>) => {
|
||||
...options,
|
||||
};
|
||||
|
||||
ipcMain.on('video-src-changed', async (_, data: string) => {
|
||||
videoID = (JSON.parse(data) as GetPlayerResponse)?.videoDetails?.videoId;
|
||||
ipcMain.on('video-src-changed', async (_, data: GetPlayerResponse) => {
|
||||
videoID = data?.videoDetails?.videoId;
|
||||
const segments = await fetchSegments(apiURL, categories);
|
||||
win.webContents.send('sponsorblock-skip', segments);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user