node build fixed

This commit is contained in:
ra_ma
2025-09-20 14:08:38 +01:00
parent c6ebbe069d
commit 3d298fa434
1516 changed files with 535727 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
package qbittorrent_model
type AddTorrentsOptions struct {
// Download folder
Savepath string `json:"savepath,omitempty"`
// Cookie sent to download the .torrent file
Cookie string `json:"cookie,omitempty"`
// Category for the torrent
Category string `json:"category,omitempty"`
// Skip hash checking.
SkipChecking bool `json:"skip_checking,omitempty"`
// Add torrents in the paused state.
Paused string `json:"paused,omitempty"`
// Create the root folder. Possible values are true, false, unset (default)
RootFolder string `json:"root_folder,omitempty"`
// Rename torrent
Rename string `json:"rename,omitempty"`
// Set torrent upload speed limit. Unit in bytes/second
UpLimit int `json:"upLimit,omitempty"`
// Set torrent download speed limit. Unit in bytes/second
DlLimit int `json:"dlLimit,omitempty"`
// Whether Automatic Torrent Management should be used
UseAutoTMM bool `json:"useAutoTMM,omitempty"`
// Enable sequential download. Possible values are true, false (default)
SequentialDownload bool `json:"sequentialDownload,omitempty"`
// Prioritize download first last piece. Possible values are true, false (default)
FirstLastPiecePrio bool `json:"firstLastPiecePrio,omitempty"`
// Tags for the torrent, split by ','
Tags string `json:"tags,omitempty"`
}

View File

@@ -0,0 +1,9 @@
package qbittorrent_model
type BuildInfo struct {
QT string `json:"qt"`
LibTorrent string `json:"libtorrent"`
Boost string `json:"boost"`
OpenSSL string `json:"openssl"`
Bitness string `json:"bitness"`
}

View File

@@ -0,0 +1,6 @@
package qbittorrent_model
type Category struct {
Name string `json:"name"`
SavePath string `json:"savePath"`
}

View File

@@ -0,0 +1,9 @@
package qbittorrent_model
type GetLogOptions struct {
Normal bool `url:"normal"`
Info bool `url:"info"`
Warning bool `url:"warning"`
Critical bool `url:"critical"`
LastKnownID int `url:"lastKnownId"`
}

View File

@@ -0,0 +1,23 @@
package qbittorrent_model
type GetTorrentListOptions struct {
Filter TorrentListFilter `url:"filter,omitempty"`
Category *string `url:"category,omitempty"`
Sort string `url:"sort,omitempty"`
Reverse bool `url:"reverse,omitempty"`
Limit int `url:"limit,omitempty"`
Offset int `url:"offset,omitempty"`
Hashes string `url:"hashes,omitempty"`
}
type TorrentListFilter string
const (
FilterAll TorrentListFilter = "all"
FilterDownloading = "downloading"
FilterCompleted = "completed"
FilterPaused = "paused"
FilterActive = "active"
FilterInactive = "inactive"
FilterResumed = "resumed"
)

View File

@@ -0,0 +1,44 @@
package qbittorrent_model
import (
"encoding/json"
"time"
)
type LogEntry struct {
ID int `json:"id"`
Message string `json:"message"`
Timestamp time.Time `json:"timestamp"`
Type LogType `json:"type"`
}
func (l *LogEntry) UnmarshalJSON(data []byte) error {
var raw rawLogEntry
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
t := time.Unix(0, int64(raw.Timestamp)*int64(time.Millisecond))
*l = LogEntry{
ID: raw.ID,
Message: raw.Message,
Timestamp: t,
Type: raw.Type,
}
return nil
}
type LogType int
const (
TypeNormal LogType = iota << 1
TypeInfo
TypeWarning
TypeCritical
)
type rawLogEntry struct {
ID int `json:"id"`
Message string `json:"message"`
Timestamp int `json:"timestamp"`
Type LogType `json:"type"`
}

View File

@@ -0,0 +1,19 @@
package qbittorrent_model
type Peer struct {
Client string `json:"client"`
Connection string `json:"connection"`
Country string `json:"country"`
CountryCode string `json:"country_code"`
DLSpeed int `json:"dlSpeed"`
Downloaded int `json:"downloaded"`
Files string `json:"files"`
Flags string `json:"flags"`
FlagsDescription string `json:"flags_desc"`
IP string `json:"ip"`
Port int `json:"port"`
Progress float64 `json:"progress"`
Relevance int `json:"relevance"`
ULSpeed int `json:"up_speed"`
Uploaded int `json:"uploaded"`
}

View File

