package meta_test

import (
	"MediaTools/encode"
	"MediaTools/internal/pkg/meta"
	"testing"

	"github.com/stretchr/testify/require"
)

type expectedMeta struct {
	mediaType      meta.MediaType
	cntitle        string
	entitle        string
	year           int
	part           string
	season         string
	episode        string
	resourcePix    meta.ResourcePix
	resourceType   meta.ResourceType
	resourceEffect []meta.ResourceEffect
	videoEncode    encode.VideoEncode
	audioEncode    encode.AudioEncode
	version        uint8
}

func TestParseVideoMeta(t *testing.T) {

	testCases := []struct {
		input    string
		expected expectedMeta
	}{
		{
			input: "The Long Season 2017 2160p WEB-DL H265 AAC-XXX",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeUnknown,
				cntitle:        "",
				entitle:        "The Long Season",
				year:           2017,
				part:           "",
				season:         "",
				episode:        "",
				resourcePix:    meta.ResourcePix2160p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH265,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "Cherry Season S01 2014 2160p WEB-DL H265 AAC-XXX",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Cherry Season",
				year:           2014,
				part:           "",
				season:         "S01",
				episode:        "",
				resourcePix:    meta.ResourcePix2160p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH265,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "【爪爪字幕组】★7月新番[欢迎来到实力至上主义的教室 第二季/Youkoso Jitsuryoku Shijou Shugi no Kyoushitsu e S2][11][1080p][HEVC][GB][MP4][招募翻译校对]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "欢迎来到实力至上主义的教室",
				entitle:        "Youkoso Jitsuryoku Shijou Shugi no Kyoushitsu e",
				year:           0,
				part:           "",
				season:         "S02",
				episode:        "E11",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH265,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "National.Parks.Adventure.AKA.America.Wild:.National.Parks.Adventure.3D.2016.1080p.Blu-ray.AVC.TrueHD.7.1",
			expected: expectedMeta{
				mediaType:    meta.MediaTypeUnknown,
				cntitle:      "",
				entitle:      "National Parks Adventure AKA America Wild: National Parks Adventure",
				year:         2016,
				part:         "",
				season:       "",
				episode:      "",
				resourcePix:  meta.ResourcePix1080p,
				resourceType: meta.ResourceTypeBluRay,
				resourceEffect: []meta.ResourceEffect{
					meta.ResourceEffect3D,
				},
				videoEncode: encode.VideoEncodeH264,
				audioEncode: encode.AudioEncodeTrueHD,
				version:     1,
			},
		},
		{
			input: "[秋叶原冥途战争][Akiba Maid Sensou][2022][WEB-DL][1080][TV Series][第01话][LeagueWEB]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Akiba Maid Sensou",
				year:           2022,
				part:           "",
				season:         "S01",
				episode:        "E01",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "哆啦A梦：大雄的宇宙小战争 2021 (2022) - 1080p.mp4",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeUnknown,
				cntitle:        "哆啦A梦：大雄的宇宙小战争 2021",
				entitle:        "",
				year:           2022,
				part:           "",
				season:         "",
				episode:        "",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "新精武门1991 (1991).mkv",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeUnknown,
				cntitle:        "新精武门1991",
				entitle:        "",
				year:           1991,
				part:           "",
				season:         "",
				episode:        "",
				resourcePix:    meta.ResourcePixUnknown,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "24 S01 1080p WEB-DL AAC2.0 H.264-BTN",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "24",
				year:           0,
				part:           "",
				season:         "S01",
				episode:        "",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "Qi Refining for 3000 Years S01E06 2022 1080p B-Blobal WEB-DL X264 AAC-AnimeS@AdWeb",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Qi Refining for 3000 Years",
				year:           2022,
				part:           "",
				season:         "S01",
				episode:        "E06",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "Noumin Kanren no Skill Bakka Agetetara Naze ka Tsuyoku Natta S01E02 2022 1080p B-Global WEB-DL X264 AAC-AnimeS@ADWeb[2022年10月新番]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Noumin Kanren no Skill Bakka Agetetara Naze ka Tsuyoku Natta",
				year:           2022,
				part:           "",
				season:         "S01",
				episode:        "E02",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "Thor Love and Thunder (2022) [1080p] [WEBRip] [5.1]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeUnknown,
				cntitle:        "",
				entitle:        "Thor Love and Thunder",
				year:           2022,
				part:           "",
				season:         "",
				episode:        "",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebRip,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "[Animations(动画片)][[诛仙][Jade Dynasty][2022][WEB-DL][2160][TV Series][TV 08][LeagueWEB]][诛仙/诛仙动画 第一季 第08集 | 类型:动画 [国语中字]][680.12 MB]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "诛仙",
				entitle:        "Jade Dynasty",
				year:           2022,
				part:           "",
				season:         "S01",
				episode:        "E08",
				resourcePix:    meta.ResourcePix2160p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "钢铁侠2 (2010) 1080p AC3.mp4",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeUnknown,
				cntitle:        "钢铁侠2",
				entitle:        "",
				year:           2010,
				part:           "",
				season:         "",
				episode:        "",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeAC3,
				version:        1,
			},
		},
		{
			input: "Wonder Woman 1984 2020 BluRay 1080p Atmos TrueHD 7.1 X264-EPiC",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeUnknown,
				cntitle:        "",
				entitle:        "Wonder Woman 1984",
				year:           2020,
				part:           "",
				season:         "",
				episode:        "",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeBluRay,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAtmos,
				version:        1,
			},
		},
		// {
		// 	input: "9-1-1 - S04E03 - Future Tense WEBDL-1080p.mp4",
		// 	expected: expectedMeta{
		// 		mediaType:      meta.MediaTypeTV,
		// 		cntitle:        "",
		// 		entitle:        "9 1 1",
		// 		year:           0,
		// 		part:           "",
		// 		season:         "S04",
		// 		episode:        "E03",
		// 		resourcePix:    meta.ResourcePix1080p,
		// 		resourceType:   meta.ResourceTypeWebDL,
		// 		resourceEffect: make([]meta.ResourceEffect,0),
		// 		videoEncode:    encode.VideoEncodeUnknown,
		// 		audioEncode:    encode.AudioEncodeUnknown,
		// 		version:        1,
		// 	},
		// },
		{
			input: "【幻月字幕组】【22年日剧】【据幸存的六人所说】【04】【1080P】【中日双语】",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "据幸存的六人所说",
				entitle:        "",
				year:           0,
				part:           "",
				season:         "S01",
				episode:        "E04",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "【爪爪字幕组】★7月新番[即使如此依旧步步进逼/Soredemo Ayumu wa Yosetekuru][09][1080p][HEVC][GB][MP4][招募翻译校对]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "即使如此依旧步步进逼",
				entitle:        "Soredemo Ayumu wa Yosetekuru",
				year:           0,
				part:           "",
				season:         "S01",
				episode:        "E09",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH265,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "[GM-Team][国漫][寻剑 第1季][Sword Quest Season 1][2022][02][AVC][GB][1080P]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "寻剑",
				entitle:        "Sword Quest Season 1",
				year:           2022,
				part:           "",
				season:         "S01",
				episode:        "E02",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "[猎户不鸽发布组] 组长女儿与照料专员 / 组长女儿与保姆 Kumichou Musume to Sewagakari [09] [1080p+] [简中内嵌] [2022年7月番]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "组长女儿与照料专员 组长女儿与保姆",
				entitle:        "Kumichou Musume to Sewagakari",
				year:           0,
				part:           "",
				season:         "S01",
				episode:        "E09",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "Nande Koko ni Sensei ga!? 2019 Blu-ray Remux 1080p AVC LPCM-7³ ACG",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeUnknown,
				cntitle:        "",
				entitle:        "Nande Koko ni Sensei ga!?",
				year:           2019,
				part:           "",
				season:         "",
				episode:        "",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeBluRayRemux,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeLPCM,
				version:        1,
			},
		},
		{
			input: "30.Rock.S02E01.1080p.UHD.BluRay.X264-BORDURE.mkv",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "30 Rock",
				year:           0,
				part:           "",
				season:         "S02",
				episode:        "E01",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUHDBluRay,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "Test.S01E01v2.1080p.WEB-DL.H264.AAC-XXX",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Test",
				year:           0,
				part:           "",
				season:         "S01",
				episode:        "E01",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAAC,
				version:        2,
			},
		},
		{
			input: "Test.S01E12A.1080p.WEB-DL.H264.AAC-XXX",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Test",
				year:           0,
				part:           "",
				season:         "S01",
				episode:        "E12",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "S02E1000.mkv",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "",
				year:           0,
				part:           "",
				season:         "S02",
				episode:        "E1000",
				resourcePix:    meta.ResourcePixUnknown,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "西部世界 12.mkv",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "西部世界",
				entitle:        "",
				year:           0,
				part:           "",
				season:         "S01",
				episode:        "E12",
				resourcePix:    meta.ResourcePixUnknown,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "[ANi] OVERLORD 第四季 - 04 [1080P][Baha][WEB-DL][AAC AVC][CHT].mp4",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "OVERLORD",
				year:           0,
				part:           "",
				season:         "S04",
				episode:        "E04",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "[SweetSub&LoliHouse] Made in Abyss S2 - 03v2 [WebRip 1080p HEVC-10bit AAC ASSx2].mkv",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Made in Abyss",
				year:           0,
				part:           "",
				season:         "S02",
				episode:        "E03",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebRip,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH265_10bit,
				audioEncode:    encode.AudioEncodeAAC,
				version:        2,
			},
		},
		{
			input: "[GM-Team][国漫][斗破苍穹 第5季][Fights Break Sphere V][2022][05][HEVC][GB][4K]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "斗破苍穹",
				entitle:        "Fights Break Sphere V",
				year:           2022,
				part:           "",
				season:         "S05",
				episode:        "E05",
				resourcePix:    meta.ResourcePix2160p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH265,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "Ousama Ranking S01E02-[1080p][BDRIP][X265.FLAC].mkv",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Ousama Ranking",
				year:           0,
				part:           "",
				season:         "S01",
				episode:        "E02",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeBDRip,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH265,
				audioEncode:    encode.AudioEncodeFLAC,
				version:        1,
			},
		},
		{
			input: "[Nekomoe kissaten&LoliHouse] Soredemo Ayumu wa Yosetekuru - 01v2 [WebRip 1080p HEVC-10bit EAC3 ASSx2].mkv",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Soredemo Ayumu wa Yosetekuru",
				year:           0,
				part:           "",
				season:         "S01",
				episode:        "E01",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebRip,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH265_10bit,
				audioEncode:    encode.AudioEncodeEAC3,
				version:        2,
			},
		},
		{
			input: "[喵萌奶茶屋&LoliHouse] 金装的薇尔梅 / Kinsou no Vermeil - 01 [WebRip 1080p HEVC-10bit AAC][简繁内封字幕]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "金装的薇尔梅",
				entitle:        "Kinsou no Vermeil",
				year:           0,
				part:           "",
				season:         "S01",
				episode:        "E01",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebRip,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH265_10bit,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "Hataraku.Maou-sama.S02E05.2022.1080p.CR.WEB-DL.X264.AAC-ADWeb.mkv",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Hataraku Maou sama",
				year:           2022,
				part:           "",
				season:         "S02",
				episode:        "E05",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "The Witch Part 2: The Other One 2022 1080p WEB-DL AAC5.1 H264-tG1R0",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeUnknown,
				cntitle:        "",
				entitle:        "The Witch Part 2: The Other One",
				year:           2022,
				part:           "",
				season:         "",
				episode:        "",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "一夜新娘 - S02E07 - 第 7 集.mp4",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "一夜新娘",
				entitle:        "",
				year:           0,
				part:           "",
				season:         "S02",
				episode:        "E07",
				resourcePix:    meta.ResourcePixUnknown,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "[ANi] 處刑少女的生存之道 - 07 [1080P][Baha][WEB-DL][AAC AVC][CHT].mp4",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "處刑少女的生存之道",
				entitle:        "",
				year:           0,
				part:           "",
				season:         "S01",
				episode:        "E07",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "Stand-up.Comedy.S01E01.PartA.2022.1080p.WEB-DL.H264.AAC-TJUPT.mp4",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Stand up Comedy",
				year:           2022,
				part:           "PartA",
				season:         "S01",
				episode:        "E01",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "教父3.The.Godfather.Part.III.1990.1080p.NF.WEBRip.H264.DDP5.1-PTerWEB.mkv",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeUnknown,
				cntitle:        "教父3",
				entitle:        "The Godfather Part III",
				year:           1990,
				part:           "",
				season:         "",
				episode:        "",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebRip,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeEAC3,
				version:        1,
			},
		},
		{
			input: "A.Quiet.Place.Part.II.2020.1080p.UHD.BluRay.DD+7.1.DoVi.X265-PuTao",
			expected: expectedMeta{
				mediaType:    meta.MediaTypeUnknown,
				cntitle:      "",
				entitle:      "A Quiet Place Part II",
				year:         2020,
				part:         "",
				season:       "",
				episode:      "",
				resourcePix:  meta.ResourcePix1080p,
				resourceType: meta.ResourceTypeUHDBluRay,
				resourceEffect: []meta.ResourceEffect{
					meta.ResourceEffectDovi,
				},
				videoEncode: encode.VideoEncodeH265,
				audioEncode: encode.AudioEncodeEAC3,
				version:     1,
			},
		},
		{
			input: "Childhood.In.A.Capsule.S01E16.2022.1080p.KKTV.WEB-DL.X264.AAC-ADWeb.mkv",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Childhood In A Capsule",
				year:           2022,
				part:           "",
				season:         "S01",
				episode:        "E16",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "[桜都字幕组] 异世界归来的舅舅 / Isekai Ojisan [01][1080p][简体内嵌]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "异世界归来的舅舅",
				entitle:        "Isekai Ojisan",
				year:           0,
				part:           "",
				season:         "S01",
				episode:        "E01",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "【喵萌奶茶屋】★04月新番★[夏日重現/Summer Time Rendering][15][720p][繁日雙語][招募翻譯片源]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "夏日重現",
				entitle:        "Summer Time Rendering",
				year:           0,
				part:           "",
				season:         "S01",
				episode:        "E15",
				resourcePix:    meta.ResourcePix720p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "[NC-Raws] 打工吧！魔王大人 第二季 / Hataraku Maou-sama!! - 02 (B-Global 1920x1080 HEVC AAC MKV)",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "打工吧！魔王大人",
				entitle:        "Hataraku Maou sama!!",
				year:           0,
				part:           "",
				season:         "S02",
				episode:        "E02",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH265,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "The Witch Part 2 The Other One 2022 1080p WEB-DL AAC5.1 H.264-tG1R0",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeUnknown,
				cntitle:        "",
				entitle:        "The Witch Part 2 The Other One",
				year:           2022,
				part:           "",
				season:         "",
				episode:        "",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "The 355 2022 BluRay 1080p DTS-HD MA5.1 X265.10bit-BeiTai",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeUnknown,
				cntitle:        "",
				entitle:        "The 355",
				year:           2022,
				part:           "",
				season:         "",
				episode:        "",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeBluRay,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH265_10bit,
				audioEncode:    encode.AudioEncodeDTSHDMA,
				version:        1,
			},
		},
		{
			input: "Sense8 s01-s02 2015-2017 1080P WEB-DL X265 AC3￡cXcY@FRDS",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Sense8",
				year:           2015,
				part:           "",
				season:         "S01-S02",
				episode:        "",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH265,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "The Heart of Genius S01 13-14 2022 1080p WEB-DL H264 AAC",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "The Heart of Genius",
				year:           2022,
				part:           "",
				season:         "S01",
				episode:        "E13-E14",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "The Heart of Genius E13-14 2022 1080p WEB-DL H264 AAC",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "The Heart of Genius",
				year:           2022,
				part:           "",
				season:         "S01",
				episode:        "E13-E14",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "2022.8.2.Twelve.Monkeys.1995.GBR.4K.REMASTERED.BluRay.1080p.X264.DTS [3.4 GB]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeUnknown,
				cntitle:        "",
				entitle:        "Twelve Monkeys",
				year:           1995,
				part:           "",
				season:         "",
				episode:        "",
				resourcePix:    meta.ResourcePix2160p,
				resourceType:   meta.ResourceTypeBluRay,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeDTS,
				version:        1,
			},
		},
		{
			input: "[NC-Raws] 王者天下 第四季 - 17 (Baha 1920x1080 AVC AAC MP4) [3B1AA7BB].mp4",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "王者天下",
				entitle:        "",
				year:           0,
				part:           "",
				season:         "S04",
				episode:        "E17",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "Sense8 S2E1 2015-2017 1080P WEB-DL X265 AC3￡cXcY@FRDS",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Sense8",
				year:           2015,
				part:           "",
				season:         "S02",
				episode:        "E01",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH265,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "[xyx98]传颂之物/Utawarerumono/うたわれるもの[BDrip][1920x1080][TV 01-26 Fin][hevc-yuv420p10 flac_ac3][ENG PGS]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "传颂之物",
				entitle:        "Utawarerumono うたわれるもの",
				year:           0,
				part:           "",
				season:         "S01",
				episode:        "E01-E26",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeBDRip,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH265_10bit,
				audioEncode:    encode.AudioEncodeAC3,
				version:        1,
			},
		},
		{
			input: "[云歌字幕组][7月新番][欢迎来到实力至上主义的教室 第二季][01][X264 10bit][1080p][简体中文].mp4",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "欢迎来到实力至上主义的教室",
				entitle:        "",
				year:           0,
				part:           "",
				season:         "S02",
				episode:        "E01",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264_10bit,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "Rick and Morty.S06E06.JuRicksic.Mort.1080p.HMAX.WEBRip.DD5.1.X264-NTb[rartv]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Rick and Morty",
				year:           0,
				part:           "",
				season:         "S06",
				episode:        "E06",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebRip,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAC3,
				version:        1,
			},
		},
		{
			input: "rick and Morty.S06E05.JuRicksic.Mort.1080p.HMAX.WEBRip.DD5.1.X264-NTb[rartv]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "rick and Morty",
				year:           0,
				part:           "",
				season:         "S06",
				episode:        "E05",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebRip,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAC3,
				version:        1,
			},
		},
		{
			input: "[Hall_of_C] 诛仙 Zhu Xian (Jade Dynasty) - Episode 19",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "诛仙",
				entitle:        "Zhu Xian Jade Dynasty",
				year:           0,
				part:           "",
				season:         "S01",
				episode:        "E19",
				resourcePix:    meta.ResourcePixUnknown,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "I Woke Up a Vampire S02 2023 2160p NF WEB-DL DDP5.1 Atmos H 265-HHWEB",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "I Woke Up a Vampire",
				year:           2023,
				part:           "",
				season:         "S02",
				episode:        "",
				resourcePix:    meta.ResourcePix2160p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH265,
				audioEncode:    encode.AudioEncodeAtmos,
				version:        1,
			},
		},
		{
			input: "Shadows of the Void S01 2024 1080p WEB-DL H264 AAC-HHWEB",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Shadows of the Void",
				year:           2024,
				part:           "",
				season:         "S01",
				episode:        "",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH264,
				audioEncode:    encode.AudioEncodeAAC,
				version:        1,
			},
		},
		{
			input: "【极影字幕社】★1月新番 Metallic Rouge/金属口红 第13话 GB 1080P MP4（字幕社招人内详）",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "金属口红",
				entitle:        "Metallic Rouge",
				year:           0,
				part:           "",
				season:         "S01",
				episode:        "E13",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			input: "Mai Xiang S01 2019 2160p WEB-DL H.265 DDP2.0-HHWEB",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Mai Xiang",
				year:           2019,
				part:           "",
				season:         "S01",
				episode:        "",
				resourcePix:    meta.ResourcePix2160p,
				resourceType:   meta.ResourceTypeWebDL,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeH265,
				audioEncode:    encode.AudioEncodeEAC3,
				version:        1,
			},
		},
		{
			input: "【喵萌奶茶屋】★剧场版★[青春猪头少年不会梦到娇怜外出妹/Seishun Buta Yarou wa Odekake Sister no Yume o Minai][BDRip][1080p][繁日双语][招募翻译时轴]",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeUnknown,
				cntitle:        "青春猪头少年不会梦到娇怜外出妹",
				entitle:        "Seishun Buta Yarou wa Odekake Sister no Yume o Minai",
				year:           0,
				part:           "",
				season:         "",
				episode:        "",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeBDRip,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
	}

	for _, tc := range testCases {
		t.Run(tc.input, func(t *testing.T) {
			meta := meta.ParseVideoMeta(tc.input)
			require.Equal(t, tc.expected.mediaType, meta.MediaType, "媒体类型不匹配")
			require.Equal(t, tc.expected.cntitle, meta.CNTitle, "中文标题不匹配")
			require.Equal(t, tc.expected.entitle, meta.ENTitle, "英文标题不匹配")
			require.Equal(t, tc.expected.year, meta.Year, "年份不匹配")
			require.Equal(t, tc.expected.part, meta.Part, "分部信息不匹配")
			require.Equal(t, tc.expected.season, meta.GetSeasonStr(), "季信息不匹配")
			require.Equal(t, tc.expected.episode, meta.GetEpisodeStr(), "集信息不匹配")
			require.Equal(t, tc.expected.resourcePix, meta.ResourcePix, "资源像素不匹配")
			require.Equal(t, tc.expected.resourceType, meta.ResourceType, "资源类型不匹配")
			require.Equal(t, tc.expected.resourceEffect, meta.ResourceEffect, "资源效果不匹配")
			require.Equal(t, tc.expected.videoEncode, meta.VideoEncode, "视频编码不匹配")
			require.Equal(t, tc.expected.audioEncode, meta.AudioEncode, "音频编码不匹配")
			require.Equal(t, tc.expected.version, meta.Version, "版本号不匹配")
		})

	}
}

