60 lines
1.4 KiB
C#
60 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using Learn.Models;
|
|
|
|
namespace Learn.Parsers;
|
|
|
|
public static class ItemFields
|
|
{
|
|
#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
|
|
|
|
|
|
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_Year => "Year";
|
|
|
|
|
|
public static void SetGroupIfNotExist(this Item item, string group)
|
|
{
|
|
item.Info.TryAdd(Key_Group, group);
|
|
}
|
|
|
|
public static void SetTitleIfNotExist(this Item item, string title)
|
|
{
|
|
item.Info.TryAdd(Key_Title, title);
|
|
}
|
|
|
|
public static void SetRawTitleIfNotExist(this Item item, string rawTitle)
|
|
{
|
|
item.Info.TryAdd(Key_RawTitle, rawTitle);
|
|
}
|
|
|
|
public static void SetSeasonIfNotExist(this Item item, string season)
|
|
{
|
|
item.Info.TryAdd(Key_Season, season);
|
|
}
|
|
|
|
public static void SetYear(this Item item, int year)
|
|
{
|
|
item.Info[Key_Year] = year.ToString();
|
|
}
|
|
} |