Package Tribler :: Package Core :: Module DownloadState :: Class DownloadState

Class DownloadState

Base.Serializable --+
                    |
                   DownloadState

Contains a snapshot of the state of the Download at a specific point in time. Using a snapshot instead of providing live data and protecting access via locking should be faster. cf. libtorrent torrent_status
Instance Methods
 
__init__(self, download, status, error, progress, stats=None, filepieceranges=None, logmsgs=None, coopdl_helpers=[], coopdl_coordinator=None, peerid=None, videoinfo=None)
Internal constructor.
 
get_peerid(self)
Returns our own peer id in this swarm, or None if unknown.
 
get_videoinfo(self)
Returns information about the video being streamed, or {} if unknown.
 
get_download(self)
Returns the Download object of which this is the state
 
get_progress(self)
The general progress of the Download as a percentage.
 
get_status(self)
Returns the status of the torrent.
 
get_error(self)
Returns the Exception that caused the download to be moved to DLSTATUS_STOPPED_ON_ERROR status.
 
get_current_speed(self, direct)
Returns the current up or download speed.
 
get_eta(self)
Returns the estimated time to finish of download.
 
get_num_peers(self)
Returns the download's number of active connections.
 
get_num_seeds_peers(self)
Returns the sum of the number of seeds and peers.
 
get_pieces_complete(self)
Returns a list of booleans indicating whether we have completely received that piece of the content.
 
get_vod_prebuffering_progress(self)
Returns the percentage of prebuffering for Video-On-Demand already completed.
 
is_vod(self)
Returns if this download is currently in vod mode
 
get_vod_playable(self)
Returns whether or not the Download started in Video-On-Demand mode has sufficient prebuffer and download speed to be played out to the user.
 
get_vod_playable_after(self)
Returns the estimated time until the Download started in Video-On-Demand mode can be started to play out to the user.
 
get_vod_stats(self)
Returns a dictionary of collected VOD statistics.
 
get_log_messages(self)
Returns the last 10 logged non-fatal error messages.
 
get_peerlist(self)
Returns a list of dictionaries, one for each connected peer containing the statistics for that peer.
 
get_coopdl_helpers(self)
Returns the peers currently helping.
 
get_coopdl_coordinator(self)
Returns the permid of the coordinator when helping that peer...
Method Details

__init__(self, download, status, error, progress, stats=None, filepieceranges=None, logmsgs=None, coopdl_helpers=[], coopdl_coordinator=None, peerid=None, videoinfo=None)
(Constructor)

 
Internal constructor.
Parameters:
  • download - The Download this state belongs too.
  • status - The status of the Download (DLSTATUS_*)
  • progress - The general progress of the Download.
  • stats - The BT engine statistics for the Download.
  • filepieceranges - The range of pieces that we are interested in. The get_pieces_complete() returns only completeness information about this range. This is used for playing a video in a multi-torrent file.
  • logmsgs - A list of messages from the BT engine which may be of
  • peerid - Our own peer id in the BT download swarm. interest to the user. E.g. connection to tracker failed.
  • videoinfo - Dictionary with video information.
Overrides: Base.Serializable.__init__

get_peerid(self)

 
Returns our own peer id in this swarm, or None if unknown.
Returns:
String or None.

get_videoinfo(self)

 
Returns information about the video being streamed, or {} if unknown.
Returns:
Dict.

get_progress(self)

 
The general progress of the Download as a percentage. When status is * DLSTATUS_HASHCHECKING it is the percentage of already downloaded content checked for integrity. * DLSTATUS_DOWNLOADING/SEEDING it is the percentage downloaded.
Returns:
Progress as a float (0..1).

get_status(self)

 
Returns the status of the torrent.
Returns:
DLSTATUS_*

get_error(self)

 
Returns the Exception that caused the download to be moved to DLSTATUS_STOPPED_ON_ERROR status.
Returns:
Exception

get_current_speed(self, direct)

 
Returns the current up or download speed.
Returns:
The speed in KB/s, as float.

get_eta(self)

 
Returns the estimated time to finish of download.
Returns:
The time in ?, as ?.

get_num_peers(self)

 
Returns the download's number of active connections. This is used to see if there is any progress when non-fatal errors have occured (e.g. tracker timeout).
Returns:
Boolean.

get_num_seeds_peers(self)

 
Returns the sum of the number of seeds and peers. This function works only if the Download.set_state_callback() / Session.set_download_states_callback() was called with the getpeerlist parameter set to True, otherwise returns (None,None)
Returns:
A tuple (num seeds, num peers)

get_pieces_complete(self)

 
Returns a list of booleans indicating whether we have completely received that piece of the content. The list of pieces for which we provide this info depends on which files were selected for download using DownloadStartupConfig.set_selected_files().
Returns:
A list of booleans

get_vod_prebuffering_progress(self)

 
Returns the percentage of prebuffering for Video-On-Demand already completed.
Returns:
A float (0..1)

is_vod(self)

 
Returns if this download is currently in vod mode
Returns:
A Boolean

get_vod_playable(self)

 
Returns whether or not the Download started in Video-On-Demand mode has sufficient prebuffer and download speed to be played out to the user.
Returns:
Boolean.

get_vod_playable_after(self)

 
Returns the estimated time until the Download started in Video-On-Demand mode can be started to play out to the user.
Returns:
A number of seconds.

get_vod_stats(self)

 
Returns a dictionary of collected VOD statistics. The keys contained are:
'played' = number of pieces played
'late' = number of pieces arrived after they were due
'dropped' = number of pieces lost
'stall' = estimation of time the player stalled, waiting for pieces (seconds)
'pos' = playback position
'prebuf' = amount of prebuffering time that was needed (seconds,
           set when playback starts)
, or no keys if no VOD is in progress.
Returns:
Dict.

get_log_messages(self)

 
Returns the last 10 logged non-fatal error messages.
Returns:
A list of (time,msg) tuples. Time is Python time() format.

get_peerlist(self)

 
Returns a list of dictionaries, one for each connected peer containing the statistics for that peer. In particular, the dictionary contains the keys:
'id' = PeerID or 'http seed'
'ip' = IP address as string or URL of httpseed
'optimistic' = True/False
'direction' = 'L'/'R' (outgoing/incoming)
'uprate' = Upload rate in KB/s
'uinterested' = Upload Interested: True/False
'uchoked' = Upload Choked: True/False
'downrate' = Download rate in KB/s
'dinterested' = Download interested: True/Flase
'dchoked' = Download choked: True/False
'snubbed' = Download snubbed: True/False
'utotal' = Total uploaded from peer in KB
'dtotal' = Total downloaded from peer in KB
'completed' = Fraction of download completed by peer (0-1.0) 
'speed' = The peer's current total download speed (estimated)

get_coopdl_helpers(self)

 
Returns the peers currently helping.
Returns:
A list of PermIDs.

get_coopdl_coordinator(self)

 
Returns the permid of the coordinator when helping that peer in a cooperative download
Returns:
A PermID.