lanzou

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 13 Imported by: 0

README

gLanz

Lanzou (蓝奏云) Go library: share-link resolve + account management.

Module: github.com/WangTianYou537/gLanz

Install

go get github.com/WangTianYou537/gLanz@v0.1.3
go install github.com/WangTianYou537/gLanz/cmd/lanzou@v0.1.3

Share resolve

c := lanzou.New()
res, err := c.Parse(shareURL, lanzou.Options{
    Password:      "optional",
    ResolveDirect: true,
})

Account (from lanzou.class.php)

acc := lanzou.NewAccount("user", "password", lanzou.WithCookieFile("./cookie.txt"))
if err := acc.EnsureLogin(); err != nil { /* ... */ }
list, _ := acc.List("-1")                 // root
_ = acc.CreateFolder("demo", "-1", "desc")
_ = acc.SetFilePassword(fileID, "abcd")
share, pwd, _ := acc.GetFileDownloadInfo(fileID)

APIs: Login / Verification / List / CreateFolder / DeleteFolder / SetFolderPassword / GetFolderInfo / GetFileInfo / SetFilePassword / SetFileDescribe / MoveFile / DeleteFile.

CLI

lanzou https://hya.lanzouu.com/xxx
lanzou --pwd 5grc --down https://wwbss.lanzouu.com/xxx

License

MIT

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

View Source
const (
	EntryFolder = 0
	EntryFile   = 1
)

EntryType: 0 folder, 1 file.

Variables

View Source
var (
	ErrPasswordRequired = errors.New("password required for this share link")
)

Sentinel errors.

Functions

func CalcAcwScV2

func CalcAcwScV2(arg1 string) (string, error)

CalcAcwScV2 computes cookie value from arg1.

func CalcAcwScV2With

func CalcAcwScV2With(arg1, mask string, perm []int) (string, error)

CalcAcwScV2With allows custom mask/perm.

func ExtractArg1

func ExtractArg1(html string) (string, bool)

ExtractArg1 extracts arg1 from challenge HTML.

func IsAcwChallenge

func IsAcwChallenge(html string) bool

IsAcwChallenge reports whether HTML is an acw challenge page.

func IsPasswordProtected

func IsPasswordProtected(html string) bool

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) Cookie added in v0.1.3

func (a *Account) Cookie() string

Cookie returns the raw cookie string.

func (*Account) CreateFolder added in v0.1.3

func (a *Account) CreateFolder(name, parentID, describe string) (string, error)

CreateFolder creates a folder. Returns raw JSON response body.

func (*Account) DeleteFile added in v0.1.3

func (a *Account) DeleteFile(fileID string) (string, error)

DeleteFile deletes a file by id.

func (*Account) DeleteFolder added in v0.1.3

func (a *Account) DeleteFolder(folderID string) (string, error)

DeleteFolder deletes a folder by id.

func (*Account) DeleteFolderByName added in v0.1.3

func (a *Account) DeleteFolderByName(name, fatherID string) (string, error)

DeleteFolderByName deletes a child folder by name.

func (*Account) EnsureLogin added in v0.1.3

func (a *Account) EnsureLogin() error

EnsureLogin logs in if Verification fails.

func (*Account) GetFileDescribe added in v0.1.3

func (a *Account) GetFileDescribe(fileID string) (string, error)

GetFileDescribe returns file description.

func (*Account) GetFileDownloadInfo added in v0.1.3

func (a *Account) GetFileDownloadInfo(fileID string) (shareURL, pwd string, err error)

GetFileDownloadInfo returns share URL + password for a managed file.

func (*Account) GetFileInfo added in v0.1.3

func (a *Account) GetFileInfo(fileID string) (*FileInfo, error)

GetFileInfo returns parsed file info.

func (*Account) GetFileInfoRaw added in v0.1.3

func (a *Account) GetFileInfoRaw(fileID string) (string, error)

GetFileInfoRaw returns raw JSON for task=22.

func (*Account) GetFilePassword added in v0.1.3

func (a *Account) GetFilePassword(fileID string) (string, error)

GetFilePassword returns share password for a file.

func (*Account) GetFolderIDByName added in v0.1.3

func (a *Account) GetFolderIDByName(name, fatherID string) (string, error)

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

func (a *Account) List(folderID string) ([]ListEntry, error)

List returns folders + files under folderID ("-1" is root).

func (*Account) Login added in v0.1.3

func (a *Account) Login() error

Login authenticates and stores cookies (optionally to cookie file).

func (*Account) MoveFile added in v0.1.3

func (a *Account) MoveFile(fileID, folderID string) (string, error)

MoveFile moves a file into folderID.

func (*Account) SetCookie added in v0.1.3

func (a *Account) SetCookie(cookie string)

SetCookie sets session cookie manually.

func (*Account) SetFileDescribe added in v0.1.3

func (a *Account) SetFileDescribe(fileID, describe string) (string, error)

SetFileDescribe sets file description.

func (*Account) SetFilePassword added in v0.1.3

func (a *Account) SetFilePassword(fileID, pwd string) (string, error)

SetFilePassword sets a file share password.

func (*Account) SetFolderNameAndDescribe added in v0.1.3

func (a *Account) SetFolderNameAndDescribe(folderID, name, describe string) (string, error)

SetFolderNameAndDescribe renames a folder and sets description.

func (*Account) SetFolderPassword added in v0.1.3

func (a *Account) SetFolderPassword(folderID, pwd string) (string, error)

SetFolderPassword enables password on a folder.

func (*Account) Upload added in v0.1.3

func (a *Account) Upload(localPath, folderID string) error

Upload is not implemented in the original PHP class (no multipart endpoint there). Kept as a clear stub so callers know the gap.

func (*Account) Verification added in v0.1.3

func (a *Account) Verification() bool

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.

func New

func New() *Client

New creates a Client with browser-like headers and cookie jar map.

func (*Client) Download

func (c *Client) Download(rawURL, destDir, filename, referer string) (string, error)

Download saves url into destDir and returns the path.

func (*Client) Parse

func (c *Client) Parse(shareURL string, opt Options) (*Result, error)

Parse resolves a share URL.

func (*Client) ResolveDirectURL

func (c *Client) ResolveDirectURL(cdnURL string) (string, error)

ResolveDirectURL turns a CDN pseudo link into a downloadable URL.

type FileInfo added in v0.1.3

type FileInfo struct {
	Raw map[string]any
	ID  string
	Pwd string
	// ShareURL is is_newd + "/" + f_id when available.
	ShareURL string
}

FileInfo is a decoded task=22 payload.

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

type Options struct {
	Password      string
	ResolveDirect bool
}

Options for Parse.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns options with ResolveDirect enabled.

type Result

type Result struct {
	FID               string
	Filename          string
	PasswordProtected bool
	CDNDomain         string
	Telecom           string
	Unicom            string
	Normal            string
	Direct            string
	SavedPath         string
}

Result of a successful Parse.

Directories

Path Synopsis
cmd
lanzou command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL