mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 20:52:06 +00:00
fix sponsorblock plugin
This commit is contained in:
@ -1,4 +1,12 @@
|
||||
const fetch = require("node-fetch");
|
||||
const is = require("electron-is");
|
||||
|
||||
// see https://github.com/node-fetch/node-fetch/issues/568#issuecomment-932200523
|
||||
// will not be needed if project's electron version >= v15.1.0 (https://github.com/node-fetch/node-fetch/issues/568#issuecomment-932435180)
|
||||
const https = require("https");
|
||||
const agent = new https.Agent({
|
||||
rejectUnauthorized: false,
|
||||
});
|
||||
|
||||
const defaultConfig = require("../../config/defaults");
|
||||
const registerCallback = require("../../providers/song-info");
|
||||
@ -24,6 +32,7 @@ module.exports = (win, options) => {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const fetchSegments = async (apiURL, categories) => {
|
||||
const sponsorBlockURL = `${apiURL}/api/skipSegments?videoID=${videoID}&categories=${JSON.stringify(
|
||||
categories
|
||||
@ -35,6 +44,7 @@ const fetchSegments = async (apiURL, categories) => {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
redirect: "follow",
|
||||
agent // fixes error: 'CERT_HAS_EXPIRED'
|
||||
});
|
||||
if (resp.status !== 200) {
|
||||
return [];
|
||||
@ -45,7 +55,10 @@ const fetchSegments = async (apiURL, categories) => {
|
||||
);
|
||||
|
||||
return sortedSegments;
|
||||
} catch {
|
||||
} catch (e) {
|
||||
if (is.dev()) {
|
||||
console.log('error on sponsorblock request:', e);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user