gotorrentparser

package module
v0.0.0-...-db02b40 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: Apache-2.0 Imports: 7 Imported by: 1

README

Golang Torrent Parser

A lightweight parser in Golang for .torrent files.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	// Relative path of the file
	Path []string

	// File length
	Length int64
}

type FileMetadata

type FileMetadata struct {
	Path     []string `bencode:"path"`
	PathUtf8 []string `bencode:"path.utf-8"`
	Length   int64    `bencode:"length"`
}

type InfoMetadata

type InfoMetadata struct {
	PieceLength int64  `bencode:"piece length"`
	Pieces      []byte `bencode:"pieces"`

	// single file context
	Name     string `bencode:"name"`
	NameUtf8 string `bencode:"name.utf-8"`
	Length   int64  `bencode:"length"`

	// multi file context
	Files bencode.RawMessage `bencode:"files"`
}

type Metadata

type Metadata struct {
	// Foobar   []interface{} `bencode:"announce-list"`
	Announce     string             `bencode:"announce"`
	AnnounceList [][]string         `bencode:"announce-list"`
	Comment      string             `bencode:"comment"`
	CreatedBy    string             `bencode:"created by"`
	CreatedAt    int64              `bencode:"creation date"`
	Info         bencode.RawMessage `bencode:"info"`
}

type Torrent

type Torrent struct {
	// Announce URL
	Announce []string

	// Torrent comment
	Comment string

	// Author
	CreatedBy string

	// Creation time
	CreatedAt time.Time

	// Torrent SHA1
	InfoHash string

	Files []*File
}

func Parse

func Parse(reader io.Reader) (*Torrent, error)

func ParseFromFile

func ParseFromFile(path string) (*Torrent, error)

Jump to

Keyboard shortcuts

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