turbo-download-manager icon indicating copy to clipboard operation
turbo-download-manager copied to clipboard

Short API explination

Open jgjake2 opened this issue 9 years ago • 4 comments

I haven't documented the APIs yet. Please open a new bug in the GitHub repo to review the APIs you need to access to.

It would be awesome if you could give short example of how to use the extension's API.

As for the API itself, could you provide a table of just the trigger names (status, count, etc...) and the response type/object structure. I'm assuming most of this is laid out here: /src/lib/common.js but I don't know how to handle the responses without reading the entire source.

I just want to modify video downloadhelper to use TDM instead of the default browser download manager....because it's slow and manages to utterly shit the bed every time the workload gets a little intense.

But the smart title system is fantastic and I want to be able to use the name and link it generates without having to copy everything manually. That can be time consuming when trying to pull 20+ videos/media objects. But it's still faster than watching FF stall out on 50% of DLs without EVER timing out and moving on or restarting >:(

I don't know much about writing extensions, but i'm fairly good at hacking existing ones. I had a similar setup with downloadThemAll, but e10s ruined that and all my other (working) custom/hacked extensions aren't compatible with non-multi-process FF versions; so i'm too lazy to downgrade.

jgjake2 avatar Feb 19 '16 15:02 jgjake2

Well, currently, the only API we have is to send a job request to the TDM. I am open to suggestions though. We can definitely extend this.

I just want to modify video downloadhelper to use TDM instead of the default browser download manager.

Modifying the source code doesn't seem to be a good idea. It would be more useful if you can write an extension to provide this integration as an option. Maybe just overwriting the downloading function of the video downloadhelper ...

Anyhow let me know what API you are going to need

inbasic avatar Feb 24 '16 20:02 inbasic

Ok. Like I said, I'm not an expert with extensions. But with a little help, it shouldn't be too hard.

But once a "helper extension" is written, it wouldn't be unreasonable to try and have the devs integrate it directly with an enable/disable option.

API requirements:

(Just an outline, feel free to add/remove/critique it)

  • Detect if TDM is installed (and what version)
  • Add download(s)
    • Should receive a download id to track it.
  • Check status of download
    • Download size
    • Bytes downloaded
    • Download Rate (average)
      • Download Rate (Each Thread) (average)
    • Download Rate (current instantaneous rate)
      • Download Rate (Each Thread) (current instantaneous rate)
    • File type (if known)
    • Download State (not started/connecting/downloading/complete/paused/fail/error/etc...)
    • Has first byte (true/false)
    • Has last byte (true/false)
    • Thread Count
    • Estimated time left
  • Attach event listeners to downloads for key events
    • DL received first byte
    • DL received last byte
    • DL Failure/Error
    • DL Complete (all bytes written to disk)
    • DL Thread Part Complete
    • DL Paused
    • DL Canceled
  • Pause download
  • Resume Download
  • Add Thread to download
  • Remove thread from download
    • (Option 1) Try and complete chunk first
    • (Option 2) Force termination of thread
  • Get a list of downloads

Possible options to add to TDM:

  • Max thread chunk size:
    • Target size of chunk before spawning a new thread/request. This would help sites that reduce DL speed after a predetermined amount of time (some video hosting sites do this and have their players download in chunks to prevent direct downloads).
  • Thread timeout
    • Max thread download time before spawning a new thread (see reason above)
  • Min thread download rate
    • Min download rate for thread (averaged over something like 30 seconds) before spawning a new thread.

jgjake2 avatar Feb 25 '16 12:02 jgjake2

Is there any reason why you need this comprehensive list of APIs? With them you can actually write a whole new UI for TDM. At this point I am more interested to provide only the necessary APIs, although I am open to pull request to extend this.

inbasic avatar Feb 27 '16 11:02 inbasic

Be careful @jgjake2 , @inbasic will turn you into a developer before you know it! :fearful:

Grossdm avatar Aug 02 '16 20:08 Grossdm