-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfbdl
executable file
·33 lines (29 loc) · 878 Bytes
/
fbdl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/local/bin/node
var spawn = require('child_process').spawn;
function downloadVid(vidURL){
process.stdout.write('\nyoutube-dl -f "progressive_hd_src" ' + vidURL.split("&")[0] + "\n");
yt = spawn("youtube-dl",["-f","progressive_hd_src",vidURL.split("&")[0]]);
yt.stdout.on('data', function (data) {
process.stdout.write(data);
});
yt.on('close', function (code) {
process.stdout.write('child process exited with code ' + code + "\n");
});
}
if(process.argv.length==3){
downloadVid (process.argv[2]);
}else if(process.argv.length==2){
pbpaste = spawn("pbpaste");
pbpaste.stdout.on('data', function (data) {
if(data.length>20){
downloadVid (data.toString());
}
});
}
/*console.log(process.argv);
process.stdin.on('readable', function() {
var chunk = process.stdin.read();
if (chunk !== null) {
console.log('data: ' + chunk.length);
}
});*/