From cde4a112fb879ced1a27ae80e191995c2168fdb0 Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 15 Sep 2011 21:29:18 +0200 Subject: [PATCH] scripts/fahrplan_download: switch to curl --- scripts/fahrplan_download.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/scripts/fahrplan_download.js b/scripts/fahrplan_download.js index 973f4b649..80ba67f8b 100755 --- a/scripts/fahrplan_download.js +++ b/scripts/fahrplan_download.js @@ -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) {