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:
Code2qing
2023-01-12 19:40:38 +08:00
committed by GitHub
parent 48e6f3bb23
commit 1eca2b83ed
4 changed files with 37 additions and 15 deletions

View File

@ -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
}