|
KanoopTorrentQt 0.1.0
Qt6 wrapper library for libtorrent-rasterbar
|
|
Creates .torrent metainfo files from local content.
More...
#include <torrentcreator.h>
Inheritance diagram for TorrentCreator:
Collaboration diagram for TorrentCreator:Signals | |
| void | progressUpdated (int piecesHashed, int totalPieces) |
| Emitted during piece hashing to report progress. | |
Public Member Functions | |
| TorrentCreator (QObject *parent=nullptr) | |
| Construct a TorrentCreator. | |
| void | setPieceSize (int bytes) |
| Set the piece size in bytes. | |
| int | pieceSize () const |
| Current piece size setting. | |
| void | setTrackers (const QStringList &urls) |
| Set tracker announce URLs. | |
| QStringList | trackers () const |
| Current tracker list. | |
| void | addTrackerTier (const QStringList &urls) |
| Add a tracker tier (group of announce URLs). | |
| void | setWebSeeds (const QStringList &urls) |
| Set web seed URLs (BEP 19 / GetRight-style HTTP seeding). | |
| QStringList | webSeeds () const |
| Current web seed list. | |
| void | setComment (const QString &value) |
| Set the comment embedded in the torrent metainfo. | |
| QString | comment () const |
| Current comment. | |
| void | setCreator (const QString &value) |
| Set the creator string embedded in the torrent metainfo. | |
| QString | creator () const |
| Current creator string. | |
| void | setPrivate (bool enabled) |
| Mark the torrent as private (BEP 27). | |
| bool | isPrivate () const |
| Whether the torrent will be marked private. | |
| bool | create (const QString &sourcePath, const QString &outputPath) |
Create a .torrent file from local content. | |
| qint64 | totalSize () const |
| Total content size in bytes. | |
| int | fileCount () const |
| Number of files in the torrent. | |
| int | pieceCount () const |
| Number of pieces in the torrent. | |
| QString | errorString () const |
| Last error message, or empty if no error. | |
Creates .torrent metainfo files from local content.
TorrentCreator wraps libtorrent's create_torrent API and produces bencoded .torrent files that can be distributed to trackers or loaded by TorrentClient::addTorrent().
The creation runs synchronously in create() — for large file sets consider calling from a worker thread or using QFuture.
Definition at line 32 of file torrentcreator.h.
|
explicit |
Construct a TorrentCreator.
| parent | Optional QObject parent. |
| void TorrentCreator::addTrackerTier | ( | const QStringList & | urls | ) |
Add a tracker tier (group of announce URLs).
All URLs in the list share the same tier, and the client will pick randomly among them.
| urls | List of announce URLs for this tier. |
|
inline |
Current comment.
Definition at line 92 of file torrentcreator.h.
| bool TorrentCreator::create | ( | const QString & | sourcePath, |
| const QString & | outputPath | ||
| ) |
Create a .torrent file from local content.
sourcePath can be a single file or a directory. When a directory is given, all files in it (recursively) are included.
| sourcePath | Path to the file or directory to torrent. |
| outputPath | Where to write the .torrent file. |
true on success, false on failure (check errorString()).
|
inline |
Current creator string.
Definition at line 102 of file torrentcreator.h.
|
inline |
Last error message, or empty if no error.
Definition at line 138 of file torrentcreator.h.
|
inline |
Number of files in the torrent.
Valid after a successful create().
Definition at line 134 of file torrentcreator.h.
|
inline |
Whether the torrent will be marked private.
Definition at line 113 of file torrentcreator.h.
|
inline |
Number of pieces in the torrent.
Valid after a successful create().
Definition at line 136 of file torrentcreator.h.
|
inline |
|
signal |
Emitted during piece hashing to report progress.
| piecesHashed | Number of pieces hashed so far. |
| totalPieces | Total number of pieces. |
| void TorrentCreator::setComment | ( | const QString & | value | ) |
Set the comment embedded in the torrent metainfo.
| value | Free-text comment string. |
| void TorrentCreator::setCreator | ( | const QString & | value | ) |
Set the creator string embedded in the torrent metainfo.
Defaults to "KanoopTorrentQt" if not set.
| value | Creator identification string. |
| void TorrentCreator::setPieceSize | ( | int | bytes | ) |
Set the piece size in bytes.
Must be a power of two (e.g. 16384, 32768, 65536, ...). If not set or set to 0, libtorrent picks an optimal size based on total content size.
| bytes | Piece size in bytes, or 0 for automatic. |
| void TorrentCreator::setPrivate | ( | bool | enabled | ) |
Mark the torrent as private (BEP 27).
Private torrents disable DHT and PEX; peers can only be obtained from the tracker.
| enabled | true for a private torrent. |
| void TorrentCreator::setTrackers | ( | const QStringList & | urls | ) |
Set tracker announce URLs.
Each string is a single announce URL. Multiple trackers are added as separate tiers (one tier per URL). For grouped tiers, use addTrackerTier().
| urls | List of tracker announce URLs. |
| void TorrentCreator::setWebSeeds | ( | const QStringList & | urls | ) |
Set web seed URLs (BEP 19 / GetRight-style HTTP seeding).
| urls | List of HTTP/HTTPS base URLs. |
|
inline |
Total content size in bytes.
Valid after a successful create().
Definition at line 132 of file torrentcreator.h.
|
inline |
Current tracker list.
Definition at line 67 of file torrentcreator.h.
|
inline |
Current web seed list.
Definition at line 84 of file torrentcreator.h.