Skip to content

Commit b02a835

Browse files
committed
fix pathes?
1 parent ab0dbe0 commit b02a835

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

main.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,10 @@ app.on('ready', async () => {
263263
app.setAppUserModelId("com.mp3butcher.youtube-dl-gui");
264264
env = new Environment(app);
265265
await env.initialize();
266-
let baseappdir = app.isPackaged ? path.dirname(env.paths.packedPrefix) : app.getAppPath();
267-
let pyodidepath = app.isPackaged ? path.join(baseappdir,'resources/pyodide/') : path.join(baseappdir,'node_modules/pyodide');
266+
let basewheels = app.isPackaged ? env.paths.baseappdir + '/resources/libs/wheels/': env.paths.baseappdir +'/resources/libs/wheels/'
267+
let pyodidepath;
268+
if(process.platform == 'win32') pyodidepath = app.isPackaged ? 'resources/resources/pyodide/' : 'node_modules/pyodide';
269+
else pyodidepath = app.isPackaged ? path.join(env.paths.baseappdir,'resources/pyodide/') : path.join(env.paths.baseappdir,'node_modules/pyodide');
268270
let somepackages = [
269271
"certifi-2024.2.2-py3-none-any.whl","charset_normalizer-3.3.2-py3-none-any.whl",
270272
"construct-2.8.8-py2.py3-none-any.whl","idna-3.6-py3-none-any.whl",
@@ -274,10 +276,10 @@ app.on('ready', async () => {
274276
"pywidevine-1.8.0-py3-none-any.whl",
275277
"requests-2.31.0-py3-none-any.whl",
276278
"urllib3-2.2.1-py3-none-any.whl"
277-
].map(e=>path.join(baseappdir,"resources/libs/wheels/")+e)
279+
].map(e=>basewheels + e)
278280
pyodide = await Pyodide.loadPyodide({indexURL: pyodidepath, packages: somepackages});
279281

280-
fs.readFile(path.join(baseappdir, 'resources/selectRules.conf'), 'utf8', (err, data) => {
282+
fs.readFile(path.join(env.paths.baseappdir, 'resources/selectRules.conf'), 'utf8', (err, data) => {
281283
if (err) {
282284
console.error(err);
283285
return;
@@ -453,10 +455,9 @@ function scanPostRequest(data) {
453455

454456
globalThis.zechallenge = '';
455457

456-
let baseappdir = app.isPackaged ? path.dirname(env.paths.packedPrefix) : app.getAppPath();
457-
let pre = fs.readFileSync(path.join(baseappdir,'resources/pre.py'), { encoding: 'utf8', flag: 'r' });
458-
let after = fs.readFileSync(path.join(baseappdir,'resources/after.py'), { encoding: 'utf8', flag: 'r' });
459-
let scheme = fs.readFileSync(path.join(baseappdir,'resources/schemes/') + (licrule[1] ? licrule[1] : 'CommonWV') + '.py', { encoding: 'utf8', flag: 'r' });
458+
let pre = fs.readFileSync(path.join(env.paths.baseappdir, 'resources/pre.py'), { encoding: 'utf8', flag: 'r' });
459+
let after = fs.readFileSync(path.join(env.paths.baseappdir, 'resources/after.py'), { encoding: 'utf8', flag: 'r' });
460+
let scheme = fs.readFileSync(path.join(env.paths.baseappdir, 'resources/schemes/') + (licrule[1] ? licrule[1] : 'CommonWV') + '.py', { encoding: 'utf8', flag: 'r' });
460461
//Get result
461462

462463
console.log("call python")

modules/Filepaths.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Filepaths {
2525
this.ffmpegVersion = this.app.isPackaged ? path.join(this.unpackedPrefix, "binaries/ffmpegVersion") :"binaries/ffmpegVersion";
2626
this.mitmproxy = this.app.isPackaged ? path.join(this.unpackedPrefix, "binaries") : "binaries";
2727
this.mitmproxyVersion = this.app.isPackaged ? path.join(this.unpackedPrefix, "binaries/mitmproxyVersion") :"binaries/mitmproxyVersion";
28-
this.mitmproxyScriptPath= this.app.isPackaged ? path.join(this.unpackedPrefix, "binaries"): "binaries";
28+
this.mitmproxyScriptPath = this.app.isPackaged ? path.join(this.unpackedPrefix, "binaries"): "binaries";
2929
break;
3030
case "win32app": {
3131
const appDir = path.basename(path.join(this.appPath, "../../..")).replace(/_(.*)_/g, "_");
@@ -43,7 +43,7 @@ class Filepaths {
4343
this.ffmpegVersion = path.join(this.binaryPath, "ffmpegVersion");
4444
this.mitmproxy = this.binaryPath;
4545
this.mitmproxyVersion = path.join(this.binaryPath, "mitmproxyVersion");
46-
this.mitmproxyScriptPath= this.app.isPackaged ? path.join(this.unpackedPrefix, "binaries"): "binaries";
46+
this.mitmproxyScriptPath = this.app.isPackaged ? path.join(this.unpackedPrefix, "binaries"): "binaries";
4747
break;
4848
}
4949
case "win32portable":
@@ -60,7 +60,7 @@ class Filepaths {
6060
this.ffmpegVersion = path.join(this.persistentPath, "ffmpegVersion");
6161
this.mitmproxy = this.persistentPath;
6262
this.mitmproxyVersion = path.join(this.persistentPath, "mitmproxyVersion");
63-
this.mitmproxyScriptPath= this.app.isPackaged ? path.join(this.unpackedPrefix, "binaries"): "binaries";
63+
this.mitmproxyScriptPath = this.app.isPackaged ? path.join(this.unpackedPrefix, "binaries"): "binaries";
6464
break;
6565
case "darwin":
6666
this.packedPrefix = this.appPath;
@@ -75,7 +75,7 @@ class Filepaths {
7575
this.ffmpegVersion = path.join(this.unpackedPrefix, "binaries/ffmpegVersion");
7676
this.mitmproxy = path.join(this.unpackedPrefix, "binaries");
7777
this.mitmproxyVersion = path.join(this.unpackedPrefix, "binaries/mitmproxyVersion");
78-
this.mitmproxyScriptPath= path.join(this.unpackedPrefix, "binaries");
78+
this.mitmproxyScriptPath = path.join(this.unpackedPrefix, "binaries");
7979
}else{
8080
this.ffmpeg = "binaries";
8181
this.ytdl = this.getMacOSPathYtDlp();
@@ -86,7 +86,7 @@ class Filepaths {
8686
this.ffmpegVersion = "binaries/ffmpegVersion";
8787
this.mitmproxy = "binaries";
8888
this.mitmproxyVersion = "binaries/mitmproxyVersion";
89-
this.mitmproxyScriptPath= "binaries";
89+
this.mitmproxyScriptPath = "binaries";
9090
}
9191
this.baseappdir = this.app.isPackaged ? path.dirname(this.packedPrefix) : this.appPath;
9292
this.setPermissions()
@@ -105,7 +105,7 @@ class Filepaths {
105105
this.ffmpegVersion = this.app.isPackaged ? path.join(this.persistentPath, "ffmpegVersion") :"binaries/ffmpegVersion";
106106
this.mitmproxy = this.app.isPackaged ? this.persistentPath : "binaries";
107107
this.mitmproxyVersion = this.app.isPackaged ? path.join(this.persistentPath, "mitmproxyVersion") :"binaries/mitmproxyVersion";
108-
this.mitmproxyScriptPath= this.app.isPackaged ? path.join(this.unpackedPrefix, "binaries"): "binaries";
108+
this.mitmproxyScriptPath = this.app.isPackaged ? path.join(this.unpackedPrefix, "binaries"): "binaries";
109109
this.baseappdir = this.app.isPackaged ? path.dirname(this.packedPrefix) : this.appPath;
110110
this.setPermissions()
111111
break;

0 commit comments

Comments
 (0)