@ -279,7 +279,9 @@ async function downloadQueuedFile(download_uid) {
} else if ( output ) {
if ( output . length === 0 || output [ 0 ] . length === 0 ) {
// ERROR!
logger . warn ( ` No output received for video download, check if it exists in your archive. ` )
const error _message = ` No output received for video download, check if it exists in your archive. ` ;
await handleDownloadError ( download _uid , error _message ) ;
logger . warn ( error _message ) ;
resolve ( false ) ;
return ;
}
@ -344,9 +346,10 @@ async function downloadQueuedFile(download_uid) {
}
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 = download [ 'user_uid' ] ? path . join ( fileFolderPath , 'archives' , ` archive_ ${ type } .txt ` ) : path . join ( archivePath , ` archive_ ${ type } .txt ` ) ;
const archive _folder = getArchiveFolder ( fileFolderPath , options , download [ 'user_uid' ] ) ;
const current _merged _archive = fs . readFileSync ( path . join ( archive _folder , ` merged_ ${ type } .txt ` ) , 'utf8' ) ;
const diff = current _merged _archive . replace ( options . merged _string , '' ) ;
const archive _path = path . join ( archive _folder , ` archive_ ${ type } .txt ` ) ;
fs . appendFileSync ( archive _path , diff ) ;
}
@ -455,23 +458,16 @@ exports.generateArgs = async (url, type, options, user_uid = null, simulated = f
let useYoutubeDLArchive = config _api . getConfigItem ( 'ytdl_use_youtubedl_archive' ) ;
if ( useYoutubeDLArchive ) {
let archive _folder = null ;
if ( options . customArchivePath ) {
archive _folder = path . join ( options . customArchivePath ) ;
} else if ( user _uid ) {
archive _folder = path . join ( fileFolderPath , 'archives' ) ;
} else {
archive _folder = path . join ( archivePath ) ;
}
const archive _folder = getArchiveFolder ( fileFolderPath , options , user _uid ) ;
const archive _path = path . join ( archive _folder , ` archive_ ${ type } .txt ` ) ;
await fs . ensureDir ( archive _folder ) ;
await fs . ensureFile ( archive _path ) ;
le t blacklist _path = path . join ( archive _folder , ` blacklist_ ${ type } .txt ` ) ;
const blacklist _path = path . join ( archive _folder , ` blacklist_ ${ type } .txt ` ) ;
await fs . ensureFile ( blacklist _path ) ;
let merged _path = path . join ( fileFolderPath , ` merged_ ${ type } .txt ` ) ;
const merged _path = path . join ( archive _folder , ` merged_ ${ type } .txt ` ) ;
await fs . ensureFile ( merged _path ) ;
// merges blacklist and regular archive
let inputPathList = [ archive _path , blacklist _path ] ;
@ -623,4 +619,14 @@ exports.generateNFOFile = (info, output_path) => {
const doc = create ( nfo _obj ) ;
const xml = doc . end ( { prettyPrint : true } ) ;
fs . writeFileSync ( output _path , xml ) ;
}
function getArchiveFolder ( fileFolderPath , options , user _uid ) {
if ( options . customArchivePath ) {
return path . join ( options . customArchivePath ) ;
} else if ( user _uid ) {
return path . join ( fileFolderPath , 'archives' ) ;
} else {
return path . join ( archivePath ) ;
}
}