mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
Merge pull request #339 from th-ch/fix-downloader-plugin
Fix downloader plugin
This commit is contained in:
47
index.js
47
index.js
@ -2,6 +2,7 @@
|
||||
const path = require("path");
|
||||
|
||||
const electron = require("electron");
|
||||
const enhanceWebRequest = require("electron-better-web-request").default;
|
||||
const is = require("electron-is");
|
||||
const unhandled = require("electron-unhandled");
|
||||
const { autoUpdater } = require("electron-updater");
|
||||
@ -143,17 +144,19 @@ function createMainWindow() {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
win.webContents.on("render-process-gone", (event, webContents, details) => {
|
||||
showUnresponsiveDialog(win, details);
|
||||
});
|
||||
|
||||
|
||||
win.once("ready-to-show", () => {
|
||||
if (config.get("options.appVisible")) {
|
||||
win.show();
|
||||
}
|
||||
});
|
||||
|
||||
removeContentSecurityPolicy();
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
@ -373,7 +376,45 @@ function showUnresponsiveDialog(win, details) {
|
||||
app.quit();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function removeContentSecurityPolicy(
|
||||
session = electron.session.defaultSession
|
||||
) {
|
||||
// Allows defining multiple "onHeadersReceived" listeners
|
||||
// by enhancing the session.
|
||||
// Some plugins (e.g. adblocker) also define a "onHeadersReceived" listener
|
||||
enhanceWebRequest(session);
|
||||
|
||||
// Custom listener to tweak the content security policy
|
||||
session.webRequest.onHeadersReceived(function (details, callback) {
|
||||
if (
|
||||
!details.responseHeaders["content-security-policy-report-only"] &&
|
||||
!details.responseHeaders["content-security-policy"]
|
||||
)
|
||||
return callback({ cancel: false });
|
||||
delete details.responseHeaders["content-security-policy-report-only"];
|
||||
delete details.responseHeaders["content-security-policy"];
|
||||
callback({ cancel: false, responseHeaders: details.responseHeaders });
|
||||
});
|
||||
|
||||
// When multiple listeners are defined, apply them all
|
||||
session.webRequest.setResolver("onHeadersReceived", (listeners) => {
|
||||
const response = listeners.reduce(
|
||||
async (accumulator, listener) => {
|
||||
if (accumulator.cancel) {
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
const result = await listener.apply();
|
||||
return { ...accumulator, ...result };
|
||||
},
|
||||
{ cancel: false }
|
||||
);
|
||||
|
||||
return response;
|
||||
});
|
||||
}
|
||||
|
||||
@ -69,9 +69,10 @@
|
||||
"YoutubeNonStop": "git://github.com/lawfx/YoutubeNonStop.git#v0.9.0",
|
||||
"async-mutex": "^0.3.1",
|
||||
"browser-id3-writer": "^4.4.0",
|
||||
"custom-electron-titlebar": "^3.2.7",
|
||||
"chokidar": "^3.5.1",
|
||||
"custom-electron-titlebar": "^3.2.7",
|
||||
"discord-rpc": "^3.2.0",
|
||||
"electron-better-web-request": "^1.0.1",
|
||||
"electron-debug": "^3.2.0",
|
||||
"electron-is": "^3.0.0",
|
||||
"electron-localshortcut": "^3.2.1",
|
||||
@ -82,8 +83,8 @@
|
||||
"md5": "^2.3.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"node-notifier": "^9.0.1",
|
||||
"ytdl-core": "^4.8.2",
|
||||
"ytpl": "^2.2.0"
|
||||
"ytdl-core": "^4.8.3",
|
||||
"ytpl": "^2.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "^12.0.8",
|
||||
|
||||
@ -33,7 +33,17 @@ const loadAdBlockerEngine = (
|
||||
...additionalBlockLists,
|
||||
];
|
||||
|
||||
ElectronBlocker.fromLists(fetch, lists, {}, cachingOptions)
|
||||
ElectronBlocker.fromLists(
|
||||
fetch,
|
||||
lists,
|
||||
{
|
||||
// when generating the engine for caching, do not load network filters
|
||||
// So that enhancing the session works as expected
|
||||
// Allowing to define multiple webRequest listeners
|
||||
loadNetworkFilters: session !== undefined,
|
||||
},
|
||||
cachingOptions
|
||||
)
|
||||
.then((blocker) => {
|
||||
if (session) {
|
||||
blocker.enableBlockingInSession(session);
|
||||
|
||||
33
yarn.lock
33
yarn.lock
@ -550,9 +550,9 @@
|
||||
integrity sha512-qunWJl5PezpXEm31tb8Qu5z37B5KVA1VYZCpXchMhuAb3X9T7PuE3SlhOwphEoRhzaOa3lpofDfzihAUMFaVPQ==
|
||||
|
||||
"@ffmpeg/ffmpeg@^0.10.0":
|
||||
version "0.10.0"
|
||||
resolved "https://registry.yarnpkg.com/@ffmpeg/ffmpeg/-/ffmpeg-0.10.0.tgz#0bebd944d50ce11297b91883f94b2f6220b74e34"
|
||||
integrity sha512-W+d0ysYTO6d4vue/0KMYrxaprh9wvmnPqh6qyHXavBWLrDcE7gI3cJ/EQVfwe9nrt2e0Pi7873P2I18VEDgRfA==
|
||||
version "0.10.1"
|
||||
resolved "https://registry.yarnpkg.com/@ffmpeg/ffmpeg/-/ffmpeg-0.10.1.tgz#3dacf3985de9c83a95fbf79fe709920cc009b00a"
|
||||
integrity sha512-ChQkH7Rh57hmVo1LhfQFibWX/xqneolJKSwItwZdKPcLZuKigtYAYDIvB55pDfP17VtR1R77SxgkB2/UApB+Og==
|
||||
dependencies:
|
||||
is-url "^1.2.4"
|
||||
node-fetch "^2.6.1"
|
||||
@ -3264,6 +3264,14 @@ ejs@^3.1.6:
|
||||
dependencies:
|
||||
jake "^10.6.1"
|
||||
|
||||
electron-better-web-request@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/electron-better-web-request/-/electron-better-web-request-1.0.1.tgz#9c7ccf88499cc8b17f9bffd3f33a01fc1e70282a"
|
||||
integrity sha512-euwLeL82k6fbVODfH5Uz9c4BN047/XyYKfsZcaFhdWfqx05JPu2J0xE7nciJ/1Bb0sTClU1FDLW5H2zQWBB5Gw==
|
||||
dependencies:
|
||||
url-match-patterns "^0.2.0"
|
||||
uuid "^3.3.2"
|
||||
|
||||
electron-builder@^22.10.5:
|
||||
version "22.10.5"
|
||||
resolved "https://registry.yarnpkg.com/electron-builder/-/electron-builder-22.10.5.tgz#03b156b93e6012609027c3aaa69201a3ad21e454"
|
||||
@ -6222,7 +6230,7 @@ lodash.zip@^4.2.0:
|
||||
resolved "https://registry.yarnpkg.com/lodash.zip/-/lodash.zip-4.2.0.tgz#ec6662e4896408ed4ab6c542a3990b72cc080020"
|
||||
integrity sha1-7GZi5IlkCO1KtsVCo5kLcswIACA=
|
||||
|
||||
lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21:
|
||||
lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.3.0:
|
||||
version "4.17.21"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
||||
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
||||
@ -8859,6 +8867,13 @@ urix@^0.1.0:
|
||||
resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72"
|
||||
integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=
|
||||
|
||||
url-match-patterns@^0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/url-match-patterns/-/url-match-patterns-0.2.0.tgz#a688f68b0aff990c6df3c99ec208a8d410f1cb8c"
|
||||
integrity sha1-poj2iwr/mQxt88mewgio1BDxy4w=
|
||||
dependencies:
|
||||
lodash "^4.3.0"
|
||||
|
||||
url-parse-lax@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-3.0.0.tgz#16b5cafc07dbe3676c1b1999177823d6503acb0c"
|
||||
@ -9355,16 +9370,16 @@ yocto-queue@^0.1.0:
|
||||
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
|
||||
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
|
||||
|
||||
ytdl-core@^4.8.2:
|
||||
version "4.8.2"
|
||||
resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.8.2.tgz#f034ad942c5d958f5987fc8ff0b0639664ae2fb7"
|
||||
integrity sha512-O3n++YcgZawaXJwbPmnRDgfN6b4kU0DpNdkI9Na5yM3JAdfJmoq5UHc8v9Xjgjr1RilQUUh7mhDnRRPDtKr0Kg==
|
||||
ytdl-core@^4.8.3:
|
||||
version "4.8.3"
|
||||
resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.8.3.tgz#21570d1834db13dec7828cf87bbf4c83c0fe68d7"
|
||||
integrity sha512-cWCBeX4FCgjcKmuVK384MT582RIAakpUSeMF/NPVmhO8cWiG+LeQLnBordvLolb0iXYzfUvalgmycYAE5Sy6Xw==
|
||||
dependencies:
|
||||
m3u8stream "^0.8.3"
|
||||
miniget "^4.0.0"
|
||||
sax "^1.1.3"
|
||||
|
||||
ytpl@^2.2.0:
|
||||
ytpl@^2.2.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/ytpl/-/ytpl-2.2.1.tgz#e514eccdd46e02eeb0d16e08f8278489258ab31a"
|
||||
integrity sha512-sxty58s4JTNCDkiaiTkcaXfWCOW5sfHOPwDQtWIkoU4C+Kht2qat8yaLVbWZIclUSZo+naANyaI7LGjhhrErGA==
|
||||
|
||||
Reference in New Issue
Block a user