btf

package module
v0.1.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

README

BitTorrentFile

A library to work with the BitTorrent file format.

Description

This library allows to parse BitTorrent files using the BitTorrent specification of versions 1 and 2.

The BitTorrent file format was introduced with the appearance of the BitTorrent protocol.

This format is as weird and as stupid as the BitTorrent protocol and the bencode encoding.

More information about the BitTorrent can be found on its website: https://www.bittorrent.org/.

Importing

import "github.com/vault-thirteen/BitTorrentFile"

Tools

Auxiliary tools are available in the tools folder.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitTorrentFile

type BitTorrentFile struct {
	// Source is a file which is being parsed.
	Source *b.File

	// Decoded raw data.
	RawData *b.DecodedObject

	// IsBroken is a marker of a broken file.
	// Some stupid people think that specifications were created for fools and
	// that they [these stupid people] are better than other people. We mark
	// such idiots with this flag.
	IsBroken bool

	// Version of the BitTorrent File.
	// It can be numeric or textual while there are some crazy things such as
	// the 'Hybrid' file format.
	Version models.Version

	// BitTorrent name.
	// This field is supported by the second BitTorrent protocol specification.
	Name string

	// BitTorrent Info Hash.
	// The original first version of info hash.
	BTIH mhash.BtihData

	// New BitTorrent Info Hash.
	// Second version of info hash.
	BTIH2 mhash.BtihData2

	// List of announce URLs of trackers described in the BitTorrent File.
	AnnounceUrlMain models.AnnounceAddress
	AnnounceUrlsAux [][]models.AnnounceAddress

	// Creation time of the BitTorrent File.
	CreationTime time.Time

	// Comment of the BitTorrent File.
	Comment string

	// Creator of the BitTorrent File.
	Creator string

	// String encoding format used to generate the 'pieces' field of the 'info'
	// dictionary of the BitTorrent File.
	Encoding string

	// List of files described in the BitTorrent File.
	Files []models.File
}

BitTorrentFile is a BitTorrent file.

func NewBitTorrentFile

func NewBitTorrentFile(filePath string) (tf *BitTorrentFile)

NewBitTorrentFile is a constructor of the BitTorrentFile object.

func (*BitTorrentFile) GetInfoSection

func (tf *BitTorrentFile) GetInfoSection() (is models.Dictionary, err error)

GetInfoSection gets an 'info' section from the object.

func (*BitTorrentFile) GetSection

func (tf *BitTorrentFile) GetSection(sectionName string) (result any, err error)

GetSection gets a section specified by its name from the object.

func (*BitTorrentFile) GetSectionValueAsArrayOfStringArrays

func (tf *BitTorrentFile) GetSectionValueAsArrayOfStringArrays(sectionName string) (asa [][]string, err error)

GetSectionValueAsArrayOfStringArrays reads section value and returns it as array of string arrays.

func (*BitTorrentFile) GetSectionValueAsInt

func (tf *BitTorrentFile) GetSectionValueAsInt(sectionName string) (i int, err error)

GetSectionValueAsInt reads section value and returns it as int.

func (*BitTorrentFile) GetSectionValueAsString

func (tf *BitTorrentFile) GetSectionValueAsString(sectionName string) (sv string, err error)

GetSectionValueAsString reads section value and returns it as string.

func (*BitTorrentFile) GetSectionValueAsStringArray

func (tf *BitTorrentFile) GetSectionValueAsStringArray(sectionName string) (sa []string, err error)

GetSectionValueAsStringArray reads section value and returns it as string array.

func (*BitTorrentFile) Open

func (tf *BitTorrentFile) Open() (err error)

Open opens an existing BitTorrent file and parses it.

Directories

Path Synopsis
tools
indexer command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL