Fix --format bug
This commit is contained in:
parent
49e373d079
commit
a06b698d85
1 changed files with 12 additions and 6 deletions
|
@ -14,10 +14,10 @@ const argv = yargs.options({
|
||||||
videoUrls: { type: 'array', demandOption: true },
|
videoUrls: { type: 'array', demandOption: true },
|
||||||
username: { type: 'string', demandOption: true },
|
username: { type: 'string', demandOption: true },
|
||||||
outputDirectory: { type: 'string', default: 'videos' },
|
outputDirectory: { type: 'string', default: 'videos' },
|
||||||
format: {alias:"f",
|
format: { alias:"f",
|
||||||
describe: 'Expose youtube-dl --format option, for details see\n https://github.com/ytdl-org/youtube-dl/blob/master/README.md#format-selection',
|
describe: 'Expose youtube-dl --format option, for details see\n https://github.com/ytdl-org/youtube-dl/blob/master/README.md#format-selection',
|
||||||
type:'string',
|
type:'string',
|
||||||
default:'best'
|
demandOption: false
|
||||||
}
|
}
|
||||||
}).argv;
|
}).argv;
|
||||||
|
|
||||||
|
@ -111,8 +111,14 @@ async function rentVideoForLater(videoUrls: string[], username: string, outputDi
|
||||||
const hlsUrl = amsUrl.substring(0, amsUrl.lastIndexOf('/')) + '/manifest(format=m3u8-aapl)';
|
const hlsUrl = amsUrl.substring(0, amsUrl.lastIndexOf('/')) + '/manifest(format=m3u8-aapl)';
|
||||||
|
|
||||||
console.log('Spawning youtube-dl with cookie and HLS URL...');
|
console.log('Spawning youtube-dl with cookie and HLS URL...');
|
||||||
const youtubedlCmd = 'youtube-dl --no-call-home --no-warnings ' +
|
let format = ''
|
||||||
`-f "${argv.format}" --output "${outputDirectory}/${title}.mp4" --add-header Cookie:"${cookie}" "${hlsUrl}"`;
|
if (argv.format) {
|
||||||
|
format = `-f "${argv.format}"`
|
||||||
|
}
|
||||||
|
|
||||||
|
const youtubedlCmd = 'youtube-dl --no-call-home --no-warnings ' + format +
|
||||||
|
` --output "${outputDirectory}/${title}.mp4" --add-header Cookie:"${cookie}" "${hlsUrl}"`
|
||||||
|
|
||||||
// console.log(`\n\n[DEBUG] Invoking youtube-dl: ${youtubedlCmd}\n\n`);
|
// console.log(`\n\n[DEBUG] Invoking youtube-dl: ${youtubedlCmd}\n\n`);
|
||||||
var result = execSync(youtubedlCmd, { stdio: 'inherit' });
|
var result = execSync(youtubedlCmd, { stdio: 'inherit' });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue