deluge.maketorrent

exception deluge.maketorrent.InvalidPath

Bases: exceptions.Exception

Raised when an invalid path is supplied

exception deluge.maketorrent.InvalidPieceSize

Bases: exceptions.Exception

Raised when an invalid piece size is set. Piece sizes must be multiples of 16KiB.

class deluge.maketorrent.TorrentMetadata

Bases: object

This class is used to create .torrent files.

** Usage **

>>> t = TorrentMetadata()
>>> t.data_path = "/tmp/torrent"
>>> t.comment = "My Test Torrent"
>>> t.trackers = [["http://tracker.openbittorent.com"]]
>>> t.save("/tmp/test.torrent")
comment
Comment is some extra info to be stored in the torrent. This is typically an informational string.
data_path
The path to the files that the torrent will contain. It can be either a file or a folder. This property needs to be set before the torrent file can be created and saved.
get_comment()
Comment is some extra info to be stored in the torrent. This is typically an informational string.
get_data_path()
The path to the files that the torrent will contain. It can be either a file or a folder. This property needs to be set before the torrent file can be created and saved.
get_pad_files()
If this is True, padding files will be added to align files on piece boundaries.
get_piece_size()
The size of pieces in bytes. The size must be a multiple of 16KiB. If you don’t set a piece size, one will be automatically selected to produce a torrent with less than 1024 pieces or the smallest possible with a 8192KiB piece size.
get_private()

Private torrents only announce to the tracker and will not use DHT or Peer Exchange.

See: http://bittorrent.org/beps/bep_0027.html

get_trackers()

The announce trackers is a list of lists.

See: http://bittorrent.org/beps/bep_0012.html

get_webseeds()

The web seeds can either be: Hoffman-style: http://bittorrent.org/beps/bep_0017.html or, GetRight-style: http://bittorrent.org/beps/bep_0019.html

If the url ends in ‘.php’ then it will be considered Hoffman-style, if not it will be considered GetRight-style.

pad_files
If this is True, padding files will be added to align files on piece boundaries.
piece_size
The size of pieces in bytes. The size must be a multiple of 16KiB. If you don’t set a piece size, one will be automatically selected to produce a torrent with less than 1024 pieces or the smallest possible with a 8192KiB piece size.
private

Private torrents only announce to the tracker and will not use DHT or Peer Exchange.

See: http://bittorrent.org/beps/bep_0027.html

save(torrent_path, progress=None)

Creates and saves the torrent file to path.

Parameters:
  • torrent_path (string) – where to save the torrent file
  • progress (function(num_completed, num_pieces)) – a function to be called when a piece is hashed
Raises InvalidPath:
 

if the data_path has not been set

set_comment(comment)
Parameter:comment (string) – an informational string
set_data_path(path)
Parameter:path (string) – the path to the data
Raises InvalidPath:
 if the path is not found
set_pad_files(pad)
Parameter:pad (bool) – set True to align files on piece boundaries
set_piece_size(size)
Parameter:size (int) – the desired piece size in KiBs
Raises InvalidPieceSize:
 if the piece size is not a multiple of 16 KiB
set_private(private)
Parameter:private (bool) – True if the torrent is to be private
set_trackers(trackers)
Parameter:trackers (list of list of strings) – a list of lists of trackers, each list is a tier
set_webseeds(webseeds)
Parameter:webseeds (list of urls) – the webseeds which can be either Hoffman or GetRight style
trackers

The announce trackers is a list of lists.

See: http://bittorrent.org/beps/bep_0012.html

webseeds

The web seeds can either be: Hoffman-style: http://bittorrent.org/beps/bep_0017.html or, GetRight-style: http://bittorrent.org/beps/bep_0019.html

If the url ends in ‘.php’ then it will be considered Hoffman-style, if not it will be considered GetRight-style.

Previous topic

deluge.main

Next topic

deluge.metafile

This Page