TorrentFile Class
public sealed class TorrentFileNo documentation is available.
Constructors
| Name | Description |
|---|---|
| TorrentFile() |
TorrentFile()
TorrentFile.cspublic TorrentFile()No documentation is available.
Properties
| Name | Description |
|---|---|
| AdditionalKeys | The keys of the root dictionary this model does not represent. They are written back as they are. |
| Announce | |
| AnnounceList | |
| Comment | |
| CreatedBy | |
| CreationDate | |
| Encoding | The 'encoding' key naming the code page the text fields are written with. |
| HttpSeeds | Web seed URLs from the 'httpseeds' key (BEP 17). |
| Info | The metainfo dictionary. Replacing it discards the parsed bytes, so the info-hash is recomputed from the model. |
| Nodes | DHT bootstrap nodes from the 'nodes' key (BEP 5). |
| PieceLayers | The BitTorrent v2 'piece layers' key (BEP 52): the piece hashes of each file larger than a piece. |
| Publisher | |
| PublisherUrl | The 'publisher-url' key. Kept as text because the metainfo value is not guaranteed to be a well-formed URI. |
| UrlList | Web seed URLs from the 'url-list' key (BEP 19). |
AdditionalKeys
TorrentFile.csThe keys of the root dictionary this model does not represent. They are written back as they are.
public IDictionary<BencodeString, BencodeValue> AdditionalKeys { get; }Property value
Announce
TorrentFile.csAnnounceList
TorrentFile.cspublic IReadOnlyList<IReadOnlyList<string>>? AnnounceList { get; set; }Property value
No documentation is available.
Comment
TorrentFile.csCreatedBy
TorrentFile.csCreationDate
TorrentFile.csEncoding
TorrentFile.csThe 'encoding' key naming the code page the text fields are written with.
public string? Encoding { get; set; }Property value
Remarks
When it names a known encoding other than UTF-8, such as GBK or windows-1251, the text fields of the torrent are read and written with that encoding. An unknown name is ignored: the text fields are UTF-8.
HttpSeeds
TorrentFile.csWeb seed URLs from the 'httpseeds' key (BEP 17).
public IReadOnlyList<string>? HttpSeeds { get; set; }Property value
Info
TorrentFile.csThe metainfo dictionary. Replacing it discards the parsed bytes, so the info-hash is recomputed from the model.
public TorrentInfo Info { get; set; }Property value
Nodes
TorrentFile.csDHT bootstrap nodes from the 'nodes' key (BEP 5).
public IReadOnlyList<TorrentNode>? Nodes { get; set; }Property value
PieceLayers
TorrentFile.csThe BitTorrent v2 'piece layers' key (BEP 52): the piece hashes of each file larger than a piece.
public IReadOnlyList<TorrentPieceLayer>? PieceLayers { get; set; }Property value
Publisher
TorrentFile.csPublisherUrl
TorrentFile.csUrlList
TorrentFile.csWeb seed URLs from the 'url-list' key (BEP 19).
public IReadOnlyList<string>? UrlList { get; set; }Property value
Remarks
BEP 19 allows a bare string as well as a list; both are read into this list, and it is always written back as a list.
Methods
| Name | Description |
|---|---|
| GetInfoHashSha1() | Computes the BitTorrent v1 info-hash. |
| GetInfoHashSha256() | Computes the SHA-256 of the 'info' dictionary, which is the BitTorrent v2 info-hash. |
| Parse(ReadOnlySpan<byte>) | |
| ParseAsync(PipeReader, CancellationToken) | Parses a torrent from a PipeReader, as the data arrives. Complete the reader yourself. |
| ParseAsync(Stream, CancellationToken) | Parses a torrent from a stream, as the data arrives. The stream is left open. |
| ToUtf8ByteArray(bool) | |
| TryParse(ReadOnlySpan<byte>, TorrentFile?) | |
| WriteToAsync(Stream, bool, CancellationToken) |
GetInfoHashSha1()
TorrentFile.csComputes the BitTorrent v1 info-hash.
public byte[] GetInfoHashSha1()Returns
byte[]
Remarks
For a parsed torrent this hashes the exact bytes the 'info' dictionary was read from, so keys this model does not represent still contribute to the hash.
GetInfoHashSha256()
TorrentFile.csComputes the SHA-256 of the 'info' dictionary, which is the BitTorrent v2 info-hash.
public byte[] GetInfoHashSha256()Returns
byte[]
Remarks
For a parsed torrent this hashes the exact bytes the 'info' dictionary was read from, so keys this model does not represent still contribute to the hash.
Parse(ReadOnlySpan<byte>)
TorrentFile.cspublic static TorrentFile Parse(ReadOnlySpan<byte> data)No documentation is available.
ParseAsync overloads
ParseAsync(PipeReader, CancellationToken)
TorrentFile.csParses a torrent from a PipeReader, as the data arrives. Complete the reader yourself.
net10.0
public static ValueTask<TorrentFile> ParseAsync(PipeReader reader, CancellationToken cancellationToken = default)net11.0
public static ValueTask<TorrentFile> ParseAsync(PipeReader reader, CancellationToken cancellationToken = default)ParseAsync(Stream, CancellationToken)
TorrentFile.csParses a torrent from a stream, as the data arrives. The stream is left open.
net10.0
public static ValueTask<TorrentFile> ParseAsync(Stream stream, CancellationToken cancellationToken = default)net11.0
public static ValueTask<TorrentFile> ParseAsync(Stream stream, CancellationToken cancellationToken = default)ToUtf8ByteArray(bool)
TorrentFile.csTryParse(ReadOnlySpan<byte>, TorrentFile?)
TorrentFile.cspublic static bool TryParse(ReadOnlySpan<byte> data, out TorrentFile? result)No documentation is available.
WriteToAsync(Stream, bool, CancellationToken)
TorrentFile.csnet10.0
public ValueTask WriteToAsync(Stream stream, bool canonical = true, CancellationToken cancellationToken = default)net11.0
public ValueTask WriteToAsync(Stream stream, bool canonical = true, CancellationToken cancellationToken = default)No documentation is available.