From f0a8af21c3d8131be593212d44be819777a6b300 Mon Sep 17 00:00:00 2001 From: Underworld511 Date: Thu, 28 Jul 2022 15:22:07 +0800 Subject: [PATCH] fix(): Fixed the bug that directory naming failed when saving some series videos. Fixed the bug that directory naming failed when saving some series videos. (close #12 ) --- CHANGELOG | 3 +++ README.md | 2 +- ks.go | 2 +- video/video.go | 8 ++++++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f73f611..4720fc9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +Thursday, 28 July 2022: Version 0.8.2 + Fixed the bug that directory naming failed when saving some series videos. + Sunday, 10 July 2022: Version 0.8.1 Allowed users to view the size of encrypted videos. diff --git a/README.md b/README.md index 71bd960..97fe37d 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ cd C:\Users\lenovo\Downloads\ ks version ``` -若出现`KouShare-dl v0.8.1`字样,则说明可以正常使用。接下来您可以继续输入 KouShare-dl 程序的命令来进行交互。比如,输入`ks help`并回车,您就可以看到 KouShare-dl 程序的帮助信息了。 +若出现`KouShare-dl v0.8.2`字样,则说明可以正常使用。接下来您可以继续输入 KouShare-dl 程序的命令来进行交互。比如,输入`ks help`并回车,您就可以看到 KouShare-dl 程序的帮助信息了。 # 命令简介 diff --git a/ks.go b/ks.go index b4f7a7c..998699c 100644 --- a/ks.go +++ b/ks.go @@ -162,7 +162,7 @@ func main() { }, } - const version = "v0.8.1" + const version = "v0.8.2" var cmdVersion = &cobra.Command{ Use: "version", Short: "输出版本号,并检查最新版本", diff --git a/video/video.go b/video/video.go index e5fc3ae..d24b91b 100644 --- a/video/video.go +++ b/video/video.go @@ -170,10 +170,14 @@ func (v *Video) DownloadSeriesVideos(quality string) { return } + // 过滤系列名中的不合法字符,参考 https://github.com/yliu7949/KouShare-dl/issues/12 + reg, _ := regexp.Compile(`[\\/:*?"<>|]`) + seriesName := reg.ReplaceAllString(v.seriesName, "") + if v.svpName != "" { - v.SaveDir += fmt.Sprintf("%s_%s_videos\\", v.seriesName, v.svpName) + v.SaveDir += fmt.Sprintf("%s_%s_videos\\", seriesName, reg.ReplaceAllString(v.svpName, "")) } else { - v.SaveDir += fmt.Sprintf("%s_videos\\", v.seriesName) + v.SaveDir += fmt.Sprintf("%s_videos\\", seriesName) } if _, err := os.Stat(v.SaveDir); os.IsNotExist(err) { if err := os.Mkdir(v.SaveDir, os.ModePerm); err != nil {