4#include <Kanoop/torrent/kanooptorrent.h>
42 QByteArray
infoHash()
const {
return _infoHash; }
44 QString
infoHashHex()
const {
return QString::fromLatin1(_infoHash.toHex()); }
52 QStringList
trackers()
const {
return _trackers; }
54 void addTracker(
const QString& url) { _trackers.append(url); }
75 static QByteArray decodeBase32(
const QByteArray& encoded);
80 QStringList _trackers;
81 qint64 _exactLength = 0;
Parses and constructs BitTorrent magnet URIs.
qint64 exactLength() const
Exact content length from the xl parameter, or 0 if not present.
QByteArray infoHash() const
Raw 20-byte SHA-1 info hash.
MagnetLink()
Construct an invalid (empty) magnet link.
MagnetLink(const QString &uri)
Parse a magnet URI string.
static MagnetLink fromInfoHash(const QString &hexHash)
Create a MagnetLink from a hex-encoded info hash.
void setDisplayName(const QString &value)
Set or override the display name.
QString infoHashHex() const
Info hash as a lowercase hex string (40 characters).
QStringList trackers() const
Tracker URLs extracted from tr parameters.
QString toUri() const
Reconstruct a magnet URI string from the current state.
QString displayName() const
Human-readable name extracted from the dn parameter.
void addTracker(const QString &url)
Append a tracker URL.
bool isValid() const
Whether the URI was parsed successfully and contains a valid info hash.