perf(terabox): optimize prompt message (#3002)
* perf(terabox):prompt login status when init the driver * docs:add Terabox * perf(terabox):prompt area is not available * style(terabox): del else
This commit is contained in:
@ -17,10 +17,11 @@ import (
|
||||
func (d *Terabox) request(furl string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
|
||||
req := base.RestyClient.R()
|
||||
req.SetHeaders(map[string]string{
|
||||
"Cookie": d.Cookie,
|
||||
"Accept": "application/json, text/plain, */*",
|
||||
"Referer": "https://www.terabox.com/",
|
||||
"User-Agent": base.UserAgent,
|
||||
"Cookie": d.Cookie,
|
||||
"Accept": "application/json, text/plain, */*",
|
||||
"Referer": "https://www.terabox.com/",
|
||||
"User-Agent": base.UserAgent,
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
})
|
||||
req.SetQueryParam("app_id", "250528")
|
||||
req.SetQueryParam("web", "1")
|
||||
@ -41,13 +42,17 @@ func (d *Terabox) request(furl string, method string, callback base.ReqCallback,
|
||||
|
||||
func (d *Terabox) get(pathname string, params map[string]string, resp interface{}) ([]byte, error) {
|
||||
return d.request("https://www.terabox.com"+pathname, http.MethodGet, func(req *resty.Request) {
|
||||
req.SetQueryParams(params)
|
||||
if params != nil {
|
||||
req.SetQueryParams(params)
|
||||
}
|
||||
}, resp)
|
||||
}
|
||||
|
||||
func (d *Terabox) post(pathname string, params map[string]string, data interface{}, resp interface{}) ([]byte, error) {
|
||||
return d.request("https://www.terabox.com"+pathname, http.MethodPost, func(req *resty.Request) {
|
||||
req.SetQueryParams(params)
|
||||
if params != nil {
|
||||
req.SetQueryParams(params)
|
||||
}
|
||||
req.SetBody(data)
|
||||
}, resp)
|
||||
}
|
||||
@ -73,6 +78,9 @@ func (d *Terabox) getFiles(dir string) ([]File, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if resp.Errno == 9000 {
|
||||
return nil, fmt.Errorf("terabox is not yet available in this area")
|
||||
}
|
||||
if len(resp.List) == 0 {
|
||||
break
|
||||
}
|
||||
|
Reference in New Issue
Block a user