scripts/fahrplan_download: switch to curl
This commit is contained in:
parent
bf55867a8f
commit
cde4a112fb
|
@ -5,6 +5,8 @@ var HTTPS = require('http');
|
|||
var FS = require('fs');
|
||||
var EXPAT = require('node-expat');
|
||||
var El = require('node-xmpp').Element;
|
||||
var async = require('async');
|
||||
var spawn = require('child_process').spawn;
|
||||
|
||||
|
||||
if (process.argv.length !== 5) {
|
||||
|
@ -17,19 +19,14 @@ var conference_id = process.argv[4];
|
|||
var outputDir = '.';
|
||||
var baseDir = '/fahrplan';
|
||||
|
||||
var getQueue = async.queue(function(task, cb) {
|
||||
console.log("GET", task.path);
|
||||
var curl = spawn('curl', ["-u", user + ':' + pass, "https://cccv.pentabarf.org" + task.path]);
|
||||
task.resCb(curl.stdout);
|
||||
curl.on('exit', cb);
|
||||
}, 4);
|
||||
function get(path, cb) {
|
||||
console.log("GET " + path);
|
||||
HTTPS.get({ host: 'cccv.pentabarf.org',
|
||||
path: path,
|
||||
headers: {
|
||||
'Authorization': 'Basic ' + base64(user + ':' + pass)
|
||||
} }, function(res) {
|
||||
if (res.statusCode === 200)
|
||||
cb(res);
|
||||
else
|
||||
console.warn(res.statusCode + ': ' + path);
|
||||
console.log(res.headers);
|
||||
});
|
||||
getQueue.push({ path: path, resCb: cb });
|
||||
}
|
||||
|
||||
function base64(s) {
|
||||
|
|
Loading…
Reference in New Issue