using System; using System.Collections.Generic; using System.IO; using Learn.Models; namespace Learn.Parsers; public static class ItemFields { public enum ItemType { Unknown, Extra, Subtitle, Episode } #region 基础信息 public static string MainKey_Path => "Path"; public static string MainKey_IsDir => "IsDir"; public static string Name(this Item item) { var path = item.MainInfo[MainKey_Path]; return Path.GetFileName(path); } public static bool IsFolder(this Item item) { return item.MainInfo[MainKey_IsDir] == "True"; } #endregion #region 普通字段 public static string Key_Group => "Group"; public static string Key_Title => "Title"; public static string Key_RawTitle => "RawTitle"; public static string Key_Season => "Season"; public static string Key_Type => "Type"; public static string Key_SubtitleLanguage => "SubLang"; public static string Key_Episode => "Episode"; public static string Key_Year => "Year"; public static string Key_TMDBID => "TMDBID"; public static ItemType Type(this Item item) { if (item.Info.TryGetValue(Key_Type, out var typeName)) { if(Enum.TryParse(typeName, out ItemType type)) { return type; } } return ItemType.Unknown; } #endregion }