mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-14 03:41:46 +00:00
speed up sponsorblock
This commit is contained in:
@ -1,8 +1,8 @@
|
|||||||
const fetch = require("node-fetch");
|
const fetch = require("node-fetch");
|
||||||
const is = require("electron-is");
|
const is = require("electron-is");
|
||||||
|
const { ipcMain } = require("electron");
|
||||||
|
|
||||||
const defaultConfig = require("../../config/defaults");
|
const defaultConfig = require("../../config/defaults");
|
||||||
const registerCallback = require("../../providers/song-info");
|
|
||||||
const { sortSegments } = require("./segments");
|
const { sortSegments } = require("./segments");
|
||||||
|
|
||||||
let videoID;
|
let videoID;
|
||||||
@ -13,15 +13,10 @@ module.exports = (win, options) => {
|
|||||||
...options,
|
...options,
|
||||||
};
|
};
|
||||||
|
|
||||||
registerCallback(async (info) => {
|
ipcMain.on("song-info-request", async (_, data) => {
|
||||||
const newURL = info.url || win.webContents.getURL();
|
videoID = JSON.parse(data)?.videoDetails?.videoId;
|
||||||
const newVideoID = new URL(newURL).searchParams.get("v");
|
const segments = await fetchSegments(apiURL, categories);
|
||||||
|
win.webContents.send("sponsorblock-skip", segments);
|
||||||
if (videoID !== newVideoID) {
|
|
||||||
videoID = newVideoID;
|
|
||||||
const segments = await fetchSegments(apiURL, categories);
|
|
||||||
win.webContents.send("sponsorblock-skip", segments);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user