mirror of https://github.com/Xhofe/alist
🐛 fix some lanzou can't down #360
parent
0648fdebc2
commit
5c759217cf
|
@ -33,17 +33,19 @@ func (driver Lanzou) Items() []base.Item {
|
||||||
Label: "cookie",
|
Label: "cookie",
|
||||||
Type: base.TypeString,
|
Type: base.TypeString,
|
||||||
Description: "about 15 days valid",
|
Description: "about 15 days valid",
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "site_url",
|
||||||
|
Label: "share url",
|
||||||
|
Type: base.TypeString,
|
||||||
|
Required: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "root_folder",
|
Name: "root_folder",
|
||||||
Label: "root folder file_id",
|
Label: "root folder file_id",
|
||||||
Type: base.TypeString,
|
Type: base.TypeString,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Name: "site_url",
|
|
||||||
Label: "share url",
|
|
||||||
Type: base.TypeString,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
Name: "password",
|
Name: "password",
|
||||||
Label: "share password",
|
Label: "share password",
|
||||||
|
@ -130,7 +132,7 @@ func (driver Lanzou) Link(args base.Args, account *model.Account) (*base.Link, e
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
url, err := driver.GetLink(downId)
|
url, err := driver.GetLink(downId, account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/Xhofe/alist/utils"
|
"github.com/Xhofe/alist/utils"
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -103,6 +104,10 @@ func (driver *Lanzou) GetFiles(folderId string, account *model.Account) ([]LanZo
|
||||||
func (driver *Lanzou) GetFilesByUrl(account *model.Account) ([]LanZouFile, error) {
|
func (driver *Lanzou) GetFilesByUrl(account *model.Account) ([]LanZouFile, error) {
|
||||||
files := make([]LanZouFile, 0)
|
files := make([]LanZouFile, 0)
|
||||||
shareUrl := account.SiteUrl
|
shareUrl := account.SiteUrl
|
||||||
|
u, err := url.Parse(shareUrl)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
res, err := lanzouClient.R().Get(shareUrl)
|
res, err := lanzouClient.R().Get(shareUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -135,7 +140,7 @@ func (driver *Lanzou) GetFilesByUrl(account *model.Account) ([]LanZouFile, error
|
||||||
"up": up,
|
"up": up,
|
||||||
"ls": ls,
|
"ls": ls,
|
||||||
"pwd": account.Password,
|
"pwd": account.Password,
|
||||||
}).Post("https://wwa.lanzouo.com/filemoreajax.php")
|
}).Post(fmt.Sprintf("https://%s/filemoreajax.php", u.Host))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug(err)
|
log.Debug(err)
|
||||||
break
|
break
|
||||||
|
@ -158,7 +163,7 @@ func (driver *Lanzou) GetFilesByUrl(account *model.Account) ([]LanZouFile, error
|
||||||
// IsNewd string `json:"is_newd"`
|
// IsNewd string `json:"is_newd"`
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// 获取下载页面的ID
|
// GetDownPageId 获取下载页面的ID
|
||||||
func (driver *Lanzou) GetDownPageId(fileId string, account *model.Account) (string, error) {
|
func (driver *Lanzou) GetDownPageId(fileId string, account *model.Account) (string, error) {
|
||||||
var resp LanZouFilesResp
|
var resp LanZouFilesResp
|
||||||
res, err := lanzouClient.R().SetResult(&resp).SetHeader("Cookie", account.AccessToken).
|
res, err := lanzouClient.R().SetResult(&resp).SetHeader("Cookie", account.AccessToken).
|
||||||
|
@ -190,8 +195,13 @@ type LanzouLinkResp struct {
|
||||||
Zt int `json:"zt"`
|
Zt int `json:"zt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver *Lanzou) GetLink(downId string) (string, error) {
|
func (driver *Lanzou) GetLink(downId string, account *model.Account) (string, error) {
|
||||||
res, err := lanzouClient.R().Get("https://wwa.lanzouo.com/" + downId)
|
shareUrl := account.SiteUrl
|
||||||
|
u, err := url.Parse(shareUrl)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
res, err := lanzouClient.R().Get(fmt.Sprintf("https://%s/%s", u.Host, downId))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -210,6 +220,7 @@ func (driver *Lanzou) GetLink(downId string) (string, error) {
|
||||||
}
|
}
|
||||||
signs := ajaxdata[1]
|
signs := ajaxdata[1]
|
||||||
sign := regexp.MustCompile(`var ispostdowns = '(.+?)';`).FindStringSubmatch(res.String())[1]
|
sign := regexp.MustCompile(`var ispostdowns = '(.+?)';`).FindStringSubmatch(res.String())[1]
|
||||||
|
websign := regexp.MustCompile(`'websign':'(.+?)'`).FindStringSubmatch(res.String())[1]
|
||||||
websignkey := regexp.MustCompile(`'websignkey':'(.+?)'`).FindStringSubmatch(res.String())[1]
|
websignkey := regexp.MustCompile(`'websignkey':'(.+?)'`).FindStringSubmatch(res.String())[1]
|
||||||
var resp LanzouLinkResp
|
var resp LanzouLinkResp
|
||||||
form := map[string]string{
|
form := map[string]string{
|
||||||
|
@ -217,14 +228,18 @@ func (driver *Lanzou) GetLink(downId string) (string, error) {
|
||||||
"signs": signs,
|
"signs": signs,
|
||||||
"sign": sign,
|
"sign": sign,
|
||||||
"ves": "1",
|
"ves": "1",
|
||||||
"websign": "",
|
"websign": websign,
|
||||||
"websignkey": websignkey,
|
"websignkey": websignkey,
|
||||||
}
|
}
|
||||||
log.Debugf("form: %+v", form)
|
log.Debugf("form: %+v", form)
|
||||||
_, err = lanzouClient.R().SetResult(&resp).
|
res, err = lanzouClient.R().SetResult(&resp).
|
||||||
SetHeader("origin", "https://wwa.lanzouo.com").
|
SetHeader("origin", "https://"+u.Host).
|
||||||
SetHeader("referer", iframeUrl).
|
SetHeader("referer", iframeUrl).
|
||||||
SetFormData(form).Post("https://wwa.lanzouo.com/ajaxm.php")
|
SetFormData(form).Post(fmt.Sprintf("https://%s/ajaxm.php", u.Host))
|
||||||
|
log.Debug(res.String())
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
if resp.Zt == 1 {
|
if resp.Zt == 1 {
|
||||||
return resp.Dom + "/file/" + resp.Url, nil
|
return resp.Dom + "/file/" + resp.Url, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue