From 0776f86f7eb5b603564a13df1394c5c4556b7e70 Mon Sep 17 00:00:00 2001 From: fantasticbin Date: Thu, 4 Apr 2024 10:11:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=AB=A0=E8=8A=82=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=8E=B7=E5=8F=96=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cmd/root.go | 2 +- src/cmd/start.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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{ "第",