diff options
Diffstat (limited to 'cmd/bvd')
| -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 号", }, |
