Giorgio Maone wrote:Almost everything can be done with a bit of work
Done, needs some testing.
What is weird is that axel 2.0 will identify itself as 1.1, but that should not be a problem since many people have 2.4.
Also it is weird that some ^M (carriage returns) appear in the patch, hopefully that won't give you problems (I can try uploading somewhere else).
Code: Select all
diff -r -u t.org//content/flashgot/DMS.js t//content/flashgot/DMS.js
--- t.org//content/flashgot/DMS.js 2010-12-16 15:49:54.000000000 +0800
+++ t//content/flashgot/DMS.js 2010-12-21 14:05:34.023420010 +0800
@@ -212,6 +212,7 @@
}
FlashGotDM.dmtests[this.exeName] = dmtest;
} else dmtest = FlashGotDM.dmtests[this.exeName];
+ if(this.customVersionCheck) this.customVersionCheck(dmtest);
return this._supported = dmtest.indexOf(this.name + "|OK") > -1;
}
,
@@ -639,7 +640,7 @@
// *** Unix-like DMS ***********************************************************
-function FlashGotDMX(name, cmd, argsTemplate) {
+function FlashGotDMX(name, cmd, argsTemplate, versionCmd) {
if (arguments.length != 0) {
this._init(name);
const cmds = FlashGotDMX.prototype.unixCmds;
@@ -647,6 +648,7 @@
this.unixCmd = cmd;
if (argsTemplate) this.argsTemplate = argsTemplate;
this.cookieSupport = /\[.*?(?:CFILE|COOKIE).*?\]/.test(this.argsTemplate);
+ if(versionCmd) FlashGotDMX.prototype.versionCmds[name] = versionCmd;
}
if (fg.isMac) {
this.createJobFile = FlashGotDMMac.prototype.createJobFile;
@@ -658,6 +660,7 @@
FlashGotDMX.prototype.terminal = false;
FlashGotDMX.prototype.askPath = [true, true, true];
FlashGotDMX.prototype.unixCmds = {};
+FlashGotDMX.prototype.versionCmds = {};
FlashGotDMX.prototype.__defineGetter__("unixShell", function() {
var f = CC["@mozilla.org/file/local;1"].createInstance(CI.nsILocalFile);
try {
@@ -677,12 +680,16 @@
FlashGotDMX.prototype.argsTemplate = "[URL]";
FlashGotDMX.prototype.launchSupportTest = function(testFile) {
const cmds = this.unixCmds;
+ const vcmds = this.versionCmds;
var script="(\n";
for (var name in cmds) {
cmd = cmds[name];
script += " which \"" + cmd + "\" && echo '"
+ name + "|OK' || echo '" + name+"|KO'\n";
+ if(vcmds[name]) {
+ script += " which \"" + cmd + "\" && " + vcmds[name] + "\n";
+ }
}
script += ") > '" + testFile.path + "' 2>/dev/null\n";
this.performJob(script, true);
@@ -2109,10 +2116,21 @@
dm.askPath = ASK_NEVER;
}
- dm = new FlashGotDMX("Axel", "axel", '-n 4 [URL]');
+ dm = new FlashGotDMX("Axel", "axel", '-n 4 [URL] [-o FNAME]', 'axel --version');
dm.terminal = true;
+ dm.version = 1;
+ dm.cookieSupport = true; //must be specified, even if not supported
+ dm.customVersionCheck = function(dmtest) {
+ var versionMsg = "Axel version ";
+ var start = dmtest.indexOf(versionMsg);
+ if(start < 0) return;
+ this.version = parseFloat(dmtest.substring(start+versionMsg.length));
+ }
dm.createJob = function(links, opType) {
this.argsTemplate = this.argsTemplate.replace(/^-n \d+/, "-n " + this.getPref("connections", 4));
+ if(this.version >= 2) {
+ this.argsTemplate += " [-H Cookie:COOKIE] [-H Referer:REFERER]";
+ }
return this.__proto__.createJob.call(this, links , opType);
};
Comments welcome.
Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Ubuntu/10.10 Chromium/8.0.552.224 Chrome/8.0.552.224 Safari/534.10