func TestParseVideoMetaByPath(t *testing.T) {
	testCases := []struct {
		path     string
		expected expectedMeta
	}{
		{
			path: "/volume1/电视剧/西部世界 第二季 (2016)/5.mkv",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "西部世界",
				entitle:        "",
				year:           2016,
				part:           "",
				season:         "S02",
				episode:        "E05",
				resourcePix:    meta.ResourcePixUnknown,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			path: "/movies/The Vampire Diaries (2009) [tmdbid=18165]/The.Vampire.Diaries.S01E01.1080p.mkv",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "The Vampire Diaries",
				year:           2009,
				part:           "",
				season:         "S01",
				episode:        "E01",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			path: "/movies/Inception (2010) [tmdbid-27205]/Inception.2010.1080p.mkv",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeUnknown,
				cntitle:        "",
				entitle:        "Inception",
				year:           2010,
				part:           "",
				season:         "",
				episode:        "",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			path: "/movies/Breaking Bad (2008) [tmdb=1396]/Season 1/Breaking.Bad.S01E01.1080p.mkv",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Breaking Bad",
				year:           2008,
				part:           "",
				season:         "S01",
				episode:        "E01",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			path: "/tv/Game of Thrones (2011) {tmdb=1399}/Season 1/Game.of.Thrones.S01E01.1080p.mkv",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeTV,
				cntitle:        "",
				entitle:        "Game of Thrones",
				year:           2011,
				part:           "",
				season:         "S01",
				episode:        "E01",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
		{
			path: "/movies/Avatar (2009) {tmdb-19995}/Avatar.2009.1080p.mkv",
			expected: expectedMeta{
				mediaType:      meta.MediaTypeUnknown,
				cntitle:        "",
				entitle:        "Avatar",
				year:           2009,
				part:           "",
				season:         "",
				episode:        "",
				resourcePix:    meta.ResourcePix1080p,
				resourceType:   meta.ResourceTypeUnknown,
				resourceEffect: make([]meta.ResourceEffect, 0),
				videoEncode:    encode.VideoEncodeUnknown,
				audioEncode:    encode.AudioEncodeUnknown,
				version:        1,
			},
		},
	}
	for _, tc := range testCases {
		t.Run(tc.path, func(t *testing.T) {
			meta := meta.ParseVideoMetaByPath(tc.path)
			require.Equal(t, tc.expected.mediaType, meta.MediaType, "媒体类型不匹配")
			require.Equal(t, tc.expected.cntitle, meta.CNTitle, "中文标题不匹配")
			require.Equal(t, tc.expected.entitle, meta.ENTitle, "英文标题不匹配")
			require.Equal(t, tc.expected.year, meta.Year, "年份不匹配")
			require.Equal(t, tc.expected.part, meta.Part, "分部信息不匹配")
			require.Equal(t, tc.expected.season, meta.GetSeasonStr(), "季信息不匹配")
			require.Equal(t, tc.expected.episode, meta.GetEpisodeStr(), "集信息不匹配")
			require.Equal(t, tc.expected.resourcePix, meta.ResourcePix, "资源像素不匹配")
			require.Equal(t, tc.expected.resourceType, meta.ResourceType, "资源类型不匹配")
			require.Equal(t, tc.expected.resourceEffect, meta.ResourceEffect, "资源效果不匹配")
			require.Equal(t, tc.expected.videoEncode, meta.VideoEncode, "视频编码不匹配")
			require.Equal(t, tc.expected.audioEncode, meta.AudioEncode, "音频编码不匹配")
			require.Equal(t, tc.expected.version, meta.Version, "版本号不匹配")
		})

	}
}
