diff --git a/utils/video.go b/utils/video.go index 0a4e1dd..077e628 100644 --- a/utils/video.go +++ b/utils/video.go @@ -159,7 +159,7 @@ func init() { seasonMatch, _ = regexp.Compile("[sS](0|)[0-9]+") optionsMatch, _ = regexp.Compile("\\[.*?\\](\\.)?") chsMatch, _ = regexp.Compile("([零一二三四五六七八九十百千万亿]+)[季|集]") - chsSeasonMatch, _ = regexp.Compile("第([0-9]+)([-至到])?([0-9]+)?季") + chsSeasonMatch, _ = regexp.Compile("(.*?)(\\.|)第([0-9]+)([-至到])?([0-9]+)?季") resolutionMatch, _ = regexp.Compile("[0-9]{3,4}Xx*[0-9]{3,4}") seasonRangeMatch, _ = regexp.Compile("[sS](0|)[0-9]+-[sS](0|)[0-9]+") } @@ -382,23 +382,23 @@ func FilterCorrecting(name string) string { name = ReplaceChsNumber(name) right := "" find := chsSeasonMatch.FindStringSubmatch(name) - if len(find) == 4 { - if find[2] == "" && find[3] == "" { - num, err := strconv.Atoi(find[1]) + if len(find) == 6 { + if find[4] == "" && find[5] == "" { + num, err := strconv.Atoi(find[3]) if err == nil && num > 0 { right = fmt.Sprintf("S%.2d", num) } } else { - num1, err := strconv.Atoi(find[1]) - num2, err := strconv.Atoi(find[3]) + num1, err := strconv.Atoi(find[3]) + num2, err := strconv.Atoi(find[5]) if err == nil && num1 > 0 && num2 > 0 { right = fmt.Sprintf("S%.2d-S%.2d", num1, num2) } } - } - if right != "" { - return chsSeasonMatch.ReplaceAllString(name, right) + if right != "" { + name = strings.Replace(name, find[0], find[1]+"."+right, 1) + } } return name diff --git a/utils/video_test.go b/utils/video_test.go index efe2dbc..c3f9fd4 100644 --- a/utils/video_test.go +++ b/utils/video_test.go @@ -70,7 +70,7 @@ func TestIsSeason(t *testing.T) { func TestSplit(t *testing.T) { unit := map[string][]string{ - "[梦蓝字幕组]Crayonshinchan 蜡笔小新[1105][2021.11.06][AVC][1080P][GB_JP][MP4]V2.mp4": []string{ + "[梦蓝字幕组]Crayonshinchan 蜡笔小新[1105][2021.11.06][AVC][1080P][GB_JP][MP4]V2.mp4": { "梦蓝字幕组", "Crayonshinchan", "蜡笔小新", @@ -86,14 +86,14 @@ func TestSplit(t *testing.T) { "V2", "mp4", }, - "The Last Son 2021.mkv": []string{ + "The Last Son 2021.mkv": { "The", "Last", "Son", "2021", "mkv", }, - "Midway 2019 2160p CAN UHD Blu-ray HEVC DTS-HD MA 5.1-THDBST@HDSky.nfo": []string{ + "Midway 2019 2160p CAN UHD Blu-ray HEVC DTS-HD MA 5.1-THDBST@HDSky.nfo": { "Midway", "2019", "2160p", @@ -191,6 +191,7 @@ func TestFilterCorrecting(t *testing.T) { "堕落.第一季.2013.中英字幕£CMCT无影": "堕落.S01.2013.中英字幕£CMCT无影", "一年一度喜剧大赛": "一年一度喜剧大赛", "亿万富犬.第一季": "亿万富犬.S01", + "超级宝贝JOJO第二季": "超级宝贝JOJO.S02", } for title, want := range cases {