From 768798c6b37bcf71a02df1fa8160d81deb7da915 Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Thu, 30 Jun 2022 01:29:18 -0400 Subject: [PATCH] Fixed issue where one-off playlist downlaods would only include the first video --- backend/db.js | 2 +- backend/downloader.js | 8 ++++++-- backend/subscriptions.js | 2 +- src/app/main/main.component.ts | 7 ++++--- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/backend/db.js b/backend/db.js index aacc6e9..2171a09 100644 --- a/backend/db.js +++ b/backend/db.js @@ -198,7 +198,7 @@ async function registerFileDBManual(file_object) { path_object = path.parse(file_object['path']); file_object['path'] = path.format(path_object); - exports.insertRecordIntoTable('files', file_object, {path: file_object['path']}) + await exports.insertRecordIntoTable('files', file_object, {path: file_object['path']}) return file_object; } diff --git a/backend/downloader.js b/backend/downloader.js index ce4223c..56d2b35 100644 --- a/backend/downloader.js +++ b/backend/downloader.js @@ -203,6 +203,7 @@ async function collectInfo(download_uid) { options.customOutput = category['custom_output']; options.noRelativePath = true; args = await exports.generateArgs(url, type, options, download['user_uid']); + args = utils.filterArgs(args, ['--no-simulate']); info = await exports.getVideoInfoByURL(url, args, download_uid); } @@ -356,7 +357,7 @@ async function downloadQueuedFile(download_uid) { if (file_objs.length > 1) { // create playlist const playlist_name = file_objs.map(file_obj => file_obj.title).join(', '); - container = await db_api.createPlaylist(playlist_name, file_objs.map(file_obj => file_obj.uid), type, download['user_uid']); + container = await db_api.createPlaylist(playlist_name, file_objs.map(file_obj => file_obj.uid), download['user_uid']); } else if (file_objs.length === 1) { container = file_objs[0]; } else { @@ -506,7 +507,10 @@ exports.generateArgs = async (url, type, options, user_uid = null, simulated = f } if (default_downloader === 'yt-dlp') { - downloadConfig.push('--no-clean-infojson'); + downloadConfig = utils.filterArgs(downloadConfig, ['--print-json']); + + // in yt-dlp -j --no-simulate is preferable + downloadConfig.push('--no-clean-info-json', '-j', '--no-simulate'); } } diff --git a/backend/subscriptions.js b/backend/subscriptions.js index 9178804..9fd73c0 100644 --- a/backend/subscriptions.js +++ b/backend/subscriptions.js @@ -407,7 +407,7 @@ async function generateArgsForSubscription(sub, user_uid, redownload = false, de const default_downloader = utils.getCurrentDownloader() || config_api.getConfigItem('ytdl_default_downloader'); if (default_downloader === 'yt-dlp') { - downloadConfig.push('--no-clean-infojson'); + downloadConfig.push('--no-clean-info-json'); } downloadConfig = utils.filterArgs(downloadConfig, ['--write-comments']); diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index 54db31d..fc76cbb 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -306,7 +306,7 @@ export class MainComponent implements OnInit { this.downloadingfile = false; if (!this.autoplay && !this.downloadOnlyMode && !navigate_mode) { // do nothing - this.reloadRecentVideos(); + this.reloadRecentVideos(is_playlist); } else { // if download only mode, just download the file. no redirect if (force_view === false && this.downloadOnlyMode && !this.iOS) { @@ -315,7 +315,7 @@ export class MainComponent implements OnInit { } else { this.downloadFileFromServer(container as DatabaseFile, type); } - this.reloadRecentVideos(); + this.reloadRecentVideos(is_playlist); } else { localStorage.setItem('player_navigator', this.router.url.split(';')[0]); if (is_playlist) { @@ -780,8 +780,9 @@ export class MainComponent implements OnInit { }); } - reloadRecentVideos(): void { + reloadRecentVideos(is_playlist = false): void { this.postsService.files_changed.next(true); + if (is_playlist) this.postsService.playlists_changed.next(true); } getURLArray(url_str: string): Array {