diff --git a/src/cmd/root.go b/src/cmd/root.go index 056c1e6..e61da4d 100644 --- a/src/cmd/root.go +++ b/src/cmd/root.go @@ -32,5 +32,5 @@ func CommandInit(rootCmd *cobra.Command) { rootCmd.PersistentFlags().IntVarP(&config.max, "max", "m", 1, "图片最大值") rootCmd.PersistentFlags().StringVarP(&config.output, "output", "o", "anime", "设置漫画抓取结果的保存位置,默认为当前用户的主目录下的 anime 文件夹") rootCmd.PersistentFlags().StringVarP(&config.folderTitleUrl, "folderTitleUrl", "t", "", "文件夹标题抓取链接") - rootCmd.PersistentFlags().IntVarP(&config.chapter, "chapter", "c", 1, "指定章节,用于文件夹标题抓取") + rootCmd.PersistentFlags().IntVarP(&config.chapter, "chapter", "c", 0, "指定章节,用于文件夹标题抓取") } diff --git a/src/cmd/start.go b/src/cmd/start.go index 2549dc0..8dc4bde 100644 --- a/src/cmd/start.go +++ b/src/cmd/start.go @@ -24,6 +24,13 @@ func NewCrawler() *Crawler { func (c *Crawler) Start() { c.path = config.output if config.folderTitleUrl != "" { + if config.chapter == 0 { + // 章节自动获取 + urlSlice := strings.Split(config.url, "_") + urlSlice = strings.Split(urlSlice[0], "/") + config.chapter, _ = strconv.Atoi(urlSlice[len(urlSlice)-1]) + } + chapterTitle := FindChapterTitle(config.folderTitleUrl) title := strings.Join([]string{ "第",