Documentation
¶
Index ¶
- Constants
- Variables
- func Escape2Anscii(s string) string
- func GenerateReseed2LocalSiteMap(reseedSites []Site, localSites []*config.SiteConfigStruct) map[string]string
- func GetReseedTorrents(username string, password string, sites []*config.SiteConfigStruct, ...) (results []*Torrent, results2 []*Torrent, err error)
- func Login(username string, password string) (token string, err error)
- type File
- type ReseedLoginResult
- type ReseedResult
- type ReseedResultSite
- type Site
- type Torrent
Constants ¶
const RESEED_API = "https://reseed-api.tongyifan.me/"
Reseed API backend: https://github.com/tongyifan/Reseed-backend , it's a sock.io server, with the main websocket API and some additional RESTful APIs. All APIs (except "login" API) requires authorization token in header: "Authorization: Bearar <token>". To acquire token: POST https://reseed-api.tongyifan.me/login with username & password, receive json {msg, success: true, token}. token is ephemeral, expires in 1 day. Note for websocket API, if token does NOT exists, server will return 500 error when connecting; however, if token exists but is expired or invalid, server will just hang (do NOT response to any request). The websocket API uses sock.io events: "file" event: client -> server. "reseed result" event: server -> client. Note the websocket API ONLY accept frames that is pure ASCII, all unicode characters in JSON must be encoded in '\uXXXX' format.
Variables ¶
var Command = &cobra.Command{
Use: "reseed",
Short: "Cross seed automation tool using Reseed (https://github.com/tongyifan/Reseed-backend) API.",
Long: `Cross seed automation tool using Reseed (https://github.com/tongyifan/Reseed-backend) API.`,
}
Functions ¶
func Escape2Anscii ¶
Escape all unicode (non-ASCII) characters to '\uXXXX' format.
func GenerateReseed2LocalSiteMap ¶
func GenerateReseed2LocalSiteMap(reseedSites []Site, localSites []*config.SiteConfigStruct) map[string]string
return ReseedSite => localSiteName map
func GetReseedTorrents ¶
func GetReseedTorrents(username string, password string, sites []*config.SiteConfigStruct, timeout int64, savePath ...string) (results []*Torrent, results2 []*Torrent, err error)
Request Reseed API and return xseed torrents (full match (success) & partial match (warning) results) found by Reseed backend.
Types ¶
type File ¶
the "file" event payload of Reseed sock.io API
func (File) MarshalJSON ¶
It's performance is terrible, but who cares?
type ReseedLoginResult ¶
type ReseedResult ¶
type ReseedResult struct {
Name string `json:"name,omitempty"`
CmpSuccess []ReseedResultSite `json:"cmp_success,omitempty"`
CmpWarning []ReseedResultSite `json:"cmp_warning,omitempty"`
}
the 'reseed result' event returned by Reseed backend see https://github.com/tongyifan/Reseed-backend/blob/890dfcb20b98684bf315c8c9f5352c062ae93166/views/reseed.py#L57
type ReseedResultSite ¶
type Site ¶
type Site struct {
BaseUrl string `json:"base_url,omitempty"` // e.g. "https://hdtime.org/"
Name string `json:"name,omitempty"` // e.g. "HDTIME"
}
func (*Site) MatchFilter ¶
type Torrent ¶
type Torrent struct {
Id string // local site torrent id, e.g. hdupt.23456
ReseedId string // Reseed torrent id, e.g. HDU-23456
SavePath string // Local path of torrent contents, e.g. D:\Downloads
Filename string // Filename of torrent content file or root folder
Success bool // true: a full match (success). false: partial-match (warning)
}