- Go 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
gofile rotated the secret embedded in its client generateWT(); the rest of the token scheme (field order, 4-hour window, SHA-256 hex) is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
| cmd/gofile-dl | ||
| gofile | ||
| .gitignore | ||
| go.mod | ||
| README.md | ||
gofile-downloader
A gofile.io downloader — available both as a CLI tool and a reusable Go library. Point it at a gofile link and it grabs the file (or every file, or the ones you pick).
No browser or headless automation required: the x-website-token header the gofile
API expects is reproduced locally in pure Go.
hey gofile nice obfuscation 👋
Install
go install github.com/yx-zero/gofile-downloader/cmd/gofile-dl@latest
or build from source:
git clone https://github.com/yx-zero/gofile-downloader.git
cd gofile-downloader
go build -o gofile-dl ./cmd/gofile-dl
CLI usage
gofile-dl [flags] <link-or-code> [more links...]
Accepts full links (https://gofile.io/d/zd3bfh), bare codes (zd3bfh), or several
at once.
Examples
# List the files in a link without downloading
gofile-dl -l https://gofile.io/d/zd3bfh
# Download a single-file link (auto-selected)
gofile-dl -o downloads https://gofile.io/d/zd3bfh
# Download everything in a multi-file link
gofile-dl -all -o downloads https://gofile.io/d/xLhg7O
# Pick specific files by index (1-based): ranges and lists both work
gofile-dl -select 1,3-5 xLhg7O
# Interactive: prompts for a selection when a link has >1 file
gofile-dl xLhg7O
Flags
| Flag | Default | Description |
|---|---|---|
-o |
. |
Output directory |
-c |
3 |
Number of parallel downloads |
-l |
false |
List files only, do not download |
-all |
false |
Download all files without prompting |
-select |
"" |
Non-interactive selection: 1,3,5, 2-4, or all |
-tree |
false |
Recreate the folder structure under the output directory |
-overwrite |
false |
Re-download files that already exist with the same size |
-token |
"" |
Use an existing gofile account token instead of a guest account |
-q |
false |
Quiet: suppress the progress line |
Existing files whose size already matches are skipped automatically (unless
-overwrite). Interrupting a download (Ctrl-C) leaves no half-written file — bytes
stream to a .part file that's only renamed into place on success.
Library usage
package main
import (
"context"
"fmt"
"log"
"github.com/yx-zero/gofile-downloader/gofile"
)
func main() {
ctx := context.Background()
c := gofile.New()
// Resolve a link into its content tree (folders traversed recursively).
root, err := c.Resolve(ctx, "https://gofile.io/d/zd3bfh")
if err != nil {
log.Fatal(err)
}
// Every downloadable file in the tree.
for _, f := range root.Files() {
fmt.Printf("%s (%d bytes)\n", f.Name, f.Size)
}
// Download them all with 4-way concurrency and progress callbacks.
_, err = c.DownloadAll(ctx, root, "downloads", &gofile.DownloadAllOptions{
Concurrency: 4,
Progress: func(p gofile.Progress) {
if p.Done {
fmt.Printf("finished %s\n", p.File.Name)
}
},
})
if err != nil {
log.Fatal(err)
}
}
Key API:
gofile.New(opts...)— construct a client. Options:WithHTTPClient,WithUserAgent,WithLanguage,WithToken.(*Client).Resolve(ctx, linkOrCode)— fetch the folder/file tree.(*Item).Files()— flatten a tree to its files.(*Client).Download(ctx, file, dir, opts)— download one file.(*Client).DownloadAll(ctx, root, dir, opts)— bulk download with concurrency.
How it works
The gofile web client authorises API reads with two things: a guest account token
(from POST /accounts) and a per-request x-website-token header. That header is
just:
sha256( userAgent :: navigator.language :: accountToken :: floor(unixTime/14400) :: <embedded secret> )
bucketed into 4-hour windows. This project reproduces it directly, then fetches
GET /contents/{code} and streams each file's CDN link with the accountToken
cookie.
License
MIT