Skip to content

Commit

Permalink
feat: only print to stdout if process is piped
Browse files Browse the repository at this point in the history
close #91
  • Loading branch information
fent committed Dec 13, 2018
1 parent 67626cf commit 9a3915b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bin/ytdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const opts = require('commander')
.option('-r, --range <INT>..<INT>',
'Byte range to download, ie 10355705-12452856')
.option('-b, --begin <INT>', 'Time to begin video, format by 1:30.123 and 1m30s')
.option('-o, --output <FILE>', 'Save to file, template by {prop}, default: stdout')
.option('-o, --output <FILE>', 'Save to file, template by {prop}, default: stdout or {title}')
.option('--filter <STR>',
'Can be video, videoonly, audio, audioonly',
/^(video|audio)(only)?$/)
Expand Down Expand Up @@ -137,6 +137,8 @@ if (opts.infoJson) {
if (ext && !opts.quality && !opts.filterContainer) {
opts.filterContainer = '^' + ext.slice(1) + '$';
}
} else if (process.stdout.isTTY) {
output = '{title}';
}

const ytdlOptions = {};
Expand Down

0 comments on commit 9a3915b

Please sign in to comment.