Documentation ¶
Index ¶
- Constants
- Variables
- func Aggregate(task *Task, wg *sync.WaitGroup)
- func DownloadStatusString(status int) string
- func ParseIndex(content []byte)
- func ParsePlaylist(content []byte)
- func UseDownloadReporter(reporter DownloadReporter)
- type DefaultDownloadReporter
- func (dr *DefaultDownloadReporter) OnDone(message *TrackerMessage) error
- func (dr *DefaultDownloadReporter) OnError(message *TrackerMessage) error
- func (dr *DefaultDownloadReporter) OnMerging(message *TrackerMessage) error
- func (dr *DefaultDownloadReporter) OnProgress(message *TrackerMessage) error
- func (dr *DefaultDownloadReporter) OnStart(message *TrackerMessage) error
- func (dr *DefaultDownloadReporter) OnTick() error
- func (dr *DefaultDownloadReporter) Processor() error
- type Dialer
- type Download
- type DownloadReporter
- type HttpClient
- func (c *HttpClient) CheckResource(task *Task, parameters url.Values, headers map[string]string) *Task
- func (c *HttpClient) CopyClient() HttpClient
- func (c *HttpClient) Do(req *http.Request) (*HttpResponse, error)
- func (c *HttpClient) DownloadFile(task *Task, parameters url.Values, headers map[string]string) error
- func (c *HttpClient) MakeGETRequest(URL string, parameters url.Values, headers map[string]string) (*http.Request, error)
- func (c *HttpClient) MakeHEADRequest(URL string, parameters url.Values, headers map[string]string) (*http.Request, error)
- func (c *HttpClient) MakeMultiPartPOSTRequest(URL, contentType string, postBody io.Reader, headers map[string]string) (*http.Request, error)
- func (c *HttpClient) MakeMultiPartPOSTRequestWithParameters(URL string, parameters url.Values, contentType string, postBody io.Reader, ...) (*http.Request, error)
- func (c *HttpClient) MakePOSTRequest(URL string, postFields, headers map[string]string) (*http.Request, error)
- func (c *HttpClient) MakePOSTRequestWithParameters(URL string, parameters url.Values, postFields, headers map[string]string) (*http.Request, error)
- func (c *HttpClient) MakePostFields(postFields map[string]string) io.Reader
- func (c *HttpClient) MakePostMultiPart(postFields map[string]string, files map[string]io.Reader, fieldNames []string) (io.Reader, string, error)
- func (c *HttpClient) MakeRawPOSTRequest(URL string, parameters url.Values, postBody io.Reader, ...) (*http.Request, error)
- func (c *HttpClient) SaveCookies() error
- func (c *HttpClient) SetCookiesWithStrings(cookieMap map[string][]*http.Cookie) error
- func (c *HttpClient) SetCookiesWithURLS(cookieMap map[*url.URL][]*http.Cookie) error
- func (c *HttpClient) SetProxy(proxyURLStr string) error
- func (c *HttpClient) StartThread(task *Task, started chan bool, parameters url.Values, ...) error
- type HttpClientOptions
- type HttpJSONResponse
- func (res *HttpJSONResponse) ArrayEach(cb func(value []byte, dataType jsonparser.ValueType, offset int, err error), ...) (offset int, err error)
- func (res *HttpJSONResponse) Delete(keys ...string) []byte
- func (res *HttpJSONResponse) EachKey(cb func(int, []byte, jsonparser.ValueType, error), paths ...[]string) int
- func (res *HttpJSONResponse) GetBoolean(keys ...string) (val bool, err error)
- func (res *HttpJSONResponse) GetFloat(keys ...string) (val float64, err error)
- func (res *HttpJSONResponse) GetInt(keys ...string) (val int64, err error)
- func (res *HttpJSONResponse) GetString(keys ...string) (val string, err error)
- func (res *HttpJSONResponse) GetUnsafeString(keys ...string) (val string, err error)
- func (res *HttpJSONResponse) ObjectEach(...) (err error)
- func (res *HttpJSONResponse) ParseString() (string, error)
- func (res *HttpJSONResponse) Set(setValue []byte, keys ...string) (value []byte, err error)
- type HttpResponse
- func (res *HttpResponse) Bytes() ([]byte, error)
- func (res *HttpResponse) Discard() error
- func (res *HttpResponse) HTML() (*soup.Root, error)
- func (res *HttpResponse) JSON() (*HttpJSONResponse, error)
- func (res *HttpResponse) Object(o interface{}) error
- func (res *HttpResponse) SaveToFile(filename string, permissions os.FileMode, overwrite, append bool) error
- func (res *HttpResponse) Text() (string, error)
- func (res *HttpResponse) XML() (*etree.Document, error)
- type M3U8File
- type M3U8FileList
- type M3U8Index
- type M3U8PlayList
- type RefererOptions
- type SSLPin
- type SSLPinner
- type Task
- type TrackerMessage
Constants ¶
View Source
const ( StatusStart = iota StatusProgress StatusError StatusDone StatusMerging )
Variables ¶
View Source
var DefaultGOKHTTPOptions = &HttpClientOptions{ JarOptions: &cookies.JarOptions{PublicSuffixList: publicsuffix.List, NoPersist: false, Filename: ".cookies", EncryptionPassword: ""}, Transport: &http.Transport{ TLSHandshakeTimeout: DefaultHTTPTimeout, DisableCompression: false, DisableKeepAlives: false, }, RefererOptions: &RefererOptions{Update: true, Use: true}, Timeout: &DefaultHTTPTimeout, }
proxyUrl, _ := url.Parse("http://127.0.0.1:8866")
View Source
var DefaultHTTPTimeout = time.Second * time.Duration(30)
View Source
var EmptyMap map[string]string
Functions ¶
func DownloadStatusString ¶
func ParseIndex ¶
func ParseIndex(content []byte)
func ParsePlaylist ¶
func ParsePlaylist(content []byte)
func UseDownloadReporter ¶
func UseDownloadReporter(reporter DownloadReporter)
Types ¶
type DefaultDownloadReporter ¶
type DefaultDownloadReporter struct { Ticker *time.Ticker Chan chan *TrackerMessage InProgress map[int]Download Done map[int]Download ShouldStop bool WaitTime int WaitGroup *sync.WaitGroup }
func GetDefaultDownloadReporter ¶
func GetDefaultDownloadReporter(channel chan *TrackerMessage, wg *sync.WaitGroup) *DefaultDownloadReporter
func (*DefaultDownloadReporter) OnDone ¶
func (dr *DefaultDownloadReporter) OnDone(message *TrackerMessage) error
func (*DefaultDownloadReporter) OnError ¶
func (dr *DefaultDownloadReporter) OnError(message *TrackerMessage) error
func (*DefaultDownloadReporter) OnMerging ¶
func (dr *DefaultDownloadReporter) OnMerging(message *TrackerMessage) error
func (*DefaultDownloadReporter) OnProgress ¶
func (dr *DefaultDownloadReporter) OnProgress(message *TrackerMessage) error
func (*DefaultDownloadReporter) OnStart ¶
func (dr *DefaultDownloadReporter) OnStart(message *TrackerMessage) error
func (*DefaultDownloadReporter) OnTick ¶
func (dr *DefaultDownloadReporter) OnTick() error
func (*DefaultDownloadReporter) Processor ¶
func (dr *DefaultDownloadReporter) Processor() error
type Dialer ¶
func MakeDialer ¶
type DownloadReporter ¶
type DownloadReporter interface { OnDone(message *TrackerMessage) error OnStart(message *TrackerMessage) error OnProgress(message *TrackerMessage) error OnError(message *TrackerMessage) error OnMerging(message *TrackerMessage) error OnTick() error Processor() error }
type HttpClient ¶
type HttpClient struct { Client *http.Client RefererOptions RefererOptions Headers map[string]string Context *context.Context CancelF context.CancelFunc ClientOptions *HttpClientOptions }
func GetHTTPClient ¶
func GetHTTPClient(o *HttpClientOptions) HttpClient
func GetHTTPDownloadClient ¶
func GetHTTPDownloadClient(o *HttpClientOptions) HttpClient
func (*HttpClient) CheckResource ¶
func (*HttpClient) CopyClient ¶
func (c *HttpClient) CopyClient() HttpClient
func (*HttpClient) Do ¶
func (c *HttpClient) Do(req *http.Request) (*HttpResponse, error)
func (*HttpClient) DownloadFile ¶
func (*HttpClient) MakeGETRequest ¶
func (*HttpClient) MakeHEADRequest ¶
func (*HttpClient) MakeMultiPartPOSTRequest ¶
func (*HttpClient) MakeMultiPartPOSTRequestWithParameters ¶
func (*HttpClient) MakePOSTRequest ¶
func (*HttpClient) MakePOSTRequestWithParameters ¶
func (*HttpClient) MakePostFields ¶
func (c *HttpClient) MakePostFields(postFields map[string]string) io.Reader
func (*HttpClient) MakePostMultiPart ¶
func (*HttpClient) MakeRawPOSTRequest ¶
func (*HttpClient) SaveCookies ¶
func (c *HttpClient) SaveCookies() error
func (*HttpClient) SetCookiesWithStrings ¶
func (c *HttpClient) SetCookiesWithStrings(cookieMap map[string][]*http.Cookie) error
func (*HttpClient) SetCookiesWithURLS ¶
func (*HttpClient) SetProxy ¶
func (c *HttpClient) SetProxy(proxyURLStr string) error
func (*HttpClient) StartThread ¶
type HttpClientOptions ¶
type HttpClientOptions struct { JarOptions *cookies.JarOptions Transport *http.Transport Timeout *time.Duration SSLPinningOptions *SSLPinner RefererOptions *RefererOptions RedirectPolicy func(req *http.Request, via []*http.Request) error Headers map[string]string Context *context.Context CancelF context.CancelFunc }
type HttpJSONResponse ¶
type HttpJSONResponse struct {
// contains filtered or unexported fields
}
func (*HttpJSONResponse) ArrayEach ¶
func (res *HttpJSONResponse) ArrayEach(cb func(value []byte, dataType jsonparser.ValueType, offset int, err error), keys ...string) (offset int, err error)
func (*HttpJSONResponse) Delete ¶
func (res *HttpJSONResponse) Delete(keys ...string) []byte
func (*HttpJSONResponse) EachKey ¶
func (res *HttpJSONResponse) EachKey(cb func(int, []byte, jsonparser.ValueType, error), paths ...[]string) int
func (*HttpJSONResponse) GetBoolean ¶
func (res *HttpJSONResponse) GetBoolean(keys ...string) (val bool, err error)
func (*HttpJSONResponse) GetFloat ¶
func (res *HttpJSONResponse) GetFloat(keys ...string) (val float64, err error)
func (*HttpJSONResponse) GetInt ¶
func (res *HttpJSONResponse) GetInt(keys ...string) (val int64, err error)
func (*HttpJSONResponse) GetString ¶
func (res *HttpJSONResponse) GetString(keys ...string) (val string, err error)
func (*HttpJSONResponse) GetUnsafeString ¶
func (res *HttpJSONResponse) GetUnsafeString(keys ...string) (val string, err error)
func (*HttpJSONResponse) ObjectEach ¶
func (res *HttpJSONResponse) ObjectEach(callback func(key []byte, value []byte, dataType jsonparser.ValueType, offset int) error, keys ...string) (err error)
func (*HttpJSONResponse) ParseString ¶
func (res *HttpJSONResponse) ParseString() (string, error)
type HttpResponse ¶
func (*HttpResponse) Bytes ¶
func (res *HttpResponse) Bytes() ([]byte, error)
func (*HttpResponse) Discard ¶
func (res *HttpResponse) Discard() error
func (*HttpResponse) JSON ¶
func (res *HttpResponse) JSON() (*HttpJSONResponse, error)
func (*HttpResponse) Object ¶
func (res *HttpResponse) Object(o interface{}) error
func (*HttpResponse) SaveToFile ¶
func (*HttpResponse) Text ¶
func (res *HttpResponse) Text() (string, error)
type M3U8FileList ¶
type M3U8Index ¶
type M3U8Index struct { PlayLists []M3U8PlayList RawValues map[string]string }
type M3U8PlayList ¶
type RefererOptions ¶
type Task ¶
type Task struct { Id int Name string Total uint64 // Whole file range downloaded as of yet Expected uint64 // Whole file size FragSize uint64 // If it's a fragment, the total size of the fragment CanResume bool Threads int URL string ThreadObjects []Task IsThread bool ProgressChannel chan *TrackerMessage }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.