Documentation
¶
Index ¶
- func NewPieceHasher(files []fileEntry, pieceLen int64, numPieces int, display Displayer, ...) *pieceHasher
- type BatchConfig
- type BatchJob
- type BatchResult
- type CreateOptions
- type Display
- func (d *Display) FinishProgress()
- func (d *Display) IsBatch() bool
- func (d *Display) SetBatch(isBatch bool)
- func (d *Display) SetQuiet(quiet bool)
- func (d *Display) ShowBatchResults(results []BatchResult, duration time.Duration)
- func (d *Display) ShowError(msg string)
- func (d *Display) ShowFileTree(info *metainfo.Info)
- func (d *Display) ShowFiles(files []fileEntry, numWorkers int)
- func (d *Display) ShowMessage(msg string)
- func (d *Display) ShowOutputPathWithTime(path string, duration time.Duration)
- func (d *Display) ShowProgress(total int)
- func (d *Display) ShowSeasonPackWarnings(info *SeasonPackInfo)
- func (d *Display) ShowTorrentInfo(t *Torrent, info *metainfo.Info)
- func (d *Display) ShowVerificationResult(result *VerificationResult, duration time.Duration)
- func (d *Display) ShowWarning(msg string)
- func (d *Display) UpdateProgress(completed int, hashrate float64)
- type Displayer
- type FileEntry
- type Formatter
- type ModifyOptions
- type ProgressCallback
- type Result
- type SeasonPackInfo
- type Torrent
- type TorrentInfo
- type VerificationResult
- type VerifyOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BatchConfig ¶
BatchConfig represents the YAML configuration for batch torrent creation
type BatchJob ¶
type BatchJob struct {
Output string `yaml:"output"`
Path string `yaml:"path"`
Name string `yaml:"-"`
Comment string `yaml:"comment"`
Source string `yaml:"source"`
Trackers []string `yaml:"trackers"`
WebSeeds []string `yaml:"webseeds"`
ExcludePatterns []string `yaml:"exclude_patterns"`
IncludePatterns []string `yaml:"include_patterns"`
PieceLength uint `yaml:"piece_length"`
TargetPieceCount uint `yaml:"target_piece_count"`
Private bool `yaml:"private"`
NoDate bool `yaml:"no_date"`
SkipPrefix bool `yaml:"skip_prefix"`
Entropy bool `yaml:"entropy"`
FailOnSeasonWarning bool `yaml:"fail_on_season_warning"`
}
BatchJob represents a single torrent creation job within a batch
func (*BatchJob) ToCreateOptions ¶
func (j *BatchJob) ToCreateOptions(verbose bool, quiet bool, infoOnly bool, version string) CreateOptions
ToCreateOptions converts a BatchJob to CreateOptions
type BatchResult ¶
type BatchResult struct {
Error error
Info *TorrentInfo
Trackers []string
Job BatchJob
Success bool
}
BatchResult represents the result of a single job in the batch
func ProcessBatch ¶
func ProcessBatch(configPath string, verbose bool, quiet bool, infoOnly bool, version string) ([]BatchResult, error)
ProcessBatch processes a batch configuration file and creates multiple torrents. It reads a YAML configuration file containing multiple torrent creation jobs and processes them in parallel for efficient batch operations.
type CreateOptions ¶
type CreateOptions struct {
PieceLengthExp *uint
MaxPieceLength *uint
TargetPieceCount *uint
Path string
Name string
TrackerURLs []string
Comment string
Source string
Version string
OutputPath string
OutputDir string
WebSeeds []string
ExcludePatterns []string
IncludePatterns []string
Workers int
IsPrivate bool
NoDate bool
NoCreator bool
Verbose bool
Entropy bool
Quiet bool
InfoOnly bool
SkipPrefix bool
FailOnSeasonPackWarning bool
// ProgressCallback is called during hashing to report progress.
// If nil, no progress callbacks will be made.
ProgressCallback ProgressCallback
}
CreateOptions contains all options for creating a torrent
type Display ¶
type Display struct {
// contains filtered or unexported fields
}
func NewDisplay ¶
func (*Display) FinishProgress ¶
func (d *Display) FinishProgress()
func (*Display) ShowBatchResults ¶
func (d *Display) ShowBatchResults(results []BatchResult, duration time.Duration)
func (*Display) ShowFileTree ¶
ShowFileTree displays the file structure of a multi-file torrent The decision to show the tree is now handled in cmd/inspect.go
func (*Display) ShowFiles ¶
ShowFiles displays the list of files being processed and the number of workers used.
func (*Display) ShowMessage ¶
func (*Display) ShowOutputPathWithTime ¶
func (*Display) ShowProgress ¶
func (*Display) ShowSeasonPackWarnings ¶
func (d *Display) ShowSeasonPackWarnings(info *SeasonPackInfo)
func (*Display) ShowTorrentInfo ¶
func (*Display) ShowVerificationResult ¶
func (d *Display) ShowVerificationResult(result *VerificationResult, duration time.Duration)
ShowVerificationResult displays the results of a torrent verification check
func (*Display) ShowWarning ¶
func (*Display) UpdateProgress ¶
type Displayer ¶
type Displayer interface {
ShowProgress(total int)
UpdateProgress(completed int, hashrate float64)
ShowFiles(files []fileEntry, numWorkers int)
ShowSeasonPackWarnings(info *SeasonPackInfo)
FinishProgress()
IsBatch() bool
}
Displayer defines the interface for displaying progress during torrent creation
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
func NewFormatter ¶
func (*Formatter) FormatBytes ¶
type ModifyOptions ¶
type ModifyOptions struct {
IsPrivate *bool
PieceLengthExp *uint
MaxPieceLength *uint
PresetName string
PresetFile string
Name string
OutputDir string
OutputPattern string
TrackerURLs []string
Comment string
Source string
Version string
WebSeeds []string
NoDate bool
NoCreator bool
DryRun bool
Verbose bool
Quiet bool
Entropy *bool
SkipPrefix bool
SourceSet bool // true when --source flag was explicitly provided (allows empty string to clear)
CommentSet bool // true when --comment flag was explicitly provided (allows empty string to clear)
RemovePrivate bool // true when --no-private flag is provided (removes private field entirely)
}
ModifyOptions represents the options for modifying a torrent, including both preset-related options and flag-based overrides.
type ProgressCallback ¶
ProgressCallback is called during torrent creation to report progress. completed: number of pieces hashed so far total: total number of pieces to hash hashRate: current hashing rate in bytes per second
type Result ¶
Result represents the result of modifying a torrent
func ModifyTorrent ¶
func ModifyTorrent(path string, opts ModifyOptions) (*Result, error)
ModifyTorrent modifies a single torrent file according to the given options. It can change trackers, comment, source, piece length, and other metadata. Returns a Result containing the operation outcome and output path.
func ProcessTorrents ¶
func ProcessTorrents(paths []string, opts ModifyOptions) ([]*Result, error)
ProcessTorrents modifies multiple torrent files according to the given options. It processes each torrent file and returns the results for all operations. This function provides parallel processing for better performance with multiple files.
type SeasonPackInfo ¶
type SeasonPackInfo struct {
Episodes []int
MissingEpisodes []int
Season int
MaxEpisode int
VideoFileCount int
IsSeasonPack bool
IsSuspicious bool
}
func AnalyzeSeasonPack ¶
func AnalyzeSeasonPack(files []fileEntry) *SeasonPackInfo
type Torrent ¶
Torrent represents a torrent file with additional functionality
func CreateTorrent ¶
func CreateTorrent(opts CreateOptions) (*Torrent, error)
CreateTorrent creates a new torrent file from the given options. Returns a Torrent struct containing the metainfo. This is the lower-level function; use Create() for a higher-level interface.
func LoadFromFile ¶
LoadFromFile loads a torrent file from disk and returns a Torrent struct. The returned Torrent wraps the metainfo and provides additional functionality.
type TorrentInfo ¶
type TorrentInfo struct {
MetaInfo *metainfo.MetaInfo
Path string
InfoHash string
Announce string
Size int64
Files int
}
TorrentInfo contains summary information about the created torrent
func Create ¶
func Create(opts CreateOptions) (*TorrentInfo, error)
Create creates a new torrent file with the given options. Returns TorrentInfo containing summary information about the created torrent. The torrent file is automatically saved to disk based on the output options. This is the main high-level function for torrent creation.
type VerificationResult ¶
type VerificationResult struct {
BadPieceIndices []int
MissingFiles []string
TotalPieces int
GoodPieces int
BadPieces int
MissingPieces int
Completion float64
}
VerificationResult holds the outcome of a torrent data verification check
func VerifyData ¶
func VerifyData(opts VerifyOptions) (*VerificationResult, error)
VerifyData checks the integrity of content files against a torrent file. It compares the actual file data against the piece hashes in the torrent. Returns detailed verification results including bad pieces and missing files.