|
KanoopTorrentQt 0.1.0
Qt6 wrapper library for libtorrent-rasterbar
|
|
Parses and constructs BitTorrent magnet URIs. More...
#include <magnetlink.h>
Public Member Functions | |
| MagnetLink () | |
| Construct an invalid (empty) magnet link. | |
| MagnetLink (const QString &uri) | |
| Parse a magnet URI string. | |
| bool | isValid () const |
| Whether the URI was parsed successfully and contains a valid info hash. | |
| QByteArray | infoHash () const |
| Raw 20-byte SHA-1 info hash. | |
| QString | infoHashHex () const |
| Info hash as a lowercase hex string (40 characters). | |
| QString | displayName () const |
Human-readable name extracted from the dn parameter. | |
| void | setDisplayName (const QString &value) |
| Set or override the display name. | |
| QStringList | trackers () const |
Tracker URLs extracted from tr parameters. | |
| void | addTracker (const QString &url) |
| Append a tracker URL. | |
| qint64 | exactLength () const |
Exact content length from the xl parameter, or 0 if not present. | |
| QString | toUri () const |
| Reconstruct a magnet URI string from the current state. | |
Static Public Member Functions | |
| static MagnetLink | fromInfoHash (const QString &hexHash) |
| Create a MagnetLink from a hex-encoded info hash. | |
Parses and constructs BitTorrent magnet URIs.
MagnetLink handles both hex (40-char) and Base32-encoded info hashes, extracts tracker URLs and display names, and can reconstruct a well-formed magnet URI string.
Definition at line 23 of file magnetlink.h.
|
explicit |
Parse a magnet URI string.
Supports the xt (exact topic / info hash), dn (display name), tr (tracker), and xl (exact length) parameters.
| uri | A "magnet:?..." URI string. |
|
inline |
Append a tracker URL.
Definition at line 54 of file magnetlink.h.
|
inline |
Human-readable name extracted from the dn parameter.
Definition at line 47 of file magnetlink.h.
|
inline |
Exact content length from the xl parameter, or 0 if not present.
Definition at line 57 of file magnetlink.h.
|
static |
Create a MagnetLink from a hex-encoded info hash.
Automatically appends a set of well-known public trackers.
| hexHash | 40-character hex-encoded SHA-1 hash. |
hexHash is malformed.
|
inline |
Raw 20-byte SHA-1 info hash.
Definition at line 42 of file magnetlink.h.
|
inline |
Info hash as a lowercase hex string (40 characters).
Definition at line 44 of file magnetlink.h.
|
inline |
Whether the URI was parsed successfully and contains a valid info hash.
Definition at line 39 of file magnetlink.h.
|
inline |
Set or override the display name.
Definition at line 49 of file magnetlink.h.
| QString MagnetLink::toUri | ( | ) | const |
Reconstruct a magnet URI string from the current state.
"magnet:?..." URI string.
|
inline |
Tracker URLs extracted from tr parameters.
Definition at line 52 of file magnetlink.h.