Documentation
¶
Index ¶
- func ExportAndModifyTorrent(client *QbittorrentClient, hash string, cfg *configs.Config, outputDir string) (string, error)
- type AddTorrentOptions
- type Category
- type HTTPClient
- type LocalFileInfo
- type QbittorrentClient
- func (c *QbittorrentClient) AddTorrent(opts AddTorrentOptions) error
- func (c *QbittorrentClient) CheckConnection() error
- func (c *QbittorrentClient) ExportTorrent(infohash string) ([]byte, error)
- func (c *QbittorrentClient) GetAllTorrents() ([]TorrentInfo, error)
- func (c *QbittorrentClient) GetCategories(sidCookie *http.Cookie) (map[string]Category, error)
- func (c *QbittorrentClient) GetTorrentFiles(infohash string) ([]TorrentFile, error)
- func (c *QbittorrentClient) GetTorrentInfo(infohash string) (*TorrentInfo, error)
- type TorrentClient
- type TorrentClientWrapper
- type TorrentFile
- type TorrentInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExportAndModifyTorrent ¶ added in v1.12.0
func ExportAndModifyTorrent(client *QbittorrentClient, hash string, cfg *configs.Config, outputDir string) (string, error)
ExportAndModifyTorrent exports a torrent and modifies its tracker/source for RocketHD
Types ¶
type AddTorrentOptions ¶
type HTTPClient ¶ added in v1.9.0
type LocalFileInfo ¶ added in v1.12.0
LocalFileInfo represents a file in the local directory
func ScanLocalFiles ¶ added in v1.12.0
func ScanLocalFiles(path string) ([]LocalFileInfo, int64, error)
ScanLocalFiles scans a path and returns file info for all included files
type QbittorrentClient ¶
func NewQbittorrentClient ¶
func NewQbittorrentClient(cfg *configs.Config, httpClient *http.Client) *QbittorrentClient
func (*QbittorrentClient) AddTorrent ¶
func (c *QbittorrentClient) AddTorrent(opts AddTorrentOptions) error
func (*QbittorrentClient) CheckConnection ¶ added in v1.10.0
func (c *QbittorrentClient) CheckConnection() error
CheckConnection verifies connectivity and authentication to qBittorrent
func (*QbittorrentClient) ExportTorrent ¶ added in v1.12.0
func (c *QbittorrentClient) ExportTorrent(infohash string) ([]byte, error)
ExportTorrent exports a .torrent file from qBittorrent
func (*QbittorrentClient) GetAllTorrents ¶ added in v1.12.0
func (c *QbittorrentClient) GetAllTorrents() ([]TorrentInfo, error)
GetAllTorrents retrieves all torrents from qBittorrent
func (*QbittorrentClient) GetCategories ¶ added in v1.11.0
GetCategories retrieves all categories from qBittorrent
func (*QbittorrentClient) GetTorrentFiles ¶ added in v1.12.0
func (c *QbittorrentClient) GetTorrentFiles(infohash string) ([]TorrentFile, error)
GetTorrentFiles retrieves the file list for a specific torrent
func (*QbittorrentClient) GetTorrentInfo ¶ added in v1.9.0
func (c *QbittorrentClient) GetTorrentInfo(infohash string) (*TorrentInfo, error)
GetTorrentInfo retrieves detailed info for a torrent by its infohash
type TorrentClient ¶
type TorrentClient interface {
// AddTorrent adds a torrent file to the client and sets the save path.
AddTorrent(opts AddTorrentOptions) error
GetTorrentInfo(infohash string) (*TorrentInfo, error)
}
TorrentClient defines the interface for interacting with a torrent client.
type TorrentClientWrapper ¶ added in v1.9.0
type TorrentClientWrapper struct {
HTTPClient HTTPClient
Config *configs.Config
// contains filtered or unexported fields
}
TorrentClientWrapper provides a unified interface for torrent clients following the same pattern as RocketHDClient and MDBClient.
This wrapper initializes the appropriate torrent client implementation based on configuration. Currently supports:
- qBittorrent
To add support for additional clients:
- Create a new file (e.g., transmission.go)
- Implement the TorrentClient interface
- Add client selection logic in AddTorrent() based on config
Example for adding Transmission support:
type TransmissionClient struct {
cfg *configs.Config
HTTPClient *http.Client
}
func NewTransmissionClient(cfg *configs.Config, httpClient *http.Client) *TransmissionClient {
return &TransmissionClient{cfg: cfg, HTTPClient: httpClient}
}
func (t *TransmissionClient) AddTorrent(opts AddTorrentOptions) error {
// Implementation for Transmission
}
Then update AddTorrent() to select based on cfg.TorrentClient.Type
func (*TorrentClientWrapper) AddTorrent ¶ added in v1.9.0
func (c *TorrentClientWrapper) AddTorrent(opts AddTorrentOptions) error
AddTorrent implements the TorrentClient interface
func (*TorrentClientWrapper) GetQbittorrentClient ¶ added in v1.12.0
func (c *TorrentClientWrapper) GetQbittorrentClient() (*QbittorrentClient, error)
GetQbittorrentClient returns the underlying qBittorrent client for reuse hash functionality. This is needed because the reuse hash feature requires qBittorrent-specific API calls.
func (*TorrentClientWrapper) GetTorrentInfo ¶ added in v1.9.0
func (c *TorrentClientWrapper) GetTorrentInfo(infohash string) (*TorrentInfo, error)
AddTorrent implements the TorrentClient interface
type TorrentFile ¶ added in v1.12.0
type TorrentFile struct {
Name string `json:"name"` // Relative path within torrent
Size int64 `json:"size"` // File size in bytes
Progress float64 `json:"progress"` // Download progress (0-1)
Priority int `json:"priority"` // Download priority
}
TorrentFile represents a single file within a torrent (from qBittorrent API)
type TorrentInfo ¶ added in v1.9.0
type TorrentInfo struct {
AddedOn int64 `json:"added_on"`
AmountLeft int64 `json:"amount_left"`
AutoTMM bool `json:"auto_tmm"`
Availability float64 `json:"availability"`
Category string `json:"category"`
Completed int64 `json:"completed"`
CompletionOn int64 `json:"completion_on"`
ContentPath string `json:"content_path"`
DlLimit int64 `json:"dl_limit"`
Dlspeed int64 `json:"dlspeed"`
Downloaded int64 `json:"downloaded"`
DownloadedSession int64 `json:"downloaded_session"`
ETA int64 `json:"eta"`
FLPiecePrio bool `json:"f_l_piece_prio"`
ForceStart bool `json:"force_start"`
Hash string `json:"hash"`
IsPrivate bool `json:"isPrivate"`
LastActivity int64 `json:"last_activity"`
MagnetURI string `json:"magnet_uri"`
MaxRatio float64 `json:"max_ratio"`
MaxSeedingTime int64 `json:"max_seeding_time"`
Name string `json:"name"`
NumComplete int `json:"num_complete"`
NumIncomplete int `json:"num_incomplete"`
NumLeechs int `json:"num_leechs"`
NumSeeds int `json:"num_seeds"`
Priority int `json:"priority"`
Progress float64 `json:"progress"`
Ratio float64 `json:"ratio"`
RatioLimit float64 `json:"ratio_limit"`
SavePath string `json:"save_path"`
SeedingTime int64 `json:"seeding_time"`
SeedingTimeLimit int64 `json:"seeding_time_limit"`
SeenComplete int64 `json:"seen_complete"`
SeqDl bool `json:"seq_dl"`
Size int64 `json:"size"`
State string `json:"state"`
SuperSeeding bool `json:"super_seeding"`
Tags string `json:"tags"`
TimeActive int64 `json:"time_active"`
TotalSize int64 `json:"total_size"`
Tracker string `json:"tracker"`
UpLimit int64 `json:"up_limit"`
Uploaded int64 `json:"uploaded"`
UploadedSession int64 `json:"uploaded_session"`
Upspeed int64 `json:"upspeed"`
}
TorrentInfo represents the info of a torrent returned by qBittorrent API
func FindMatchingTorrent ¶ added in v1.12.0
func FindMatchingTorrent(client *QbittorrentClient, localFiles []LocalFileInfo, totalSize int64, sizeSimilarity float64) (*TorrentInfo, error)
FindMatchingTorrent searches qBittorrent for a torrent matching the local files