scripts/fahrplan_download: switch to curl

This commit is contained in:
Astro 2011-09-15 21:29:18 +02:00
parent bf55867a8f
commit cde4a112fb
1 changed files with 9 additions and 12 deletions

View File

@ -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) {