From 40d569fcda66f47c2197222130bba85cc3aed73d Mon Sep 17 00:00:00 2001 From: fengqi Date: Thu, 6 Apr 2023 13:06:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=9B=86=E5=8C=B9=E9=85=8D=E7=AD=96?= =?UTF-8?q?=E7=95=A5=E8=B0=83=E6=95=B4=20=E4=B8=8D=E5=86=8D=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=B8=8D=E8=A7=84=E8=8C=83=E7=9A=84=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/video.go | 8 ++++---- utils/video_test.go | 13 +++++-------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/utils/video.go b/utils/video.go index 1032886..967991c 100644 --- a/utils/video.go +++ b/utils/video.go @@ -151,7 +151,7 @@ func init() { channelMap[item] = struct{}{} } - episodeMatch, _ = regexp.Compile("((?:s|S|第|\\s)([0-9]+)(季|)(?:.|_|x|-|\\s|))?((?:第|E|e|Ep|P|EP|\\s)([0-9]+)(集|)?)") + episodeMatch, _ = regexp.Compile(`(?i)((?:s|第|season)([0-9]+)(?:季|)(?:.|_|x|-| |))?((?:第|e|ep|p|episode)([0-9]+)(?:集|))`) collectionMatch, _ = regexp.Compile("[sS](0|)[0-9]+-[sS](0|)[0-9]+") subEpisodesMatch, _ = regexp.Compile("[eE](0|)[0-9]+-[eE](0|)[0-9]+") yearRangeLikeMatch, _ = regexp.Compile("[12][0-9]{3}-[12][0-9]{3}") @@ -293,7 +293,7 @@ func SplitTitleAlias(name string) (string, string) { // MatchEpisode 匹配季和集 func MatchEpisode(name string) (string, int, int) { find := episodeMatch.FindStringSubmatch(name) - if len(find) != 7 { + if len(find) != 5 { return "", 0, 0 } @@ -306,8 +306,8 @@ func MatchEpisode(name string) (string, int, int) { } } - if len(find[5]) > 0 { - s, err := strconv.Atoi(find[5]) + if len(find[4]) > 0 { + s, err := strconv.Atoi(find[4]) if err == nil { episode = s } diff --git a/utils/video_test.go b/utils/video_test.go index f203a55..b3085a0 100644 --- a/utils/video_test.go +++ b/utils/video_test.go @@ -7,17 +7,14 @@ import ( func TestMatchEpisode(t *testing.T) { cases := map[string][]int{ "[堕落].The.Fall.2013.S02.E03.Complete.BluRay.720p.x264.AC3-CMCT.mkv": {2, 3}, - "[堕落].The.Fall.2013.S10.E12.Complete.BluRay.720p.x264.AC3-CMCT.mkv": {10, 12}, - "[堕落].The.Fall.2013.S120.E132.Complete.BluRay.720p.x264.AC3-CMCT.mkv": {120, 132}, "Agent.Carter.S02E01.1080p.BluRay.DD5.1.x264-HDS.mkv": {2, 1}, "[壹高清]21点灵.Leave No Soul Behind.Ep01.HDTV.1080p.H264-OneHD.ts": {1, 1}, "Kimetsu.no.Yaiba.Yuukaku-hen.E01.2021.Crunchyroll.WEB-DL.1080p.x264.AAC-HDCTV.mkv": {1, 1}, - "Overlord IV - 09.mp4": {1, 9}, - "宝贝揪揪 第3季 第10集.mp4": {3, 10}, - "宝贝揪揪 3季 10集.mp4": {3, 10}, - "宝贝揪揪 第9集.mp4": {1, 9}, - "Gannibal.E01.2022": {1, 1}, - "Gannibal S01 E01 2022": {1, 1}, + "宝贝揪揪 第3季 第10集.mp4": {3, 10}, + "宝贝揪揪 第9集.mp4": {1, 9}, + "Gannibal.E01.2022.mp4": {1, 1}, + "Gannibal S02 E11 2022.mp4": {2, 11}, + "Gannibal-S01-E02-2022.mp4": {1, 2}, } for name, cse := range cases { _, s, e := MatchEpisode(name)