deluge.httpdownloader

deluge.httpdownloader.download_file(url, filename, callback=None, headers=None)

Downloads a file from a specific URL and returns a Deferred. You can also specify a callback function to be called as parts are received.

Parameters:
  • url (string) – the url to download from
  • filename (string) – the filename to save the file as
  • callback (function) – a function to be called when a part of data is received, it’s signature should be: func(data, current_length, total_length)
  • headers (dictionary) – any optional headers to send
Returns:

the filename of the downloaded file

Return type:

Deferred

Raises t.w.e.PageRedirect:
 

when server responds with a temporary redirect or permanently moved.

Raises t.w.e.Error:
 

for all other HTTP response errors (besides OK)

Previous topic

deluge.event

Next topic

deluge.log

This Page