diff options
| author | Verdant <i@glowisle.me> | 2026-02-13 02:09:14 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-13 02:09:14 +0800 |
| commit | 84a12b2666dd98db0265d37ecb6510c47066acf4 (patch) | |
| tree | eee8cdfc82bd03f2e4b464e4ca66738f7cc5dc81 /cmd/bvd/main.go | |
| parent | c52f41545df179b542f106d08e6dd013a70216e7 (diff) | |
| parent | b665cb604ac5ad9322b536c4de7334ae2efd84dc (diff) | |
| download | bvd-84a12b2666dd98db0265d37ecb6510c47066acf4.tar.gz bvd-84a12b2666dd98db0265d37ecb6510c47066acf4.zip | |
feat: 修复下载错误并添加输出路径选项
Diffstat (limited to 'cmd/bvd/main.go')
| -rw-r--r-- | cmd/bvd/main.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/cmd/bvd/main.go b/cmd/bvd/main.go index 3a537b4..db473b5 100644 --- a/cmd/bvd/main.go +++ b/cmd/bvd/main.go @@ -19,16 +19,36 @@ func main() { { Name: "download", Usage: "下载指定 BV 号的视频", + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "file", + Aliases: []string{"f"}, + Usage: "指定单个视频下载时的输出文件名(不含扩展名)", + }, + &cli.StringFlag{ + Name: "director", + Aliases: []string{"d"}, + Usage: "指定下载目标文件夹(不存在时会自动创建)", + }, + }, Action: func(c *cli.Context) error { bvid := c.Args().First() if bvid == "" { return fmt.Errorf("请提供视频 BV 号") } + outputFile := c.String("file") + outputDir := c.String("director") + // fmt.Printf("Debug: outputFile=%s, outputDir=%s\n", outputFile, outputDir) + biliAPI := api.NewBiliAPI() - downloader := downloader.NewDownloader() + dl := downloader.NewDownloader() + opts := &downloader.DownloadOptions{ + OutputFile: outputFile, + OutputDir: outputDir, + } - return downloader.Start(bvid, biliAPI) + return dl.Start(bvid, biliAPI, opts) }, ArgsUsage: "<BVID> 欲下载视频的 BV 号", }, |
