Package Tribler :: Package Core :: Module Download :: Class Download

Class Download

                   DownloadConfig.DownloadConfigInterface --+    
                                                            |    
APIImplementation.DownloadRuntimeConfig.DownloadRuntimeConfig --+
                                                                |
                  APIImplementation.DownloadImpl.DownloadImpl --+
                                                                |
                                                               Download

Representation of a running BT download/upload. A Download implements the DownloadConfigInterface which can be used to change download parameters are runtime (for selected parameters). cf. libtorrent torrent_handle
Instance Methods
 
__init__(self, session, tdef)
Internal constructor
 
get_def(self)
Return the read-only torrent definition (TorrentDef) for this Download.
 
set_state_callback(self, usercallback, getpeerlist=False)
Set a callback for retrieving the state of the download.
 
stop(self)
Stops the Download, i.e.
 
restart(self)
Restarts the stopped Download.
 
set_max_desired_speed(self, direct, speed)
Sets the maximum desired upload/download speed for this Download.
 
get_max_desired_speed(self, direct)
Returns the maximum desired upload/download speed for this Download.
 
get_dest_files(self, exts=None)
Returns the filenames on disk to which this Download saves
 
ask_coopdl_helpers(self, permidlist)
Ask the specified list of peers to help speed up this download
 
stop_coopdl_helpers(self, permidlist)
Ask the specified list of peers to stop helping speed up this ...
 
set_seeding_policy(self, policy)

Inherited from APIImplementation.DownloadRuntimeConfig.DownloadRuntimeConfig: get_alloc_rate, get_alloc_type, get_auto_flush, get_auto_kick, get_breakup_seed_bitfield, get_buffer_reads, get_check_hashes, get_double_check_writes, get_download_slice_size, get_exclude_ips, get_http_timeout, get_keepalive_interval, get_lock_files, get_lock_while_reading, get_max_conns, get_max_conns_to_initiate, get_max_files_open, get_max_message_length, get_max_rate_period, get_max_slice_length, get_max_speed, get_max_uploads, get_min_peers, get_min_uploads, get_mode, get_rarest_first_cutoff, get_rarest_first_priority_cutoff, get_request_backlog, get_rerequest_interval, get_round_robin_period, get_security, get_selected_files, get_snub_time, get_super_seeder, get_tcp_ack_fudge, get_triple_check_writes, get_upload_rate_fudge, get_upload_unit_size, get_ut_pex_max_addrs_from_peer, get_video_event_callback, get_video_events, get_write_buffer_size, set_alloc_rate, set_alloc_type, set_auto_flush, set_auto_kick, set_breakup_seed_bitfield, set_buffer_reads, set_check_hashes, set_double_check_writes, set_download_slice_size, set_exclude_ips, set_http_timeout, set_keepalive_interval, set_lock_files, set_lock_while_reading, set_max_conns, set_max_conns_to_initiate, set_max_files_open, set_max_message_length, set_max_rate_period, set_max_slice_length, set_max_speed, set_max_uploads, set_min_peers, set_min_uploads, set_mode, set_rarest_first_cutoff, set_rarest_first_priority_cutoff, set_request_backlog, set_rerequest_interval, set_round_robin_period, set_saveas, set_security, set_selected_files, set_snub_time, set_super_seeder, set_tcp_ack_fudge, set_triple_check_writes, set_upload_rate_fudge, set_upload_unit_size, set_ut_pex_max_addrs_from_peer, set_video_event_callback, set_video_events, set_write_buffer_size

Inherited from DownloadConfig.DownloadConfigInterface: get_coopdl_coordinator_permid, get_coopdl_role, get_dest_dir, get_live_aux_seeders, get_video_ratelimit, get_video_source, set_coopdl_coordinator_permid, set_dest_dir, set_live_aux_seeders, set_video_ratelimit, set_video_source

Inherited from APIImplementation.DownloadImpl.DownloadImpl: create_engine_wrapper, get_content_dest, get_coopdl_role_object, get_mimetype, network_checkpoint, network_create_engine_wrapper, network_get_persistent_state, network_get_state, network_restart, network_stop, sesscb_get_state_returncallback, set_error, set_filepieceranges, setup, stop_remove

Method Details

__init__(self, session, tdef)
(Constructor)

 
Internal constructor
Parameters:
  • session - Session
  • tdef - TorrentDef
Overrides: APIImplementation.DownloadImpl.DownloadImpl.__init__

get_def(self)

 
Return the read-only torrent definition (TorrentDef) for this Download.
Returns:
A TorrentDef object.
Overrides: APIImplementation.DownloadImpl.DownloadImpl.get_def

set_state_callback(self, usercallback, getpeerlist=False)

 
Set a callback for retrieving the state of the download. This callback will be called immediately with a DownloadState object as first parameter. The callback method must return a tuple (when,getpeerlist) where "when" indicates whether the callback should be called again and represents a number of seconds from now. If "when" <= 0.0 the callback will not be called again. "getpeerlist" is a boolean that indicates whether the DownloadState passed to the callback on the next invocation should contain info about the set of current peers. The callback will be called by a popup thread which can be used indefinitely (within reason) by the higher level code.
Parameters:
  • usercallback - Function that accepts DownloadState as parameter and returns a (float,boolean) tuple.
Overrides: APIImplementation.DownloadImpl.DownloadImpl.set_state_callback

stop(self)

 
Stops the Download, i.e. closes all connections to other peers.
Overrides: APIImplementation.DownloadImpl.DownloadImpl.stop

restart(self)

 
Restarts the stopped Download.
Overrides: APIImplementation.DownloadImpl.DownloadImpl.restart

set_max_desired_speed(self, direct, speed)

 
Sets the maximum desired upload/download speed for this Download.
Parameters:
  • direct - The direction (UPLOAD/DOWNLOAD)
  • speed - The speed in KB/s.
Overrides: APIImplementation.DownloadImpl.DownloadImpl.set_max_desired_speed

get_max_desired_speed(self, direct)

 
Returns the maximum desired upload/download speed for this Download.
Returns:
The previously set speed in KB/s
Overrides: APIImplementation.DownloadImpl.DownloadImpl.get_max_desired_speed

get_dest_files(self, exts=None)

 
Returns the filenames on disk to which this Download saves
Returns:
A list of (filename-in-torrent, disk filename) tuples.
Overrides: APIImplementation.DownloadImpl.DownloadImpl.get_dest_files

stop_coopdl_helpers(self, permidlist)

 
Ask the specified list of peers to stop helping speed up this download