From 1ac6683f3346d2f5d247ebd35606a3e8e607a592 Mon Sep 17 00:00:00 2001 From: Isaac Grynsztein Date: Sun, 26 Apr 2020 21:37:08 -0400 Subject: [PATCH] Custom quality configurations now use the old downloading method to avoid errors postsservice now does jwt auth after checking if multi user mode is enabled Minor update to user profile UI Added setting for enabling and disabling multi user mode --- backend/app.js | 6 +-- .../user-profile-dialog.component.html | 12 ++++- src/app/posts.services.ts | 44 ++++++++++++++----- src/app/settings/settings.component.html | 7 ++- 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/backend/app.js b/backend/app.js index 60ff1a7..224e05b 100644 --- a/backend/app.js +++ b/backend/app.js @@ -1411,9 +1411,9 @@ async function generateArgs(url, type, options) { downloadConfig = customArgs.split(' '); } else { if (customQualityConfiguration) { - qualityPath = customQualityConfiguration; + qualityPath = `-f ${customQualityConfiguration}`; } else if (selectedHeight && selectedHeight !== '' && !is_audio) { - qualityPath = `-f bestvideo[height=${selectedHeight}]+bestaudio/best[height=${selectedHeight}]`; + qualityPath = `-f '(mp4)[height=${selectedHeight}]'`; } else if (maxBitrate && is_audio) { qualityPath = `--audio-quality ${maxBitrate}` } @@ -1783,7 +1783,7 @@ app.post('/api/tomp4', optionalJwt, async function(req, res) { const is_playlist = url.includes('playlist'); let result_obj = null; - if (is_playlist) + if (is_playlist || options.customQualityConfiguration) result_obj = await downloadFileByURL_exec(url, 'video', options, req.query.sessionID); else result_obj = await downloadFileByURL_normal(url, 'video', options, req.query.sessionID); diff --git a/src/app/dialogs/user-profile-dialog/user-profile-dialog.component.html b/src/app/dialogs/user-profile-dialog/user-profile-dialog.component.html index 26b621c..fd9be71 100644 --- a/src/app/dialogs/user-profile-dialog/user-profile-dialog.component.html +++ b/src/app/dialogs/user-profile-dialog/user-profile-dialog.component.html @@ -11,8 +11,7 @@
Created: {{postsService.user.created ? postsService.user.created : 'N/A'}}
-
- +
@@ -21,3 +20,12 @@ + + +
+
+ + +
+
+
diff --git a/src/app/posts.services.ts b/src/app/posts.services.ts index 00f02e0..d188006 100644 --- a/src/app/posts.services.ts +++ b/src/app/posts.services.ts @@ -33,6 +33,11 @@ export class PostsService implements CanActivate { isLoggedIn = false; token = null; user = null; + + reload_config = new BehaviorSubject(false); + config_reloaded = new BehaviorSubject(false); + + config = null; constructor(private http: HttpClient, private router: Router, @Inject(DOCUMENT) private document: Document, public snackBar: MatSnackBar) { console.log('PostsService Initialized...'); @@ -53,17 +58,25 @@ export class PostsService implements CanActivate { }), }; - // login stuff - - if (localStorage.getItem('jwt_token')) { - this.token = localStorage.getItem('jwt_token'); - this.httpOptions = { - params: new HttpParams({ - fromString: `apiKey=${this.auth_token}&sessionID=${this.session_id}&jwt=${this.token}` - }), - }; - this.jwtAuth(); - } + // get config + this.loadNavItems().subscribe(res => { + const result = !this.debugMode ? res['config_file'] : res; + if (result) { + this.config = result['YoutubeDLMaterial']; + if (this.config['Advanced']['multi_user_mode']) { + // login stuff + if (localStorage.getItem('jwt_token')) { + this.token = localStorage.getItem('jwt_token'); + this.httpOptions = { + params: new HttpParams({ + fromString: `apiKey=${this.auth_token}&sessionID=${this.session_id}&jwt=${this.token}` + }), + }; + this.jwtAuth(); + } + } + } + }); } canActivate(route, state): Promise { return new Promise(resolve => { @@ -85,6 +98,15 @@ export class PostsService implements CanActivate { return this.http.get(url + 'geturl'); } + reloadConfig() { + this.loadNavItems().subscribe(res => { + const result = !this.debugMode ? res['config_file'] : res; + if (result) { + this.config = result['YoutubeDLMaterial']; + } + }); + } + getVideoFolder() { return this.http.get(this.startPath + 'videofolder'); } diff --git a/src/app/settings/settings.component.html b/src/app/settings/settings.component.html index 2335182..e2e9102 100644 --- a/src/app/settings/settings.component.html +++ b/src/app/settings/settings.component.html @@ -166,7 +166,7 @@ Allow multi-download mode
- Require pin for settings + Require pin for settings
@@ -252,9 +252,12 @@ -
+
Allow advanced download
+
+ Multi-user mode +