Fix CLI import script
This commit is contained in:
parent
47dc5db9c3
commit
de29e90c37
|
@ -72,11 +72,12 @@ async function run (url: string, user: UserInfo) {
|
||||||
|
|
||||||
const youtubeDL = await safeGetYoutubeDL()
|
const youtubeDL = await safeGetYoutubeDL()
|
||||||
|
|
||||||
const options = [ '-j', '--flat-playlist', '--playlist-reverse', ...command.args ]
|
let info = await getYoutubeDLInfo(youtubeDL, program['targetUrl'], command.args)
|
||||||
|
|
||||||
youtubeDL.getInfo(program['targetUrl'], options, processOptions, async (err, info) => {
|
if (info?.title === 'Uploads') {
|
||||||
if (err) {
|
console.log('Fixing URL to %s.', info.url)
|
||||||
exitError(err.stderr + ' ' + err.message)
|
|
||||||
|
info = await getYoutubeDLInfo(youtubeDL, info.url, command.args)
|
||||||
}
|
}
|
||||||
|
|
||||||
let infoArray: any[]
|
let infoArray: any[]
|
||||||
|
@ -107,7 +108,6 @@ async function run (url: string, user: UserInfo) {
|
||||||
|
|
||||||
log.info('Video/s for user %s imported: %s', user.username, program['targetUrl'])
|
log.info('Video/s for user %s imported: %s', user.username, program['targetUrl'])
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function processVideo (parameters: {
|
function processVideo (parameters: {
|
||||||
|
@ -397,3 +397,15 @@ function exitError (message: string, ...meta: any[]) {
|
||||||
console.error(message, ...meta)
|
console.error(message, ...meta)
|
||||||
process.exit(-1)
|
process.exit(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getYoutubeDLInfo (youtubeDL: any, url: string, args: string[]) {
|
||||||
|
return new Promise<any>((res, rej) => {
|
||||||
|
const options = [ '-j', '--flat-playlist', '--playlist-reverse', ...args ]
|
||||||
|
|
||||||
|
youtubeDL.getInfo(url, options, processOptions, async (err, info) => {
|
||||||
|
if (err) return rej(err)
|
||||||
|
|
||||||
|
return res(info)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue