-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8067f9
commit 6a5c105
Showing
10 changed files
with
2,062 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Include any files or directories that you don't want to be copied to your | ||
# container here (e.g., local build artifacts, temporary files, etc.). | ||
# | ||
# For more help, visit the .dockerignore file reference guide at | ||
# https://docs.docker.com/engine/reference/builder/#dockerignore-file | ||
|
||
**/.DS_Store | ||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
LICENSE | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./main.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
go-qbittorrent | ||
================== | ||
|
||
Golang wrapper for qBittorrent Web API (for versions above v4.1) forked from [superturkey650](https://github.com/superturkey650/go-qbittorrent) version (only supporting older API version) | ||
|
||
This wrapper is based on the methods described in [qBittorrent's Official Web API](https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)>) | ||
|
||
Some methods are only supported in qBittorent's latest version (v4.5 when writing). | ||
|
||
It'll be best if you upgrade your client to a latest version. | ||
|
||
An example can be found in main.go | ||
|
||
Installation | ||
============ | ||
|
||
The best way is to install with go get:: | ||
|
||
$ go get github.com/simon-ding/go-qbittorrent/qbt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,260 @@ | ||
PACKAGE DOCUMENTATION | ||
|
||
package qbt | ||
import "/Users/me/Repos/go/src/go-qbittorrent/qbt" | ||
|
||
|
||
TYPES | ||
|
||
type BasicTorrent struct { | ||
AddedOn int `json:"added_on"` | ||
Category string `json:"category"` | ||
CompletionOn int64 `json:"completion_on"` | ||
Dlspeed int `json:"dlspeed"` | ||
Eta int `json:"eta"` | ||
ForceStart bool `json:"force_start"` | ||
Hash string `json:"hash"` | ||
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 int `json:"progress"` | ||
Ratio int `json:"ratio"` | ||
SavePath string `json:"save_path"` | ||
SeqDl bool `json:"seq_dl"` | ||
Size int `json:"size"` | ||
State string `json:"state"` | ||
SuperSeeding bool `json:"super_seeding"` | ||
Upspeed int `json:"upspeed"` | ||
} | ||
BasicTorrent holds a basic torrent object from qbittorrent | ||
|
||
type Client struct { | ||
URL string | ||
Authenticated bool | ||
Session string //replace with session type | ||
Jar http.CookieJar | ||
// contains filtered or unexported fields | ||
} | ||
Client creates a connection to qbittorrent and performs requests | ||
|
||
func NewClient(url string) *Client | ||
NewClient creates a new client connection to qbittorrent | ||
|
||
func (c *Client) AddTrackers(infoHash string, trackers string) (*http.Response, error) | ||
AddTrackers adds trackers to a specific torrent | ||
|
||
func (c *Client) DecreasePriority(infoHashList []string) (*http.Response, error) | ||
DecreasePriority decreases the priority of a list of torrents | ||
|
||
func (c *Client) DeletePermanently(infoHashList []string) (*http.Response, error) | ||
DeletePermanently deletes all files for a list of torrents | ||
|
||
func (c *Client) DeleteTemp(infoHashList []string) (*http.Response, error) | ||
DeleteTemp deletes the temporary files for a list of torrents | ||
|
||
func (c *Client) DownloadFromFile(file string, options map[string]string) (*http.Response, error) | ||
DownloadFromFile downloads a torrent from a file | ||
|
||
func (c *Client) DownloadFromLink(link string, options map[string]string) (*http.Response, error) | ||
DownloadFromLink starts downloading a torrent from a link | ||
|
||
func (c *Client) ForceStart(infoHashList []string, value bool) (*http.Response, error) | ||
ForceStart force starts a list of torrents | ||
|
||
func (c *Client) GetAlternativeSpeedStatus() (status bool, err error) | ||
GetAlternativeSpeedStatus gets the alternative speed status of your | ||
qbittorrent client | ||
|
||
func (c *Client) GetGlobalDownloadLimit() (limit int, err error) | ||
GetGlobalDownloadLimit gets the global download limit of your | ||
qbittorrent client | ||
|
||
func (c *Client) GetGlobalUploadLimit() (limit int, err error) | ||
GetGlobalUploadLimit gets the global upload limit of your qbittorrent | ||
client | ||
|
||
func (c *Client) GetTorrentDownloadLimit(infoHashList []string) (limits map[string]string, err error) | ||
GetTorrentDownloadLimit gets the download limit for a list of torrents | ||
|
||
func (c *Client) GetTorrentUploadLimit(infoHashList []string) (limits map[string]string, err error) | ||
GetTorrentUploadLimit gets the upload limit for a list of torrents | ||
|
||
func (c *Client) IncreasePriority(infoHashList []string) (*http.Response, error) | ||
IncreasePriority increases the priority of a list of torrents | ||
|
||
func (c *Client) Login(username string, password string) (loggedIn bool, err error) | ||
Login logs you in to the qbittorrent client | ||
|
||
func (c *Client) Logout() (loggedOut bool, err error) | ||
Logout logs you out of the qbittorrent client | ||
|
||
func (c *Client) Pause(infoHash string) (*http.Response, error) | ||
Pause pauses a specific torrent | ||
|
||
func (c *Client) PauseAll() (*http.Response, error) | ||
PauseAll pauses all torrents | ||
|
||
func (c *Client) PauseMultiple(infoHashList []string) (*http.Response, error) | ||
PauseMultiple pauses a list of torrents | ||
|
||
func (c *Client) Recheck(infoHashList []string) (*http.Response, error) | ||
Recheck rechecks a list of torrents | ||
|
||
func (c *Client) Resume(infoHash string) (*http.Response, error) | ||
Resume resumes a specific torrent | ||
|
||
func (c *Client) ResumeAll(infoHashList []string) (*http.Response, error) | ||
ResumeAll resumes all torrents | ||
|
||
func (c *Client) ResumeMultiple(infoHashList []string) (*http.Response, error) | ||
ResumeMultiple resumes a list of torrents | ||
|
||
func (c *Client) SetCategory(infoHashList []string, category string) (*http.Response, error) | ||
SetCategory sets the category for a list of torrents | ||
|
||
func (c *Client) SetFilePriority(infoHash string, fileID string, priority string) (*http.Response, error) | ||
SetFilePriority sets the priority for a specific torrent file | ||
|
||
func (c *Client) SetGlobalDownloadLimit(limit string) (*http.Response, error) | ||
SetGlobalDownloadLimit sets the global download limit of your | ||
qbittorrent client | ||
|
||
func (c *Client) SetGlobalUploadLimit(limit string) (*http.Response, error) | ||
SetGlobalUploadLimit sets the global upload limit of your qbittorrent | ||
client | ||
|
||
func (c *Client) SetLabel(infoHashList []string, label string) (*http.Response, error) | ||
SetLabel sets the labels for a list of torrents | ||
|
||
func (c *Client) SetMaxPriority(infoHashList []string) (*http.Response, error) | ||
SetMaxPriority sets the max priority for a list of torrents | ||
|
||
func (c *Client) SetMinPriority(infoHashList []string) (*http.Response, error) | ||
SetMinPriority sets the min priority for a list of torrents | ||
|
||
func (c *Client) SetPreferences(params map[string]string) (*http.Response, error) | ||
SetPreferences sets the preferences of your qbittorrent client | ||
|
||
func (c *Client) SetTorrentDownloadLimit(infoHashList []string, limit string) (*http.Response, error) | ||
SetTorrentDownloadLimit sets the download limit for a list of torrents | ||
|
||
func (c *Client) SetTorrentUploadLimit(infoHashList []string, limit string) (*http.Response, error) | ||
SetTorrentUploadLimit sets the upload limit of a list of torrents | ||
|
||
func (c *Client) Shutdown() (shuttingDown bool, err error) | ||
Shutdown shuts down the qbittorrent client | ||
|
||
func (c *Client) Sync(rid string) (Sync, error) | ||
Sync syncs main data of qbittorrent | ||
|
||
func (c *Client) ToggleAlternativeSpeed() (*http.Response, error) | ||
ToggleAlternativeSpeed toggles the alternative speed of your qbittorrent | ||
client | ||
|
||
func (c *Client) ToggleFirstLastPiecePriority(infoHashList []string) (*http.Response, error) | ||
ToggleFirstLastPiecePriority toggles first last piece priority of a list | ||
of torrents | ||
|
||
func (c *Client) ToggleSequentialDownload(infoHashList []string) (*http.Response, error) | ||
ToggleSequentialDownload toggles the download sequence of a list of | ||
torrents | ||
|
||
func (c *Client) Torrent(infoHash string) (Torrent, error) | ||
Torrent gets a specific torrent | ||
|
||
func (c *Client) TorrentFiles(infoHash string) ([]TorrentFile, error) | ||
TorrentFiles gets the files of a specifc torrent | ||
|
||
func (c *Client) TorrentTrackers(infoHash string) ([]Tracker, error) | ||
TorrentTrackers gets all trackers for a specific torrent | ||
|
||
func (c *Client) TorrentWebSeeds(infoHash string) ([]WebSeed, error) | ||
TorrentWebSeeds gets seeders for a specific torrent | ||
|
||
func (c *Client) Torrents(filters map[string]string) (torrentList []BasicTorrent, err error) | ||
Torrents gets a list of all torrents in qbittorrent matching your filter | ||
|
||
type Sync struct { | ||
Categories []string `json:"categories"` | ||
FullUpdate bool `json:"full_update"` | ||
Rid int `json:"rid"` | ||
ServerState struct { | ||
ConnectionStatus string `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"` | ||
Queueing bool `json:"queueing"` | ||
RefreshInterval int `json:"refresh_interval"` | ||
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"` | ||
} `json:"server_state"` | ||
Torrents map[string]Torrent `json:"torrents"` | ||
} | ||
Sync holds the sync response struct | ||
|
||
type Torrent struct { | ||
AdditionDate int `json:"addition_date"` | ||
Comment string `json:"comment"` | ||
CompletionDate int `json:"completion_date"` | ||
CreatedBy string `json:"created_by"` | ||
CreationDate int `json:"creation_date"` | ||
DlLimit int `json:"dl_limit"` | ||
DlSpeed int `json:"dl_speed"` | ||
DlSpeedAvg int `json:"dl_speed_avg"` | ||
Eta int `json:"eta"` | ||
LastSeen int `json:"last_seen"` | ||
NbConnections int `json:"nb_connections"` | ||
NbConnectionsLimit int `json:"nb_connections_limit"` | ||
Peers int `json:"peers"` | ||
PeersTotal int `json:"peers_total"` | ||
PieceSize int `json:"piece_size"` | ||
PiecesHave int `json:"pieces_have"` | ||
PiecesNum int `json:"pieces_num"` | ||
Reannounce int `json:"reannounce"` | ||
SavePath string `json:"save_path"` | ||
SeedingTime int `json:"seeding_time"` | ||
Seeds int `json:"seeds"` | ||
SeedsTotal int `json:"seeds_total"` | ||
ShareRatio float64 `json:"share_ratio"` | ||
TimeElapsed int `json:"time_elapsed"` | ||
TotalDownloaded int `json:"total_downloaded"` | ||
TotalDownloadedSession int `json:"total_downloaded_session"` | ||
TotalSize int `json:"total_size"` | ||
TotalUploaded int `json:"total_uploaded"` | ||
TotalUploadedSession int `json:"total_uploaded_session"` | ||
TotalWasted int `json:"total_wasted"` | ||
UpLimit int `json:"up_limit"` | ||
UpSpeed int `json:"up_speed"` | ||
UpSpeedAvg int `json:"up_speed_avg"` | ||
} | ||
Torrent holds a torrent object from qbittorrent | ||
|
||
type TorrentFile struct { | ||
IsSeed bool `json:"is_seed"` | ||
Name string `json:"name"` | ||
Priority int `json:"priority"` | ||
Progress int `json:"progress"` | ||
Size int `json:"size"` | ||
} | ||
TorrentFile holds a torrent file object from qbittorrent | ||
|
||
type Tracker struct { | ||
Msg string `json:"msg"` | ||
NumPeers int `json:"num_peers"` | ||
Status string `json:"status"` | ||
URL string `json:"url"` | ||
} | ||
Tracker holds a tracker object from qbittorrent | ||
|
||
type WebSeed struct { | ||
URL string `json:"url"` | ||
} | ||
WebSeed holds a webseed object from qbittorrent | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package qbittorrent | ||
|
||
import ( | ||
"fmt" | ||
"polaris/pkg/go-qbittorrent/qbt" | ||
|
||
"github.com/davecgh/go-spew/spew" | ||
) | ||
|
||
func main() { | ||
// connect to qbittorrent client | ||
qb := qbt.NewClient("http://localhost:8181") | ||
|
||
// login to the client | ||
loginOpts := qbt.LoginOptions{ | ||
Username: "username", | ||
Password: "password", | ||
} | ||
err := qb.Login(loginOpts) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
// ******************** | ||
// DOWNLOAD A TORRENT * | ||
// ******************** | ||
|
||
// were not using any filters so the options map is empty | ||
downloadOpts := qbt.DownloadOptions{} | ||
// set the path to the file | ||
//path := "/Users/me/Downloads/Source.Code.2011.1080p.BluRay.H264.AAC-RARBG-[rarbg.to].torrent" | ||
links := []string{"http://rarbg.to/download.php?id=9buc5hp&h=d73&f=Courage.the.Cowardly.Dog.1999.S01.1080p.AMZN.WEBRip.DD2.0.x264-NOGRP%5Brartv%5D-[rarbg.to].torrent"} | ||
// download the torrent using the file | ||
// the wrapper will handle opening and closing the file for you | ||
err = qb.DownloadLinks(links, downloadOpts) | ||
|
||
if err != nil { | ||
fmt.Println("[-] Download torrent from link") | ||
fmt.Println(err) | ||
} else { | ||
fmt.Println("[+] Download torrent from link") | ||
} | ||
|
||
// ****************** | ||
// GET ALL TORRENTS * | ||
// ****************** | ||
torrentsOpts := qbt.TorrentsOptions{} | ||
filter := "inactive" | ||
sort := "name" | ||
hash := "d739f78a12b241ba62719b1064701ffbb45498a8" | ||
torrentsOpts.Filter = &filter | ||
torrentsOpts.Sort = &sort | ||
torrentsOpts.Hashes = []string{hash} | ||
torrents, err := qb.Torrents(torrentsOpts) | ||
if err != nil { | ||
fmt.Println("[-] Get torrent list") | ||
fmt.Println(err) | ||
} else { | ||
fmt.Println("[+] Get torrent list") | ||
if len(torrents) > 0 { | ||
spew.Dump(torrents[0]) | ||
} else { | ||
fmt.Println("No torrents found") | ||
} | ||
} | ||
} |
Oops, something went wrong.