49 lines
1.0 KiB
C#
49 lines
1.0 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using Learn.Models;
|
|
|
|
namespace Learn.Parsers;
|
|
|
|
public static class ItemFieldExtension
|
|
{
|
|
#region 基础信息
|
|
|
|
public static string Name(this Item item)
|
|
{
|
|
var path = item.MainInfo["Path"];
|
|
return Path.GetFileName(path);
|
|
}
|
|
|
|
public static bool IsFolder(this Item item)
|
|
{
|
|
return item.MainInfo["IsDir"] == "True";
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
public static void SetGroupIfNotExist(this Item item, string group)
|
|
{
|
|
item.Info.TryAdd("Group", group);
|
|
}
|
|
|
|
public static void SetTitleIfNotExist(this Item item, string title)
|
|
{
|
|
item.Info.TryAdd("Title", title);
|
|
}
|
|
|
|
public static void SetRawTitle(this Item item, string rawTitle)
|
|
{
|
|
item.Info.TryAdd("RawTitle", rawTitle);
|
|
}
|
|
|
|
public static string RawTitle(this Item item)
|
|
{
|
|
return item.Info["RawTitle"];
|
|
}
|
|
|
|
public static void SetSeasonIfNotExist(this Item item, string season)
|
|
{
|
|
item.Info.TryAdd("Season", season);
|
|
}
|
|
} |