Fix #270
This commit is contained in:
parent
9f888a1cdb
commit
19800b59e3
6 changed files with 30 additions and 16 deletions
4
@types/messageHandler.d.ts
vendored
4
@types/messageHandler.d.ts
vendored
|
|
@ -13,9 +13,11 @@ export interface MessageHandler {
|
|||
downloadItem: (data) => void,
|
||||
isDownloading: () => boolean,
|
||||
writeToClipboard: (text: string) => void,
|
||||
openFolder: (path: string[]) => void
|
||||
openFolder: (path: FolderTypes) => void
|
||||
}
|
||||
|
||||
export type FolderTypes = 'content' | 'config';
|
||||
|
||||
export type QueueItem = {
|
||||
title: string,
|
||||
episode: string,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import { app, BrowserWindow, dialog, } from 'electron';
|
||||
import path from 'path/posix';
|
||||
import registerMessageHandler from './messageHandler';
|
||||
import fs from 'fs';
|
||||
import dotenv from 'dotenv';
|
||||
import express from 'express';
|
||||
import { Console } from 'console';
|
||||
import json from '../../../package.json';
|
||||
|
||||
|
||||
process.on('uncaughtException', (er, or) => {
|
||||
console.error(er, or);
|
||||
});
|
||||
|
|
@ -29,6 +29,7 @@ const getDataDirectory = () => {
|
|||
console.error('Unknown home directory');
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('Appdata', process.env.APPDATA)
|
||||
return path.join(process.env.APPDATA, json.name);
|
||||
}
|
||||
case 'linux': {
|
||||
|
|
@ -48,6 +49,7 @@ if (!fs.existsSync(getDataDirectory()))
|
|||
fs.mkdirSync(getDataDirectory());
|
||||
|
||||
export { getDataDirectory };
|
||||
process.env.contentDirectory = getDataDirectory();
|
||||
|
||||
import './menu';
|
||||
|
||||
|
|
@ -110,7 +112,7 @@ const createWindow = async () => {
|
|||
app.quit();
|
||||
}
|
||||
|
||||
registerMessageHandler(mainWindow);
|
||||
(await import('./messageHandler')).default(mainWindow);
|
||||
|
||||
if (!process.env.USE_BROWSER) {
|
||||
const app = express();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { BrowserWindow, clipboard, dialog, shell } from 'electron';
|
||||
import { DownloadInfo, ProgressData } from '../../../../@types/messageHandler';
|
||||
import { DownloadInfo, FolderTypes, ProgressData } from '../../../../@types/messageHandler';
|
||||
import { RandomEvent, RandomEvents } from '../../../../@types/randomEvents';
|
||||
import { isWindows } from '..';
|
||||
import { loadCfg } from "../../../../modules/module.cfg-loader";
|
||||
|
||||
export default class Base {
|
||||
|
||||
|
|
@ -55,12 +55,16 @@ export default class Base {
|
|||
return true;
|
||||
}
|
||||
|
||||
async openFolder(subPath: string[]) {
|
||||
const sep = isWindows ? '\\' : '/';
|
||||
|
||||
const p = __dirname.split(sep).slice(0, -4); // gui/electron/src/serviceHandler
|
||||
p.push(...subPath);
|
||||
shell.openPath(p.join(sep));
|
||||
async openFolder(folderType: FolderTypes) {
|
||||
const conf = loadCfg();
|
||||
switch (folderType) {
|
||||
case 'content':
|
||||
shell.openPath(conf.dir.content);
|
||||
break;
|
||||
case 'config':
|
||||
shell.openPath(conf.dir.config);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ const DownloadSelector: React.FC = () => {
|
|||
<Box sx={{ gap: 2, flex: 0, m: 1, mb: 3, display: 'flex', justifyContent: 'center' }}>
|
||||
<LoadingButton loading={loading} onClick={listEpisodes} variant='contained'>List episodes</LoadingButton>
|
||||
<LoadingButton loading={loading} onClick={addToQueue} variant='contained'>Add to Queue</LoadingButton>
|
||||
<Button variant="contained" startIcon={<Folder />} onClick={() => messageHandler?.openFolder(['videos'])}>Open Output Directory</Button>
|
||||
<Button variant="contained" startIcon={<Folder />} onClick={() => messageHandler?.openFolder('content')}>Open Output Directory</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,10 @@ import { lookpath } from 'lookpath';
|
|||
// new-cfg
|
||||
const workingDir = (process as NodeJS.Process & {
|
||||
pkg?: unknown
|
||||
}).pkg ? path.dirname(process.execPath) : path.join(__dirname, '/..');
|
||||
}).pkg ? path.dirname(process.execPath) : process.env.contentDirectory ? process.env.contentDirectory : path.join(__dirname, '/..');
|
||||
|
||||
console.log(workingDir, process.env.contentDirectory);
|
||||
|
||||
const binCfgFile = path.join(workingDir, 'config', 'bin-path');
|
||||
const dirCfgFile = path.join(workingDir, 'config', 'dir-path');
|
||||
const cliCfgFile = path.join(workingDir, 'config', 'cli-defaults');
|
||||
|
|
@ -37,7 +40,8 @@ export type ConfigObject = {
|
|||
dir: {
|
||||
content: string,
|
||||
trash: string,
|
||||
fonts: string;
|
||||
fonts: string;
|
||||
config: string;
|
||||
},
|
||||
bin: {
|
||||
ffmpeg?: string,
|
||||
|
|
@ -56,6 +60,7 @@ const loadCfg = () : ConfigObject => {
|
|||
content: string,
|
||||
trash: string,
|
||||
fonts: string
|
||||
config: string
|
||||
}>(dirCfgFile),
|
||||
cli: loadYamlCfgFile<{
|
||||
[key: string]: any
|
||||
|
|
@ -65,6 +70,7 @@ const loadCfg = () : ConfigObject => {
|
|||
fonts: '${wdir}/fonts/',
|
||||
content: '${wdir}/videos/',
|
||||
trash: '${wdir}/videos/_trash/',
|
||||
config: '${wdir}/config'
|
||||
};
|
||||
if (typeof defaultCfg.dir !== 'object' || defaultCfg.dir === null || Array.isArray(defaultCfg.dir)) {
|
||||
defaultCfg.dir = defaultDirs;
|
||||
|
|
@ -79,7 +85,7 @@ const loadCfg = () : ConfigObject => {
|
|||
defaultCfg.dir[key] = path.join(workingDir, defaultCfg.dir[key].replace(/^\${wdir}/, ''));
|
||||
}
|
||||
}
|
||||
|
||||
console.log(JSON.stringify(defaultCfg, null, 2));
|
||||
if(!fs.existsSync(defaultCfg.dir.content)){
|
||||
try{
|
||||
fs.ensureDirSync(defaultCfg.dir.content);
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ class Merger {
|
|||
);
|
||||
const trackName = ((this.options.videoTitle ?? vid.lang.name) + (this.options.simul ? ' [Simulcast]' : ' [Uncut]'));
|
||||
args.push('--track-name', `0:"${trackName}"`);
|
||||
args.push('--track-name', `1:"${trackName}"`);
|
||||
//args.push('--track-name', `1:"${trackName}"`);
|
||||
args.push(`--language 1:${vid.lang.code}`);
|
||||
hasVideo = true;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue