Class AddTorrentParams

java.lang.Object
com.frostwire.jlibtorrent.AddTorrentParams

public final class AddTorrentParams extends Object
The AddTorrentParams is a parameter pack for adding torrents to a session. The key fields when adding a torrent are:
  • ti - when you have a .torrent file
  • url - when you have a magnet link or http URL to the .torrent file
  • info_hash - when all you have is an info-hash (this is similar to a magnet link)
One of those fields need to be set. Another mandatory field is savePath(). The AddTorrentParams object is passed into one of the SessionHandle.addTorrent(AddTorrentParams, ErrorCode) overloads or SessionHandle.asyncAddTorrent(AddTorrentParams).

If you only specify the info-hash, the torrent file will be downloaded from peers, which requires them to support the metadata extension. It also takes an optional name() argument. This may be left empty in case no name should be assigned to the torrent. In case it's not, the name is used for the torrent as long as it doesn't have metadata.

  • Constructor Details

    • AddTorrentParams

      public AddTorrentParams(add_torrent_params p)
      The native object
      Parameters:
      p - the native object
    • AddTorrentParams

      public AddTorrentParams()
      Creates an empty parameters object with the default storage.
  • Method Details

    • swig

      public add_torrent_params swig()
      Returns:
      the native object
    • version

      public int version()
      Filled in by the constructor. It is used for forward binary compatibility.
      Returns:
      the version
    • torrentInfo

      public TorrentInfo torrentInfo()
      TorrentInfo object with the torrent to add.
      Returns:
      the torrent info or null if not set
    • torrentInfo

      public void torrentInfo(TorrentInfo ti)
      TorrentInfo object with the torrent to add.
      Parameters:
      ti - the torrent info
    • trackers

      public ArrayList<String> trackers()
      If the torrent doesn't have a tracker, but relies on the DHT to find peers, the trackers(List) can specify tracker URLs for the torrent.
      Returns:
      the list of trackers
    • trackers

      public void trackers(List<String> value)
      If the torrent doesn't have a tracker, but relies on the DHT to find peers, this method can specify tracker URLs for the torrent.
      Parameters:
      value - the list of trackers
    • trackerTiers

      public ArrayList<Integer> trackerTiers()
      The tiers the URLs in trackers() belong to. Trackers belonging to different tiers may be treated differently, as defined by the multi tracker extension. This is optional, if not specified trackers are assumed to be part of tier 0, or whichever the last tier was as iterating over the trackers.
      Returns:
      the list of trackers tiers
    • trackerTiers

      public void trackerTiers(List<Integer> value)
      The tiers the URLs in trackers() belong to. Trackers belonging to different tiers may be treated differently, as defined by the multi tracker extension. This is optional, if not specified trackers are assumed to be part of tier 0, or whichever the last tier was as iterating over the trackers.
      Parameters:
      value - the list of trackers tiers
    • dhtNodes

      public ArrayList<Pair<String,Integer>> dhtNodes()
      A list of hostname and port pairs, representing DHT nodes to be added to the session (if DHT is enabled). The hostname may be an IP address.
      Returns:
      the list of DHT nodes
    • get_verified_leaf_hashes

      public List<List<Boolean>> get_verified_leaf_hashes()
    • dhtNodes

      public void dhtNodes(List<Pair<String,Integer>> value)
      A list of hostname and port pairs, representing DHT nodes to be added to the session (if DHT is enabled). The hostname may be an IP address.
      Parameters:
      value - the list of DHT nodes
    • name

      public String name()
      Returns:
      the name
    • name

      public void name(String value)
      Parameters:
      value - the name
    • savePath

      public String savePath()
      The path where the torrent is or will be stored. Note that this may also be stored in resume data. If you want the save path saved in the resume data to be used, you need to set the flag_use_resume_save_path flag.

      .. note:: On windows this path (and other paths) are interpreted as UNC paths. This means they must use backslashes as directory separators

      Returns:
      the save path
    • savePath

      public void savePath(String value)
      The path where the torrent is or will be stored. Note that this may also be stored in resume data. If you want the save path saved in the resume data to be used, you need to set the flag_use_resume_save_path flag.

      .. note:: On windows this path (and other paths) are interpreted as UNC paths. This means they must use backslashes as directory separators

      Parameters:
      value - the save path
    • storageMode

      public StorageMode storageMode()
      Returns:
      the storage mode
      See Also:
    • storageMode

      public void storageMode(StorageMode value)
      Parameters:
      value - the storage mode
      See Also:
    • trackerId

      public String trackerId()
      The default tracker id to be used when announcing to trackers. By default this is empty, and no tracker ID is used, since this is an optional argument. If a tracker returns a tracker ID, that ID is used instead of this.
      Returns:
      the trackerid url parameter
    • trackerId

      public void trackerId(String value)
      The default tracker id to be used when announcing to trackers. By default this is empty, and no tracker ID is used, since this is an optional argument. If a tracker returns a tracker ID, that ID is used instead of this.
      Parameters:
      value - the trackerid url parameter
    • getInfoHashes

      public InfoHash getInfoHashes()
      Set this to the info hash of the torrent to add in case the info-hash is the only known property of the torrent. i.e. you don't have a .torrent file nor a magnet link.
      Returns:
      the info-hash
    • setInfoHashes

      public void setInfoHashes(InfoHash value)
      Set this to the info hash of the torrent to add in case the info-hash is the only known property of the torrent. i.e. you don't have a .torrent file nor a magnet link.
      Parameters:
      value - the info-hash
    • maxUploads

      public int maxUploads()
      Returns:
      max uploads limit
    • maxUploads

      public void maxUploads(int value)
      Parameters:
      value - max uploads limit
    • maxConnections

      public int maxConnections()
      Returns:
      max connections limit
    • maxConnections

      public void maxConnections(int value)
      Parameters:
      value - max connections limit
    • uploadLimit

      public int uploadLimit()
      Returns:
      upload limit
    • uploadLimit

      public void uploadLimit(int value)
      Parameters:
      value - upload limit
    • downloadLimit

      public int downloadLimit()
      Returns:
      download limit
    • downloadLimit

      public void downloadLimit(int value)
      Parameters:
      value - download limit
    • flags

      public torrent_flags_t flags()
      Flags controlling aspects of this torrent and how it's added.
      Returns:
      the flags
    • flags

      public void flags(torrent_flags_t flags)
      Flags controlling aspects of this torrent and how it's added.
      Parameters:
      flags - the flags
    • urlSeeds

      public ArrayList<String> urlSeeds()
      Url seeds to be added to the torrent (`BEP 17`_).
      Returns:
      the url seeds
    • urlSeeds

      public void urlSeeds(List<String> value)
      Url seeds to be added to the torrent (`BEP 17`_).
      Parameters:
      value - the url seeds
    • filePriorities

      public void filePriorities(Priority[] priorities)
      Can be set to control the initial file priorities when adding a torrent. The semantics are the same as for TorrentHandle.prioritizeFiles(Priority[]).
      Parameters:
      priorities - the priorities
    • piecePriorities

      public void piecePriorities(Priority[] priorities)
      This sets the priorities for each individual piece in the torrent. Each element in the vector represent the piece with the same index. If you set both file- and piece priorities, file priorities will take precedence.
      Parameters:
      priorities - the priorities
    • peers

      public ArrayList<TcpEndpoint> peers()
      Peers to add to the torrent, to be tried to be connected to as bittorrent peers.
      Returns:
      the peers list
    • peers

      public void peers(List<TcpEndpoint> value)
      Peers to add to the torrent, to be tried to be connected to as bittorrent peers.
      Parameters:
      value - the peers list
    • bannedPeers

      public ArrayList<TcpEndpoint> bannedPeers()
      Peers banned from this torrent. The will not be connected to.
      Returns:
      the peers list
    • bannedPeers

      public void bannedPeers(List<TcpEndpoint> value)
      Peers banned from this torrent. The will not be connected to.
      Parameters:
      value - the peers list
    • createInstance

      public static AddTorrentParams createInstance()
      Returns:
      an instance with the default storage
    • parseMagnetUri

      public static AddTorrentParams parseMagnetUri(String uri)
      Helper function to parse a magnet uri and fill the parameters.
      Parameters:
      uri - the magnet uri
      Returns:
      the params object filled with the data from the magnet
    • writeResumeData

      public static Entry writeResumeData(AddTorrentParams params)
      Turns the resume data in an `AddTorrentParams` object into a bencoded structure.