增加章节自动获取机制
This commit is contained in:
parent
f496801c4d
commit
0776f86f7e
@ -32,5 +32,5 @@ func CommandInit(rootCmd *cobra.Command) {
|
|||||||
rootCmd.PersistentFlags().IntVarP(&config.max, "max", "m", 1, "图片最大值")
|
rootCmd.PersistentFlags().IntVarP(&config.max, "max", "m", 1, "图片最大值")
|
||||||
rootCmd.PersistentFlags().StringVarP(&config.output, "output", "o", "anime", "设置漫画抓取结果的保存位置,默认为当前用户的主目录下的 anime 文件夹")
|
rootCmd.PersistentFlags().StringVarP(&config.output, "output", "o", "anime", "设置漫画抓取结果的保存位置,默认为当前用户的主目录下的 anime 文件夹")
|
||||||
rootCmd.PersistentFlags().StringVarP(&config.folderTitleUrl, "folderTitleUrl", "t", "", "文件夹标题抓取链接")
|
rootCmd.PersistentFlags().StringVarP(&config.folderTitleUrl, "folderTitleUrl", "t", "", "文件夹标题抓取链接")
|
||||||
rootCmd.PersistentFlags().IntVarP(&config.chapter, "chapter", "c", 1, "指定章节,用于文件夹标题抓取")
|
rootCmd.PersistentFlags().IntVarP(&config.chapter, "chapter", "c", 0, "指定章节,用于文件夹标题抓取")
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,13 @@ func NewCrawler() *Crawler {
|
|||||||
func (c *Crawler) Start() {
|
func (c *Crawler) Start() {
|
||||||
c.path = config.output
|
c.path = config.output
|
||||||
if config.folderTitleUrl != "" {
|
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)
|
chapterTitle := FindChapterTitle(config.folderTitleUrl)
|
||||||
title := strings.Join([]string{
|
title := strings.Join([]string{
|
||||||
"第",
|
"第",
|
||||||
|
Loading…
Reference in New Issue
Block a user