Skip to content

Commit

Permalink
Fixed configs
Browse files Browse the repository at this point in the history
  • Loading branch information
padvincenzo authored Jan 24, 2022
1 parent 660e538 commit 4b86f29
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
32 changes: 17 additions & 15 deletions assets/classes/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,37 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

module.exports = class Config {
static configPath = path.join(__dirname, "..", "..", "config.json")
static configPath = path.join(__dirname, "..", "..", "config.json");

static defaultExportPath = path.join(os.homedir(), "speededup")
static defaultFFmpegPath = path.join(__dirname, "..", "ffmpeg", (os.type() == "Windows_NT" ? "ffmpeg.exe" : "ffmpeg"))
static tmpPath = path.join(__dirname, "..", "..", "tmp")
static fragmentListPath = path.join(Config.tmpPath, "list.txt")
static defaultExportPath = path.join(os.homedir(), "speededup");
static defaultFFmpegPath = path.join(__dirname, "..", "ffmpeg", (os.type() == "Windows_NT" ? "ffmpeg.exe" : "ffmpeg"));
static tmpPath = path.join(__dirname, "..", "..", "tmp");
static fragmentListPath = path.join(Config.tmpPath, "list.txt");

static data = null
static data = null;

static load() {
let json = fs.readFileSync(Config.configPath, {encoding: 'utf-8'})
Config.data = JSON.parse(json)
let json = fs.readFileSync(Config.configPath, {encoding: 'utf-8'});
Config.data = JSON.parse(json);

if(Config.data.exportPath == "") {
Config.data.exportPath = Config.defaultExportPath
Config.data.exportPath = Config.defaultExportPath;
}

if(Config.data.ffmpegPath == "" && fs.existsSync(Config.defaultFFmpegPath)) {
Config.data.ffmpegPath = Config.defaultFFmpegPath
Config.data.ffmpegPath = Config.defaultFFmpegPath;
}

if (!fs.existsSync(Config.data.exportPath))
fs.mkdirSync(Config.data.exportPath)
if (!fs.existsSync(Config.data.exportPath)) {
fs.mkdirSync(Config.data.exportPath);
}

if (!fs.existsSync(Config.tmpPath))
fs.mkdirSync(Config.tmpPath)
if (!fs.existsSync(Config.tmpPath)) {
fs.mkdirSync(Config.tmpPath);
}
}

static update(data) {
Config.data = data
Config.data = data;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "silence-speedup",
"productName": "Silence SpeedUp",
"version": "1.2.4",
"version": "1.2.5",
"description": "Speed-up your videos speeding-up (or removing) silences, using FFmpeg. This is an electron-based app.",
"main": "main.js",
"scripts": {
Expand Down

0 comments on commit 4b86f29

Please sign in to comment.