Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Resolve lanzou links #21

Merged
merged 2 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ linters-settings:
- G401
- G501
- G306
depguard:
rules:
main:
# Packages that are not allowed where the value is a suggestion.
deny:
- pkg: "github.com/sirupsen/logrus"
desc: not allowed
- pkg: "github.com/pkg/errors"
desc: Should be replaced by standard lib errors package


linters:
disable-all: true
Expand Down
2 changes: 1 addition & 1 deletion internal/driver/lanzou/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var (
dirURLRe = regexp.MustCompile(`(?m)https?://[a-zA-Z0-9-]*?\.?lanzou[a-z]\.com/(/s/)?b[a-zA-Z0-9]{7,}/?`)
fileURLRe = regexp.MustCompile(`(?m)https?://[a-zA-Z0-9-]*?\.?lanzou[a-z]\.com/(/s/)?i[a-zA-Z0-9]{7,}/?`)

find1Re = regexp.MustCompile(`(?m)url\s:\s+'(.*?)',\n\t+data\s:\s+'(.*?)'\+pwd,`)
find1Re = regexp.MustCompile(`(?m)var\s+skdklds\s+=\s+'(.*?)';`)
find2Re = regexp.MustCompile(`(?m)<iframe.*?src="(/fn\?\w{10,})"\s.*>`)
find2TitleRe = regexp.MustCompile(`(?m)<title>(.*?)\s-\s蓝奏云</title>`)

Expand Down
13 changes: 8 additions & 5 deletions internal/driver/lanzou/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,20 @@ func (l *Lanzou) resolveFileShareURL(parsedURI, pwd string) (*ResponseData, erro
}

func (l *Lanzou) ParsePasswordShare(parsedURI string, pwd string, firstPage string) (*ResponseData, error) {
allString := find1Re.FindStringSubmatch(firstPage)
urlpath := allString[1]
params := allString[2] + pwd
sign := find1Re.FindStringSubmatch(firstPage)
urlpath := "/ajaxm.php"

result := &Dom{}
query, _ := url.ParseQuery(params)
data := make(map[string]string)
data["action"] = "downprocess"
data["sign"] = sign[1]
data["p"] = pwd

_, err := l.R().
SetHeader("referer", l.BaseURL+parsedURI).
SetHeader("Content-Type", "application/x-www-form-urlencoded").
SetResult(result).
SetFormDataFromValues(query).
SetFormData(data).
Post(urlpath)
if err != nil {
return nil, err
Expand Down