Page 1 of 1

Is it possible to invoke flashgot from another firefox addon

Posted: Mon Nov 18, 2013 3:52 am
by kneo
Hi,

I'm writing a firefox addon, which could generate some addresses dynamically. So I'd like to invoke flashgot to download them from my addon. Is it possible?
BTW: I want it automatic, not generating a dynamic page and asking user to use flashgot manually.

Thanks,
Kneo

Re: Is it possible to invoke flashgot from another firefox a

Posted: Mon Nov 18, 2013 5:51 am
by kneo
I'm able to get flashgot-service successfully right now. I guess it can be used to start a download. Still investigating...

Code: Select all

{Cc, Ci} = require("chrome")
gFlashGotService = Cc["@maone.net/flashgot-service;1"].getService().wrappedJSObject

Re: Is it possible to invoke flashgot from another firefox a

Posted: Mon Nov 18, 2013 8:43 am
by Giorgio Maone
There's no officially supported API, but something like this should work:

Code: Select all


let flashGotService = Cc["@maone.net/flashgot-service;1"].getService().wrappedJSObject

let links = {
  __proto__: Array.prototype, // very important, or use let links=[] and add expandoes later
  document: window.content.document, // optional, the document containing the links
  referrer: window.content.location.href, // optional, or inferred from document
  postData: "param1=something&param2=something+else", // optional
}

links.push({
  href: "http://xyz.com/clip.avi",
  description: "Some description", // optional, used by UI
  fname: "Forced_file_name.avi", // optional, overrides href URL's file name
  postData: "param1=something&param2=something+else", // optional, overrides links.postData
});

links.push(anotherLinkObject);

flashgotService.download(links);

Re: Is it possible to invoke flashgot from another firefox a

Posted: Mon Nov 18, 2013 8:52 am
by kneo
Many thanks! It's exactly what I wanted to know!
Giorgio Maone wrote:There's no officially supported API, but something like this should work:

Code: Select all


let flashGotService = Cc["@maone.net/flashgot-service;1"].getService().wrappedJSObject

let links = {
  __proto__: Array.prototype, // very important, or use let links=[] and add expandoes later
  document: window.content.document, // optional, the document containing the links
  referrer: window.content.location.href, // optional, or inferred from document
  postData: "param1=something&param2=something+else", // optional
}

links.push({
  href: "http://xyz.com/clip.avi",
  description: "Some description", // optional, used by UI
  fname: "Forced_file_name.avi", // optional, overrides href URL's file name
  postData: "param1=something&param2=something+else", // optional, overrides links.postData
});

links.push(anotherLinkObject);

flashgotService.download(links);

Re: Is it possible to invoke flashgot from another firefox a

Posted: Mon Nov 18, 2013 12:32 pm
by kneo
For some reason, the '__proto__: Array.prototype' style doesn't work for me, but '[]' does work.
When I use '__proto__: Array.prototype', the external download tool can be launched, but nothing is downloaded.

Re: Is it possible to invoke flashgot from another firefox a

Posted: Sat Sep 06, 2014 6:59 am
by syed20
I'm able to get flashgot-service successfully right now. I guess it can be used to start a download. Still investigating...