diff --git a/backend/app.js b/backend/app.js index c234ef1..ed32f1d 100644 --- a/backend/app.js +++ b/backend/app.js @@ -1246,6 +1246,7 @@ async function downloadFileByURL_exec(url, type, options, sessionID = null) { } else if (output) { if (output.length === 0 || output[0].length === 0) { download['error'] = 'No output. Check if video already exists in your archive.'; + logger.warn(`No output received for video download, check if it exists in your archive.`) updateDownloads(); resolve(false); @@ -1296,10 +1297,10 @@ async function downloadFileByURL_exec(url, type, options, sessionID = null) { let is_playlist = file_names.length > 1; - if (options.merged_string) { - let current_merged_archive = fs.readFileSync(fileFolderPath + 'merged.txt', 'utf8'); + if (options.merged_string !== null && options.merged_string !== undefined) { + let current_merged_archive = fs.readFileSync(path.join(fileFolderPath, `merged_${type}.txt`), 'utf8'); let diff = current_merged_archive.replace(options.merged_string, ''); - const archive_path = path.join(archivePath, `archive_${type}.txt`); + const archive_path = options.user ? path.join(fileFolderPath, 'archives', `archive_${type}.txt`) : path.join(archivePath, `archive_${type}.txt`); fs.appendFileSync(archive_path, diff); } @@ -1430,10 +1431,10 @@ async function downloadFileByURL_normal(url, type, options, sessionID = null) { const base_file_name = video_info._filename.substring(fileFolderPath.length, video_info._filename.length); file_uid = registerFileDB(base_file_name, type, multiUserMode); - if (options.merged_string) { - let current_merged_archive = fs.readFileSync(fileFolderPath + 'merged.txt', 'utf8'); + if (options.merged_string !== null && options.merged_string !== undefined) { + let current_merged_archive = fs.readFileSync(path.join(fileFolderPath, `merged_${type}.txt`), 'utf8'); let diff = current_merged_archive.replace(options.merged_string, ''); - const archive_path = req.isAuthenticated() ? path.join(fileFolderPath, 'archives', `archive_${type}.txt`) : path.join(archivePath, `archive_${type}.txt`); + const archive_path = options.user ? path.join(fileFolderPath, 'archives', `archive_${type}.txt`) : path.join(archivePath, `archive_${type}.txt`); fs.appendFileSync(archive_path, diff); } @@ -1534,7 +1535,11 @@ async function generateArgs(url, type, options) { let useYoutubeDLArchive = config_api.getConfigItem('ytdl_use_youtubedl_archive'); if (useYoutubeDLArchive) { - const archive_path = options.user ? path.join(fileFolderPath, 'archives', `archive_${type}.txt`) : path.join(archivePath, `archive_${type}.txt`); + const archive_folder = options.user ? path.join(fileFolderPath, 'archives') : archivePath; + const archive_path = path.join(archive_folder, `archive_${type}.txt`); + + fs.ensureDirSync(archive_folder); + // create archive file if it doesn't exist if (!fs.existsSync(archive_path)) { fs.closeSync(fs.openSync(archive_path, 'w')); @@ -1546,7 +1551,7 @@ async function generateArgs(url, type, options) { fs.closeSync(fs.openSync(blacklist_path, 'w')); } - let merged_path = fileFolderPath + 'merged.txt'; + let merged_path = path.join(fileFolderPath, `merged_${type}.txt`); fs.ensureFileSync(merged_path); // merges blacklist and regular archive let inputPathList = [archive_path, blacklist_path]; @@ -1568,6 +1573,7 @@ async function generateArgs(url, type, options) { } } + logger.verbose(`youtube-dl args being used: ${downloadConfig.join(',')}`); // downloadConfig.map((arg) => `"${arg}"`); resolve(downloadConfig); }); diff --git a/backend/authentication/auth.js b/backend/authentication/auth.js index 7501bdc..0373215 100644 --- a/backend/authentication/auth.js +++ b/backend/authentication/auth.js @@ -430,8 +430,8 @@ exports.deleteUserFile = function(user_uid, file_uid, type, blacklistMode = fals fs.appendFileSync(blacklistPath, line); } } else { - logger.info('Could not find archive file for audio files. Creating...'); - fs.closeSync(fs.openSync(archive_path, 'w')); + logger.info(`Could not find archive file for ${type} files. Creating...`); + fs.ensureFileSync(archive_path); } } } diff --git a/src/app/main/main.component.html b/src/app/main/main.component.html index d5b69b0..13482a5 100644 --- a/src/app/main/main.component.html +++ b/src/app/main/main.component.html @@ -11,10 +11,7 @@