implemented global custom args functionality

fixed bad logic in settings
pull/29/head
Isaac Grynsztein 5 years ago
parent 73d4cca615
commit 946abd2e92

@ -585,6 +585,7 @@ app.post('/api/tomp3', function(req, res) {
var customQualityConfiguration = req.body.customQualityConfiguration; var customQualityConfiguration = req.body.customQualityConfiguration;
var maxBitrate = req.body.maxBitrate; var maxBitrate = req.body.maxBitrate;
var globalArgs = config_api.getConfigItem('ytdl_custom_args');
var customArgs = req.body.customArgs; var customArgs = req.body.customArgs;
var customOutput = req.body.customOutput; var customOutput = req.body.customOutput;
var youtubeUsername = req.body.youtubeUsername; var youtubeUsername = req.body.youtubeUsername;
@ -621,6 +622,11 @@ app.post('/api/tomp3', function(req, res) {
if (!useDefaultDownloadingAgent && customDownloadingAgent === 'aria2c') { if (!useDefaultDownloadingAgent && customDownloadingAgent === 'aria2c') {
downloadConfig.splice(0, 0, '--external-downloader', 'aria2c'); downloadConfig.splice(0, 0, '--external-downloader', 'aria2c');
} }
if (globalArgs && globalArgs !== '') {
// adds global args
downloadConfig = downloadConfig.concat(globalArgs.split(' '));
}
} }
youtubedl.exec(url, downloadConfig, {}, function(err, output) { youtubedl.exec(url, downloadConfig, {}, function(err, output) {
@ -671,6 +677,7 @@ app.post('/api/tomp4', function(req, res) {
var date = Date.now(); var date = Date.now();
var path = videoFolderPath; var path = videoFolderPath;
var videopath = '%(title)s'; var videopath = '%(title)s';
var globalArgs = config_api.getConfigItem('ytdl_custom_args');
var customArgs = req.body.customArgs; var customArgs = req.body.customArgs;
var customOutput = req.body.customOutput; var customOutput = req.body.customOutput;
@ -704,6 +711,11 @@ app.post('/api/tomp4', function(req, res) {
if (!useDefaultDownloadingAgent && customDownloadingAgent === 'aria2c') { if (!useDefaultDownloadingAgent && customDownloadingAgent === 'aria2c') {
downloadConfig.splice(0, 0, '--external-downloader', 'aria2c'); downloadConfig.splice(0, 0, '--external-downloader', 'aria2c');
} }
if (globalArgs && globalArgs !== '') {
// adds global args
downloadConfig = downloadConfig.concat(globalArgs.split(' '));
}
} }
youtubedl.exec(url, downloadConfig, {}, function(err, output) { youtubedl.exec(url, downloadConfig, {}, function(err, output) {

@ -1,8 +1,9 @@
const fs = require('fs'); const fs = require('fs');
let CONFIG_ITEMS = require('./consts.js')['CONFIG_ITEMS']; let CONFIG_ITEMS = require('./consts.js')['CONFIG_ITEMS'];
const debugMode = process.env.YTDL_MODE === 'debug';
let configPath = 'config/default.json'; let configPath = debugMode ? '../src/assets/default.json' : 'config/default.json';
// https://stackoverflow.com/questions/6491463/accessing-nested-javascript-objects-with-string-key // https://stackoverflow.com/questions/6491463/accessing-nested-javascript-objects-with-string-key
Object.byString = function(o, s) { Object.byString = function(o, s) {

@ -801,8 +801,9 @@ export class MainComponent implements OnInit {
getSimulatedOutput() { getSimulatedOutput() {
const customArgsExists = this.customArgsEnabled && this.customArgs; const customArgsExists = this.customArgsEnabled && this.customArgs;
const globalArgsExists = this.globalCustomArgs && this.globalCustomArgs !== '';
const full_string_array: string[] = []; let full_string_array: string[] = [];
const base_string_array = ['youtube-dl', this.url]; const base_string_array = ['youtube-dl', this.url];
if (customArgsExists) { if (customArgsExists) {
@ -861,6 +862,10 @@ export class MainComponent implements OnInit {
full_string_array.push(...additional_params); full_string_array.push(...additional_params);
} }
if (globalArgsExists) {
full_string_array = full_string_array.concat(this.globalCustomArgs.split(' '));
}
this.simulatedOutput = full_string_array.join(' '); this.simulatedOutput = full_string_array.join(' ');
return this.simulatedOutput; return this.simulatedOutput;
} }

@ -211,7 +211,7 @@
</div> </div>
<div class="col-12"> <div class="col-12">
<mat-form-field color="accent"> <mat-form-field color="accent">
<input [disabled]="!new_config['Advanced']['use_default_downloading_agent']" [(ngModel)]="new_config['Advanced']['custom_downloading_agent']" matInput placeholder="Custom agent" required> <input [disabled]="new_config['Advanced']['use_default_downloading_agent']" [(ngModel)]="new_config['Advanced']['custom_downloading_agent']" matInput placeholder="Custom agent" required>
<mat-hint></mat-hint> <mat-hint></mat-hint>
</mat-form-field> </mat-form-field>
</div> </div>

Loading…
Cancel
Save