Documentation
¶
Overview ¶
Package lanzou resolves Lanzou (蓝奏云) public and password share links.
Features:
- public / password shares
- Alibaba WAF/ESA acw_sc__v2 cookie
- CDN pseudo-link resolution and risk-page fallback
- optional local download
Index ¶
- Constants
- Variables
- func CalcAcwScV2(arg1 string) (string, error)
- func CalcAcwScV2With(arg1, mask string, perm []int) (string, error)
- func ExtractArg1(html string) (string, bool)
- func IsAcwChallenge(html string) bool
- func IsPasswordProtected(html string) bool
- type Account
- func (a *Account) Cookie() string
- func (a *Account) CreateFolder(name, parentID, describe string) (string, error)
- func (a *Account) DeleteFile(fileID string) (string, error)
- func (a *Account) DeleteFolder(folderID string) (string, error)
- func (a *Account) DeleteFolderByName(name, fatherID string) (string, error)
- func (a *Account) EnsureLogin() error
- func (a *Account) GetFileDescribe(fileID string) (string, error)
- func (a *Account) GetFileDownloadInfo(fileID string) (shareURL, pwd string, err error)
- func (a *Account) GetFileInfo(fileID string) (*FileInfo, error)
- func (a *Account) GetFileInfoRaw(fileID string) (string, error)
- func (a *Account) GetFilePassword(fileID string) (string, error)
- func (a *Account) GetFolderIDByName(name, fatherID string) (string, error)
- func (a *Account) GetFolderInfo(folderID string) (*FolderInfo, error)
- func (a *Account) List(folderID string) ([]ListEntry, error)
- func (a *Account) Login() error
- func (a *Account) MoveFile(fileID, folderID string) (string, error)
- func (a *Account) SetCookie(cookie string)
- func (a *Account) SetFileDescribe(fileID, describe string) (string, error)
- func (a *Account) SetFilePassword(fileID, pwd string) (string, error)
- func (a *Account) SetFolderNameAndDescribe(folderID, name, describe string) (string, error)
- func (a *Account) SetFolderPassword(folderID, pwd string) (string, error)
- func (a *Account) Upload(localPath, folderID string) (*UploadResult, error)
- func (a *Account) Verification() bool
- type AccountOption
- type Client
- type FileInfo
- type FolderInfo
- type ListEntry
- type Options
- type Result
- type UploadResult
Constants ¶
const ( EntryFolder = 0 EntryFile = 1 )
EntryType: 0 folder, 1 file.
Variables ¶
var (
ErrPasswordRequired = errors.New("password required for this share link")
)
Sentinel errors.
Functions ¶
func CalcAcwScV2 ¶
CalcAcwScV2 computes cookie value from arg1.
func CalcAcwScV2With ¶
CalcAcwScV2With allows custom mask/perm.
func ExtractArg1 ¶
ExtractArg1 extracts arg1 from challenge HTML.
func IsAcwChallenge ¶
IsAcwChallenge reports whether HTML is an acw challenge page.
func IsPasswordProtected ¶
IsPasswordProtected detects password share HTML.
Types ¶
type Account ¶ added in v0.1.3
type Account struct {
// contains filtered or unexported fields
}
Account is a logged-in Lanzou control-panel client.
func NewAccount ¶ added in v0.1.3
func NewAccount(username, password string, opts ...AccountOption) *Account
NewAccount creates an account client. Call Login or LoadCookie before API use.
func (*Account) CreateFolder ¶ added in v0.1.3
CreateFolder creates a folder. Returns raw JSON response body.
func (*Account) DeleteFile ¶ added in v0.1.3
DeleteFile deletes a file by id.
func (*Account) DeleteFolder ¶ added in v0.1.3
DeleteFolder deletes a folder by id.
func (*Account) DeleteFolderByName ¶ added in v0.1.3
DeleteFolderByName deletes a child folder by name.
func (*Account) EnsureLogin ¶ added in v0.1.3
EnsureLogin logs in if Verification fails.
func (*Account) GetFileDescribe ¶ added in v0.1.3
GetFileDescribe returns file description.
func (*Account) GetFileDownloadInfo ¶ added in v0.1.3
GetFileDownloadInfo returns share URL + password for a managed file.
func (*Account) GetFileInfo ¶ added in v0.1.3
GetFileInfo returns parsed file info.
func (*Account) GetFileInfoRaw ¶ added in v0.1.3
GetFileInfoRaw returns raw JSON for task=22.
func (*Account) GetFilePassword ¶ added in v0.1.3
GetFilePassword returns share password for a file.
func (*Account) GetFolderIDByName ¶ added in v0.1.3
GetFolderIDByName finds a child folder id by name under fatherID.
func (*Account) GetFolderInfo ¶ added in v0.1.3
func (a *Account) GetFolderInfo(folderID string) (*FolderInfo, error)
GetFolderInfo scrapes folder info page.
func (*Account) List ¶ added in v0.1.3
List returns folders + files under folderID ("-1" is root). Folders via task=47, files via task=5 (JSON APIs).
func (*Account) Login ¶ added in v0.1.3
Login POSTs task/uid/pwd to mlogin.php (same as browser/curl simple login).
func (*Account) SetFileDescribe ¶ added in v0.1.3
SetFileDescribe sets file description.
func (*Account) SetFilePassword ¶ added in v0.1.3
SetFilePassword sets a file share password.
func (*Account) SetFolderNameAndDescribe ¶ added in v0.1.3
SetFolderNameAndDescribe renames a folder and sets description.
func (*Account) SetFolderPassword ¶ added in v0.1.3
SetFolderPassword enables password on a folder.
func (*Account) Upload ¶ added in v0.1.3
func (a *Account) Upload(localPath, folderID string) (*UploadResult, error)
Upload uploads a local file to folderID ("-1" = root) via html5up.php. Matches browser HTML5 upload:
POST https://pc.woozooo.com/html5up.php multipart: task=1, folder_id=<id>, upload_file=@file
func (*Account) Verification ¶ added in v0.1.3
Verification checks whether the current cookie session is valid.
type AccountOption ¶ added in v0.1.3
type AccountOption func(*Account)
AccountOption configures Account.
func WithAccountBase ¶ added in v0.1.3
func WithAccountBase(base string) AccountOption
WithAccountBase overrides the control-panel origin (default up.woozooo.com).
func WithCookieFile ¶ added in v0.1.3
func WithCookieFile(path string) AccountOption
WithCookieFile sets a path to load/save session cookies.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client holds HTTP state (cookies) for a lanzou session.
type FolderInfo ¶ added in v0.1.3
type FolderInfo struct {
Name string
Description string
URL string
Password string
FileCount string
FileSize string
}
FolderInfo holds scraped folder metadata.
type ListEntry ¶ added in v0.1.3
type ListEntry struct {
Type int `json:"type"` // 0 folder, 1 file
ID string `json:"id"`
Name string `json:"name"`
URL string `json:"url,omitempty"`
Size string `json:"size,omitempty"`
Time string `json:"time,omitempty"`
Description string `json:"description,omitempty"`
}
ListEntry is a folder or file row.
type Options ¶
Options for Parse.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns options with ResolveDirect enabled.