@@ -0,0 +1,38 @@
package qbittorrent_model
import (
"encoding/json"
"time"
)
type PeerLogEntry struct {
ID int `json:"id"`
IP string `json:"ip"`
Timestamp time.Time `json:"timestamp"`
Blocked bool `json:"blocked"`
Reason string `json:"reason"`
}
func (l *PeerLogEntry) UnmarshalJSON(data []byte) error {
var raw rawPeerLogEntry
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
t := time.Unix(0, int64(raw.Timestamp)*int64(time.Millisecond))
*l = PeerLogEntry{
ID: raw.ID,
IP: raw.IP,
Timestamp: t,
Blocked: raw.Blocked,
Reason: raw.Reason,
}
return nil
}
type rawPeerLogEntry struct {
ID int `json:"id"`
IP string `json:"ip"`
Timestamp int `json:"timestamp"`
Blocked bool `json:"blocked"`
Reason string `json:"reason"`
}

View File

@@ -0,0 +1,213 @@
package qbittorrent_model
type Preferences struct {
// Currently selected language (e.g. en_GB for English)
Locale string `json:"locale"`
// True if a subfolder should be created when adding a torrent
CreateSubfolderEnabled bool `json:"create_subfolder_enabled"`
// True if torrents should be added in a Paused state
StartPausedEnabled bool `json:"start_paused_enabled"`
// No documentation provided
AutoDeleteMode int `json:"auto_delete_mode"`
// True if disk space should be pre-allocated for all files
PreallocateAll bool `json:"preallocate_all"`
// True if ".!qB" should be appended to incomplete files
IncompleteFilesExt bool `json:"incomplete_files_ext"`
// True if Automatic Torrent Management is enabled by default
AutoTmmEnabled bool `json:"auto_tmm_enabled"`
// True if torrent should be relocated when its Category changes
TorrentChangedTmmEnabled bool `json:"torrent_changed_tmm_enabled"`
// True if torrent should be relocated when the default save path changes
SavePathChangedTmmEnabled bool `json:"save_path_changed_tmm_enabled"`
// True if torrent should be relocated when its Category's save path changes
CategoryChangedTmmEnabled bool `json:"category_changed_tmm_enabled"`
// Default save path for torrents, separated by slashes
SavePath string `json:"save_path"`
// True if folder for incomplete torrents is enabled
TempPathEnabled bool `json:"temp_path_enabled"`
// Path for incomplete torrents, separated by slashes
TempPath string `json:"temp_path"`
// Property: directory to watch for torrent files, value: where torrents loaded from this directory should be downloaded to (see list of possible values below). Slashes are used as path separators; multiple key/value pairs can be specified
ScanDirs map[string]interface{} `json:"scan_dirs"`
// Path to directory to copy .torrent files to. Slashes are used as path separators
ExportDir string `json:"export_dir"`
// Path to directory to copy .torrent files of completed downloads to. Slashes are used as path separators
ExportDirFin string `json:"export_dir_fin"`
// True if e-mail notification should be enabled
MailNotificationEnabled bool `json:"mail_notification_enabled"`
// e-mail where notifications should originate from
MailNotificationSender string `json:"mail_notification_sender"`
// e-mail to send notifications to
MailNotificationEmail string `json:"mail_notification_email"`
// smtp server for e-mail notifications
MailNotificationSmtp string `json:"mail_notification_smtp"`
// True if smtp server requires SSL connection
MailNotificationSslEnabled bool `json:"mail_notification_ssl_enabled"`
// True if smtp server requires authentication
MailNotificationAuthEnabled bool `json:"mail_notification_auth_enabled"`
// Username for smtp authentication
MailNotificationUsername string `json:"mail_notification_username"`
// Password for smtp authentication
MailNotificationPassword string `json:"mail_notification_password"`
// True if external program should be run after torrent has finished downloading
AutorunEnabled bool `json:"autorun_enabled"`
// Program path/name/arguments to run if autorun_enabled is enabled; path is separated by slashes; you can use %f and %n arguments, which will be expanded by qBittorent as path_to_torrent_file and torrent_name (from the GUI; not the .torrent file name) respectively
AutorunProgram string `json:"autorun_program"`
// True if torrent queuing is enabled
QueueingEnabled bool `json:"queueing_enabled"`
// Maximum number of active simultaneous downloads
MaxActiveDownloads int `json:"max_active_downloads"`
// Maximum number of active simultaneous downloads and uploads
MaxActiveTorrents int `json:"max_active_torrents"`
// Maximum number of active simultaneous uploads
MaxActiveUploads int `json:"max_active_uploads"`
// If true torrents w/o any activity (stalled ones) will not be counted towards max_active_* limits; see dont_count_slow_torrents for more information
DontCountSlowTorrents bool `json:"dont_count_slow_torrents"`
// Download rate in KiB/s for a torrent to be considered "slow"
SlowTorrentDlRateThreshold int `json:"slow_torrent_dl_rate_threshold"`
// Upload rate in KiB/s for a torrent to be considered "slow"
SlowTorrentUlRateThreshold int `json:"slow_torrent_ul_rate_threshold"`
// Seconds a torrent should be inactive before considered "slow"
SlowTorrentInactiveTimer int `json:"slow_torrent_inactive_timer"`
// True if share ratio limit is enabled
MaxRatioEnabled bool `json:"max_ratio_enabled"`
// Get the global share ratio limit
MaxRatio float64 `json:"max_ratio"`
// Action performed when a torrent reaches the maximum share ratio. See list of possible values here below.
MaxRatioAct MaxRatioAction `json:"max_ratio_act"`
// Port for incoming connections
ListenPort int `json:"listen_port"`
// True if UPnP/NAT-PMP is enabled
Upnp bool `json:"upnp"`
// True if the port is randomly selected
RandomPort bool `json:"random_port"`
// Global download speed limit in KiB/s; -1 means no limit is applied
DlLimit int `json:"dl_limit"`
// Global upload speed limit in KiB/s; -1 means no limit is applied
UpLimit int `json:"up_limit"`
// Maximum global number of simultaneous connections
MaxConnec int `json:"max_connec"`
// Maximum number of simultaneous connections per torrent
MaxConnecPerTorrent int `json:"max_connec_per_torrent"`
// Maximum number of upload slots
MaxUploads int `json:"max_uploads"`
// Maximum number of upload slots per torrent
MaxUploadsPerTorrent int `json:"max_uploads_per_torrent"`
// True if uTP protocol should be enabled; this option is only available in qBittorent built against libtorrent version 0.16.X and higher
EnableUtp bool `json:"enable_utp"`
// True if [du]l_limit should be applied to uTP connections; this option is only available in qBittorent built against libtorrent version 0.16.X and higher
LimitUtpRate bool `json:"limit_utp_rate"`
// True if [du]l_limit should be applied to estimated TCP overhead (service data: e.g. packet headers)
LimitTcpOverhead bool `json:"limit_tcp_overhead"`
// True if [du]l_limit should be applied to peers on the LAN
LimitLanPeers bool `json:"limit_lan_peers"`
// Alternative global download speed limit in KiB/s
AltDlLimit int `json:"alt_dl_limit"`
// Alternative global upload speed limit in KiB/s
AltUpLimit int `json:"alt_up_limit"`
// True if alternative limits should be applied according to schedule
SchedulerEnabled bool `json:"scheduler_enabled"`
// Scheduler starting hour
ScheduleFromHour int `json:"schedule_from_hour"`
// Scheduler starting minute
ScheduleFromMin int `json:"schedule_from_min"`
// Scheduler ending hour
ScheduleToHour int `json:"schedule_to_hour"`
// Scheduler ending minute
ScheduleToMin int `json:"schedule_to_min"`
// Scheduler days. See possible values here below
SchedulerDays int `json:"scheduler_days"`
// True if DHT is enabled
Dht bool `json:"dht"`
// True if DHT port should match TCP port
DhtSameAsBT bool `json:"dhtSameAsBT"`
// DHT port if dhtSameAsBT is false
DhtPort int `json:"dht_port"`
// True if PeX is enabled
Pex bool `json:"pex"`
// True if LSD is enabled
Lsd bool `json:"lsd"`
// See list of possible values here below
Encryption int `json:"encryption"`
// If true anonymous mode will be enabled; read more here; this option is only available in qBittorent built against libtorrent version 0.16.X and higher
AnonymousMode bool `json:"anonymous_mode"`
// See list of possible values here below
ProxyType int `json:"proxy_type"`
// Proxy IP address or domain name
ProxyIp string `json:"proxy_ip"`
// Proxy port
ProxyPort int `json:"proxy_port"`
// True if peer and web seed connections should be proxified; this option will have any effect only in qBittorent built against libtorrent version 0.16.X and higher
ProxyPeerConnections bool `json:"proxy_peer_connections"`
// True if the connections not supported by the proxy are disabled
ForceProxy bool `json:"force_proxy"`
// True proxy requires authentication; doesn't apply to SOCKS4 proxies
ProxyAuthEnabled bool `json:"proxy_auth_enabled"`
// Username for proxy authentication
ProxyUsername string `json:"proxy_username"`
// Password for proxy authentication
ProxyPassword string `json:"proxy_password"`
// True if external IP filter should be enabled
IpFilterEnabled bool `json:"ip_filter_enabled"`
// Path to IP filter file (.dat, .p2p, .p2b files are supported); path is separated by slashes
IpFilterPath string `json:"ip_filter_path"`
// True if IP filters are applied to trackers
IpFilterTrackers bool `json:"ip_filter_trackers"`
// Comma-separated list of domains to accept when performing Host header validation
WebUiDomainList string `json:"web_ui_domain_list"`
// IP address to use for the WebUI
WebUiAddress string `json:"web_ui_address"`
// WebUI port
WebUiPort int `json:"web_ui_port"`
// True if UPnP is used for the WebUI port
WebUiUpnp bool `json:"web_ui_upnp"`
// WebUI username
WebUiUsername string `json:"web_ui_username"`
// For API ≥ v2.3.0: Plaintext WebUI password, not readable, write-only. For API < v2.3.0: MD5 hash of WebUI password, hash is generated from the following string: username:Web UI Access:plain_text_web_ui_password
WebUiPassword string `json:"web_ui_password"`
// True if WebUI CSRF protection is enabled
WebUiCsrfProtectionEnabled bool `json:"web_ui_csrf_protection_enabled"`
// True if WebUI clickjacking protection is enabled
WebUiClickjackingProtectionEnabled bool `json:"web_ui_clickjacking_protection_enabled"`
// True if authentication challenge for loopback address (127.0.0.1) should be disabled
BypassLocalAuth bool `json:"bypass_local_auth"`
// True if webui authentication should be bypassed for clients whose ip resides within (at least) one of the subnets on the whitelist
BypassAuthSubnetWhitelistEnabled bool `json:"bypass_auth_subnet_whitelist_enabled"`
// (White)list of ipv4/ipv6 subnets for which webui authentication should be bypassed; list entries are separated by commas
BypassAuthSubnetWhitelist string `json:"bypass_auth_subnet_whitelist"`
// True if an alternative WebUI should be used
AlternativeWebuiEnabled bool `json:"alternative_webui_enabled"`
// File path to the alternative WebUI
AlternativeWebuiPath string `json:"alternative_webui_path"`
// True if WebUI HTTPS access is enabled
UseHttps bool `json:"use_https"`
// SSL keyfile contents (this is a not a path)
SslKey string `json:"ssl_key"`
// SSL certificate contents (this is a not a path)
SslCert string `json:"ssl_cert"`
// True if server DNS should be updated dynamically
DyndnsEnabled bool `json:"dyndns_enabled"`
// See list of possible values here below
DyndnsService int `json:"dyndns_service"`
// Username for DDNS service
DyndnsUsername string `json:"dyndns_username"`
// Password for DDNS service
DyndnsPassword string `json:"dyndns_password"`
// Your DDNS domain name
DyndnsDomain string `json:"dyndns_domain"`
// RSS refresh interval
RssRefreshInterval int `json:"rss_refresh_interval"`
// Max stored articles per RSS feed
RssMaxArticlesPerFeed int `json:"rss_max_articles_per_feed"`
// Enable processing of RSS feeds
RssProcessingEnabled bool `json:"rss_processing_enabled"`
// Enable auto-downloading of torrents from the RSS feeds
RssAutoDownloadingEnabled bool `json:"rss_auto_downloading_enabled"`
}
type MaxRatioAction int
const (
ActionPause MaxRatioAction = 0
ActionRemove = 1
)

View File

@@ -0,0 +1,30 @@
package qbittorrent_model
type RuleDefinition struct {
// Whether the rule is enabled
Enabled bool `json:"enabled"`
// The substring that the torrent name must contain
MustContain string `json:"mustContain"`
// The substring that the torrent name must not contain
MustNotContain string `json:"mustNotContain"`
// Enable regex mode in "mustContain" and "mustNotContain"
UseRegex bool `json:"useRegex"`
// Episode filter definition
EpisodeFilter string `json:"episodeFilter"`
// Enable smart episode filter
SmartFilter bool `json:"smartFilter"`
// The list of episode IDs already matched by smart filter
PreviouslyMatchedEpisodes []string `json:"previouslyMatchedEpisodes"`
// The feed URLs the rule applied to
AffectedFeeds []string `json:"affectedFeeds"`
// Ignore sunsequent rule matches
IgnoreDays int `json:"ignoreDays"`
// The rule last match time
LastMatch string `json:"lastMatch"`
// Add matched torrent in paused mode
AddPaused bool `json:"addPaused"`
// Assign category to the torrent
AssignedCategory string `json:"assignedCategory"`
// Save torrent to the given directory
SavePath string `json:"savePath"`
}

View File

@@ -0,0 +1,10 @@
package qbittorrent_model
type SearchPlugin struct {
Enabled bool `json:"enabled"`
FullName string `json:"fullName"`
Name string `json:"name"`
SupportedCategories []string `json:"supportedCategories"`
URL string `json:"url"`
Version string `json:"version"`
}

View File

@@ -0,0 +1,18 @@
package qbittorrent_model
type SearchResult struct {
// URL of the torrent's description page
DescriptionLink string `json:"descrLink"`
// Name of the file
FileName string `json:"fileName"`
// Size of the file in Bytes
FileSize int `json:"fileSize"`
// Torrent download link (usually either .torrent file or magnet link)
FileUrl string `json:"fileUrl"`
// Number of leechers
NumLeechers int `json:"nbLeechers"`
// int of seeders
NumSeeders int `json:"nbSeeders"`
// URL of the torrent site
SiteUrl string `json:"siteUrl"`
}

View File

@@ -0,0 +1,7 @@
package qbittorrent_model
type SearchResultsPaging struct {
Results []SearchResult `json:"results"`
Status string `json:"status"`
Total int `json:"total"`
}

View File

@@ -0,0 +1,7 @@
package qbittorrent_model
type SearchStatus struct {
ID int `json:"id"`
Status string `json:"status"`
Total int `json:"total"`
}

View File

@@ -0,0 +1,80 @@
package qbittorrent_model
import (
"encoding/json"
"strconv"
)
type ServerState struct {
TransferInfo
AlltimeDl int `json:"alltime_dl"`
AlltimeUl int `json:"alltime_ul"`
AverageTimeQueue int `json:"average_time_queue"`
FreeSpaceOnDisk int `json:"free_space_on_disk"`
GlobalRatio float64 `json:"global_ratio"`
QueuedIoJobs int `json:"queued_io_jobs"`
ReadCacheHits float64 `json:"read_cache_hits"`
ReadCacheOverload float64 `json:"read_cache_overload"`
TotalBuffersSize int `json:"total_buffers_size"`
TotalPeerConnections int `json:"total_peer_connections"`
TotalQueuedSize int `json:"total_queued_size"`
TotalWastedSession int `json:"total_wasted_session"`
WriteCacheOverload float64 `json:"write_cache_overload"`
}
func (s *ServerState) UnmarshalJSON(data []byte) error {
var raw rawServerState
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
globalRatio, err := strconv.ParseFloat(raw.GlobalRatio, 64)
if err != nil {
return err
}
readCacheHits, err := strconv.ParseFloat(raw.ReadCacheHits, 64)
if err != nil {
return err
}
readCacheOverload, err := strconv.ParseFloat(raw.ReadCacheOverload, 64)
if err != nil {
return err
}
writeCacheOverload, err := strconv.ParseFloat(raw.WriteCacheOverload, 64)
if err != nil {
return err
}
*s = ServerState{
TransferInfo: raw.TransferInfo,
AlltimeDl: raw.AlltimeDl,
AlltimeUl: raw.AlltimeUl,
AverageTimeQueue: raw.AverageTimeQueue,
FreeSpaceOnDisk: raw.FreeSpaceOnDisk,
GlobalRatio: globalRatio,
QueuedIoJobs: raw.QueuedIoJobs,
ReadCacheHits: readCacheHits,
ReadCacheOverload: readCacheOverload,
TotalBuffersSize: raw.TotalBuffersSize,
TotalPeerConnections: raw.TotalPeerConnections,
TotalQueuedSize: raw.TotalQueuedSize,
TotalWastedSession: raw.TotalWastedSession,
WriteCacheOverload: writeCacheOverload,
}
return nil
}
type rawServerState struct {
TransferInfo
AlltimeDl int `json:"alltime_dl"`
AlltimeUl int `json:"alltime_ul"`
AverageTimeQueue int `json:"average_time_queue"`
FreeSpaceOnDisk int `json:"free_space_on_disk"`
GlobalRatio string `json:"global_ratio"`
QueuedIoJobs int `json:"queued_io_jobs"`
ReadCacheHits string `json:"read_cache_hits"`
ReadCacheOverload string `json:"read_cache_overload"`
TotalBuffersSize int `json:"total_buffers_size"`
TotalPeerConnections int `json:"total_peer_connections"`
TotalQueuedSize int `json:"total_queued_size"`
TotalWastedSession int `json:"total_wasted_session"`
WriteCacheOverload string `json:"write_cache_overload"`
}

View File

@@ -0,0 +1,12 @@
package qbittorrent_model
type SyncMainData struct {
RID int `json:"rid"`
FullUpdate bool `json:"full_update"`
Torrents map[string]*Torrent `json:"torrents"`
TorrentsRemoved []string `json:"torrents_removed"`
Categories map[string]Category `json:"categories"`
CategoriesRemoved map[string]Category `json:"categories_removed"`
Queueing bool `json:"queueing"`
ServerState ServerState `json:"server_state"`
}

View File

@@ -0,0 +1,8 @@
package qbittorrent_model
type SyncPeersData struct {
FullUpdate bool `json:"full_update"`
Peers map[string]Peer `json:"peers"`
RID int `json:"rid"`
ShowFlags bool `json:"show_flags"`
}

View File

@@ -0,0 +1,119 @@
package qbittorrent_model
type Torrent struct {
// Torrent hash
Hash string `json:"hash"`
// Torrent name
Name string `json:"name"`
// Total size (bytes) of files selected for download
Size int `json:"size"`
// Torrent progress (percentage/100)
Progress float64 `json:"progress"`
// Torrent download speed (bytes/s)
Dlspeed int `json:"dlspeed"`
// Torrent upload speed (bytes/s)
Upspeed int `json:"upspeed"`
// Torrent priority. Returns -1 if queuing is disabled or torrent is in seed mode
Priority int `json:"priority"`
// Number of seeds connected to
NumSeeds int `json:"num_seeds"`
// Number of seeds in the swarm
NumComplete int `json:"num_complete"`
// Number of leechers connected to
NumLeechs int `json:"num_leechs"`
// Number of leechers in the swarm
NumIncomplete int `json:"num_incomplete"`
// Torrent share ratio. Max ratio value: 9999.
Ratio float64 `json:"ratio"`
// Torrent ETA (seconds)
Eta int `json:"eta"`
// Torrent state. See table here below for the possible values
State TorrentState `json:"state"`
// True if sequential download is enabled
SeqDl bool `json:"seq_dl"`
// True if first last piece are prioritized
FLPiecePrio bool `json:"f_l_piece_prio"`
// Category of the torrent
Category string `json:"category"`
// True if super seeding is enabled
SuperSeeding bool `json:"super_seeding"`
// True if force start is enabled for this torrent
ForceStart bool `json:"force_start"`
// New added fields
AddedOn int `json:"added_on"`
AmountLeft int `json:"amount_left"`
AutoTmm bool `json:"auto_tmm"`
Availability float64 `json:"availability"`
Completed int64 `json:"completed"`
CompletionOn int `json:"completion_on"`
ContentPath string `json:"content_path"`
DlLimit int `json:"dl_limit"`
DownloadPath string `json:"download_path"`
Downloaded int64 `json:"downloaded"`
DownloadedSession int `json:"downloaded_session"`
InfohashV1 string `json:"infohash_v1"`
InfohashV2 string `json:"infohash_v2"`
LastActivity int `json:"last_activity"`
MagnetUri string `json:"magnet_uri"`
MaxRatio int `json:"max_ratio"`
MaxSeedingTime int `json:"max_seeding_time"`
RatioLimit int `json:"ratio_limit"`
SavePath string `json:"save_path"`
SeedingTime int `json:"seeding_time"`
SeedingTimeLimit int `json:"seeding_time_limit"`
SeenComplete int `json:"seen_complete"`
Tags string `json:"tags"`
TimeActive int `json:"time_active"`
TotalSize int64 `json:"total_size"`
Tracker string `json:"tracker"`
TrackersCount int `json:"trackers_count"`
UpLimit int `json:"up_limit"`
Uploaded int64 `json:"uploaded"`
UploadedSession int64 `json:"uploaded_session"`
}
type TorrentState string
const (
// Some error occurred, applies to paused torrents
StateError TorrentState = "error"
// Torrent data files is missing
StateMissingFiles TorrentState = "missingFiles"
// Torrent is being seeded and data is being transferred
StateUploading TorrentState = "uploading"
// Torrent is paused and has finished downloading
StatePausedUP TorrentState = "pausedUP"
StateStoppedUP TorrentState = "stoppedUP"
// Queuing is enabled and torrent is queued for upload
StateQueuedUP TorrentState = "queuedUP"
// Torrent is being seeded, but no connection were made
StateStalledUP TorrentState = "stalledUP"
// Torrent has finished downloading and is being checked
StateCheckingUP TorrentState = "checkingUP"
// Torrent is forced to uploading and ignore queue limit
StateForcedUP TorrentState = "forcedUP"
// Torrent is allocating disk space for download
StateAllocating TorrentState = "allocating"
// Torrent is being downloaded and data is being transferred
StateDownloading TorrentState = "downloading"
// Torrent has just started downloading and is fetching metadata
StateMetaDL TorrentState = "metaDL"
// Torrent is paused and has NOT finished downloading
StatePausedDL TorrentState = "pausedDL"
StateStoppedDL TorrentState = "stoppedDL"
// Queuing is enabled and torrent is queued for download
StateQueuedDL TorrentState = "queuedDL"
// Torrent is being downloaded, but no connection were made
StateStalledDL TorrentState = "stalledDL"
// Same as checkingUP, but torrent has NOT finished downloading
StateCheckingDL TorrentState = "checkingDL"
// Torrent is forced to downloading to ignore queue limit
StateForceDL TorrentState = "forceDL"
// Checking resume data on qBt startup
StateCheckingResumeData TorrentState = "checkingResumeData"
// Torrent is moving to another location
StateMoving TorrentState = "moving"
// Unknown status
StateUnknown TorrentState = "unknown"
)

View File

@@ -0,0 +1,27 @@
package qbittorrent_model
type TorrentContent struct {
// File name (including relative path)
Name string `json:" name"`
// File size (bytes)
Size int `json:" size"`
// File progress (percentage/100)
Progress float64 `json:" progress"`
// File priority. See possible values here below
Priority TorrentPriority `json:" priority"`
// True if file is seeding/complete
IsSeed bool `json:" is_seed"`
// The first number is the starting piece index and the second number is the ending piece index (inclusive)
PieceRange []int `json:" piece_range"`
// Percentage of file pieces currently available
Availability float64 `json:" availability"`
}
type TorrentPriority int
const (
PriorityDoNotDownload TorrentPriority = 0
PriorityNormal = 1
PriorityHigh = 6
PriorityMaximum = 7
)

View File

@@ -0,0 +1,9 @@
package qbittorrent_model
type TorrentPieceState int
const (
PieceStateNotDownloaded TorrentPieceState = iota
PieceStateDownloading
PieceStateDownloaded
)

View File

@@ -0,0 +1,194 @@
package qbittorrent_model
import (
"encoding/json"
"time"
)
type TorrentProperties struct {
// Torrent save path
SavePath string `json:"save_path"`
// Torrent creation date (Unix timestamp)
CreationDate time.Time `json:"creation_date"`
// Torrent piece size (bytes)
PieceSize int `json:"piece_size"`
// Torrent comment
Comment string `json:"comment"`
// Total data wasted for torrent (bytes)
TotalWasted int `json:"total_wasted"`
// Total data uploaded for torrent (bytes)
TotalUploaded int `json:"total_uploaded"`
// Total data uploaded this session (bytes)
TotalUploadedSession int `json:"total_uploaded_session"`
// Total data downloaded for torrent (bytes)
TotalDownloaded int `json:"total_downloaded"`
// Total data downloaded this session (bytes)
TotalDownloadedSession int `json:"total_downloaded_session"`
// Torrent upload limit (bytes/s)
UpLimit int `json:"up_limit"`
// Torrent download limit (bytes/s)
DlLimit int `json:"dl_limit"`
// Torrent elapsed time (seconds)
TimeElapsed int `json:"time_elapsed"`
// Torrent elapsed time while complete (seconds)
SeedingTime time.Duration `json:"seeding_time"`
// Torrent connection count
NbConnections int `json:"nb_connections"`
// Torrent connection count limit
NbConnectionsLimit int `json:"nb_connections_limit"`
// Torrent share ratio
ShareRatio float64 `json:"share_ratio"`
// When this torrent was added (unix timestamp)
AdditionDate time.Time `json:"addition_date"`
// Torrent completion date (unix timestamp)
CompletionDate time.Time `json:"completion_date"`
// Torrent creator
CreatedBy string `json:"created_by"`
// Torrent average download speed (bytes/second)
DlSpeedAvg int `json:"dl_speed_avg"`
// Torrent download speed (bytes/second)
DlSpeed int `json:"dl_speed"`
// Torrent ETA (seconds)
Eta time.Duration `json:"eta"`
// Last seen complete date (unix timestamp)
LastSeen time.Time `json:"last_seen"`
// Number of peers connected to
Peers int `json:"peers"`
// Number of peers in the swarm
PeersTotal int `json:"peers_total"`
// Number of pieces owned
PiecesHave int `json:"pieces_have"`
// Number of pieces of the torrent
PiecesNum int `json:"pieces_num"`
// Number of seconds until the next announce
Reannounce time.Duration `json:"reannounce"`
// Number of seeds connected to
Seeds int `json:"seeds"`
// Number of seeds in the swarm
SeedsTotal int `json:"seeds_total"`
// Torrent total size (bytes)
TotalSize int `json:"total_size"`
// Torrent average upload speed (bytes/second)
UpSpeedAvg int `json:"up_speed_avg"`
// Torrent upload speed (bytes/second)
UpSpeed int `json:"up_speed"`
}
func (p *TorrentProperties) UnmarshalJSON(data []byte) error {
var raw rawTorrentProperties
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
creationDate := time.Unix(int64(raw.CreationDate), 0)
seedingTime := time.Duration(raw.SeedingTime) * time.Second
additionDate := time.Unix(int64(raw.AdditionDate), 0)
completionDate := time.Unix(int64(raw.CompletionDate), 0)
eta := time.Duration(raw.Eta) * time.Second
lastSeen := time.Unix(int64(raw.LastSeen), 0)
reannounce := time.Duration(raw.Reannounce) * time.Second
*p = TorrentProperties{
SavePath: raw.SavePath,
CreationDate: creationDate,
PieceSize: raw.PieceSize,
Comment: raw.Comment,
TotalWasted: raw.TotalWasted,
TotalUploaded: raw.TotalUploaded,
TotalUploadedSession: raw.TotalUploadedSession,
TotalDownloaded: raw.TotalDownloaded,
TotalDownloadedSession: raw.TotalDownloadedSession,
UpLimit: raw.UpLimit,
DlLimit: raw.DlLimit,
TimeElapsed: raw.TimeElapsed,
SeedingTime: seedingTime,
NbConnections: raw.NbConnections,
NbConnectionsLimit: raw.NbConnectionsLimit,
ShareRatio: raw.ShareRatio,
AdditionDate: additionDate,
CompletionDate: completionDate,
CreatedBy: raw.CreatedBy,
DlSpeedAvg: raw.DlSpeedAvg,
DlSpeed: raw.DlSpeed,
Eta: eta,
LastSeen: lastSeen,
Peers: raw.Peers,
PeersTotal: raw.PeersTotal,
PiecesHave: raw.PiecesHave,
PiecesNum: raw.PiecesNum,
Reannounce: reannounce,
Seeds: raw.Seeds,
SeedsTotal: raw.SeedsTotal,
TotalSize: raw.TotalSize,
UpSpeedAvg: raw.UpSpeedAvg,
UpSpeed: raw.UpSpeed,
}
return nil
}
type rawTorrentProperties struct {
// Torrent save path
SavePath string `json:"save_path"`
// Torrent creation date (Unix timestamp)
CreationDate int `json:"creation_date"`
// Torrent piece size (bytes)
PieceSize int `json:"piece_size"`
// Torrent comment
Comment string `json:"comment"`
// Total data wasted for torrent (bytes)
TotalWasted int `json:"total_wasted"`
// Total data uploaded for torrent (bytes)
TotalUploaded int `json:"total_uploaded"`
// Total data uploaded this session (bytes)
TotalUploadedSession int `json:"total_uploaded_session"`
// Total data downloaded for torrent (bytes)
TotalDownloaded int `json:"total_downloaded"`
// Total data downloaded this session (bytes)
TotalDownloadedSession int `json:"total_downloaded_session"`
// Torrent upload limit (bytes/s)
UpLimit int `json:"up_limit"`
// Torrent download limit (bytes/s)
DlLimit int `json:"dl_limit"`
// Torrent elapsed time (seconds)
TimeElapsed int `json:"time_elapsed"`
// Torrent elapsed time while complete (seconds)
SeedingTime int `json:"seeding_time"`
// Torrent connection count
NbConnections int `json:"nb_connections"`
// Torrent connection count limit
NbConnectionsLimit int `json:"nb_connections_limit"`
// Torrent share ratio
ShareRatio float64 `json:"share_ratio"`
// When this torrent was added (unix timestamp)
AdditionDate int `json:"addition_date"`
// Torrent completion date (unix timestamp)
CompletionDate int `json:"completion_date"`
// Torrent creator
CreatedBy string `json:"created_by"`
// Torrent average download speed (bytes/second)
DlSpeedAvg int `json:"dl_speed_avg"`
// Torrent download speed (bytes/second)
DlSpeed int `json:"dl_speed"`
// Torrent ETA (seconds)
Eta int `json:"eta"`
// Last seen complete date (unix timestamp)
LastSeen int `json:"last_seen"`
// Number of peers connected to
Peers int `json:"peers"`
// Number of peers in the swarm
PeersTotal int `json:"peers_total"`
// Number of pieces owned
PiecesHave int `json:"pieces_have"`
// Number of pieces of the torrent
PiecesNum int `json:"pieces_num"`
// Number of seconds until the next announce
Reannounce int `json:"reannounce"`
// Number of seeds connected to
Seeds int `json:"seeds"`
// Number of seeds in the swarm
SeedsTotal int `json:"seeds_total"`
// Torrent total size (bytes)
TotalSize int `json:"total_size"`
// Torrent average upload speed (bytes/second)
UpSpeedAvg int `json:"up_speed_avg"`
// Torrent upload speed (bytes/second)
UpSpeed int `json:"up_speed"`
}

View File

@@ -0,0 +1,22 @@
package qbittorrent_model
type TorrentTracker struct {
URL string `json:"url"`
Status TrackerStatus `json:"status"`
Tier int `json:"tier"`
NumPeers int `json:"num_peers"`
NumSeeds int `json:"num_seeds"`
NumLeeches int `json:"num_leeches"`
NumDownloaded int `json:"num_downloaded"`
Message string `json:"msg"`
}
type TrackerStatus int
const (
TrackerStatusDisabled TrackerStatus = iota
TrackerStatusNotContacted
TrackerStatusWorking
TrackerStatusUpdating
TrackerStatusNotWorking
)

View File

@@ -0,0 +1,23 @@
package qbittorrent_model
type TransferInfo struct {
ConnectionStatus ConnectionStatus `json:"connection_status"`
DhtNodes int `json:"dht_nodes"`
DlInfoData int `json:"dl_info_data"`
DlInfoSpeed int `json:"dl_info_speed"`
DlRateLimit int `json:"dl_rate_limit"`
UpInfoData int `json:"up_info_data"`
UpInfoSpeed int `json:"up_info_speed"`
UpRateLimit int `json:"up_rate_limit"`
UseAltSpeedLimits bool `json:"use_alt_speed_limits"`
Queueing bool `json:"queueing"`
RefreshInterval int `json:"refresh_interval"`
}
type ConnectionStatus string
const (
StatusConnected ConnectionStatus = "connected"
StatusFirewalled = "firewalled"
StatusDisconnected = "disconnected"
)