Bugs with arguments templates...

Ask for help about FlashGot, no registration needed to post
Post Reply
and casseres

Bugs with arguments templates...

Post by and casseres »

Hello. I use FlashGot with Wget on Windows Platform. I tuned it how written on http://flashgot.net/features:

Code: Select all

Win wget
Executable path:
C:\System32\cmd.exe
Arguments template:
/C start wget -c [--directory-prefix=FOLDER] [--referer=REFERER] [--post-data=POST]
[--load-cookies=CFILE] [--header=Cookie:COOKIE] [--input-file=UFILE]
But I use bat file and actually my settings are these:
[FOLDER] [UFILE] [REFERER] [CFILE] [Cookie:COOKIE] [POST]

I have some troubles that was appeared in two situations:
1. I tried to download this page just for test: http://www.emule-project.net/home/perl/ ... =donations.
Windows command line interpret "&" as separate token and cuts the string. (In my situation referer becomed to "http://www.emule-project.net/home/perl/ ... m=download".)
2. I tried to download some page again, and in post data was a space character, so all params were wrong.

In arguments template we can't use quotes, so I can't fix it even with bat files. I have a simple suggestion that should solve this problem: add an option "Save parameters to file...". And than we can read this file and all parameters as they are and how we need.

And I'll be very thankfull for author if he do it, because my solution is very very ugly, and acutally i don't sure that it even works without bugs, because i delete some code (as i think for wine), and i edited jar file (!), not sources for them (because i don't know technology of writing exts for FF, even Java i don't know)

I show my solution just for those who have similar problem to show how it can be fixed for some time (it very bad solution, don't do it if you really don't need it).

Solution:
1. Edit runNative function in flashgot.jar as shown below. Be carefull, you need to get the same size of file and the end of operation, so edit it in replace mode (hit "Insert" button):

Code: Select all

  
runNative: function(args, blocking, exeFile) {
    const t0 = Date.now();
    try {
fg.clearLog();//rvice.clearLog();//ob
exeFile = this.exeFile;//s.exeFile).exists()
//      || this.createExecutable()) {
        const proc = CC['@mozilla.org/process/util;1'].createInstance(
          CI.nsIProcess);
//r exeFile=CC["@mozilla.org/file/local;1"].createInstance(CI.nsILocalFile);//    
//r path="c:\\notepad.exe";//e.path);
//eFile.initWithPath(path);//M.wine;
//      }
        proc.init(exeFile);
        this.log(args.join("!"));//"\""];this.log(args.join(""));//" -- " +(blocking ? "blocking" : "async") );1
fg.logFlush();//(blocking, args, args.length, {});
proc.run(blocking, args, args.length, {});// {
//        this.log("Warning: native invocation of\n"
//          + exeFile.path
//          + "\nwith arguments <"
//          + args.join(" ")
//          + ">\nreturned " + proc.exitValue);
//      }
//      return proc.exitValue;
//    } else {
//      this.log("Bad executable " + exeFile);
//    }
    } catch(err) {
      this.log("Error running native executable:\n" + exeFile.path + 
        " " + args.join(" ") + "\n" + err.message);
    } finally {
      this.log("Native execution time " + (Date.now() - t0));
    }
    return 0xffffffff;
  }
2. I did that log file clears every time when I download something and all parameters I write in it. Than log flush and my bat is called. You can read settings from log file in your bat file. In log file should be two strings, second string is parameters. Bat code:

Code: Select all

for /F "skip=1 delims=! tokens=1-6" %%a in ('cmd /c type c:\utils\ff\profile\flashgot.log') do (
	%UNIX_UTILS%\wget.exe -c --directory-prefix="%%a" --input-file="%%b" --referer="%%c" --load-cookies="%%d" --header="%%e" --post-data="%%f" --append-output="%TEMP%\LOG\downloads.log"
echo %UNIX_UTILS%\wget.exe -c --directory-prefix="%%a" --input-file="%%b" --referer="%%c" --load-cookies="%%d" --header="%%e" --post-data="%%f" --append-output="%TEMP%\LOG\downloads.log" >"%TEMP%"\LOG\last_download_command_line.log
)
I don't know why, but if use this kind of for statement: "for /F "skip=1 delims=! tokens=1-6" %%a in (c:\utils\ff\profile\flashgot.log)" flashgot.log is not found, but not in bat file i can do with them all i want.

thx.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
and casseres

Re: Bugs with arguments templates...

Post by and casseres »

Sorry, but I was wrong.
When WGet closed and momentally disappeared at first time, I decided to launch it manually with params that was in flashgot.log. I thought that in flashgot.log right parameters, but there params without quotes, and I tried again and again with wrong params. And this technical moment isn't described anywhere.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Post Reply