Skip to content

Commit 2408a2f

Browse files
committed
feat: support path name attribute. close #75
1 parent 945930d commit 2408a2f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Jellyfin.Plugin.MetaShark/Providers/BaseProvider.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public abstract class BaseProvider
5050

5151
protected Regex regMetaSourcePrefix = new Regex(@"^\[.+\]", RegexOptions.Compiled);
5252
protected Regex regSeasonNameSuffix = new Regex(@"\s第[0-9一二三四五六七八九十]+?季$|\sSeason\s\d+?$|(?<![0-9a-zA-Z])\d$", RegexOptions.Compiled);
53+
protected Regex regDoubanIdAttribute = new Regex(@"\[(?:douban|doubanid)-(\d+?)\]", RegexOptions.Compiled);
5354

5455
protected PluginConfiguration config
5556
{
@@ -107,11 +108,17 @@ public async Task<HttpResponseMessage> GetImageResponse(string url, Cancellation
107108
protected async Task<string?> GuessByDoubanAsync(ItemLookupInfo info, CancellationToken cancellationToken)
108109
{
109110
var fileName = GetOriginalFileName(info);
111+
// 从文件名属性格式获取,如[douban-12345]或[doubanid-12345]
112+
var doubanId = this.regDoubanIdAttribute.FirstMatchGroup(fileName);
113+
if (!string.IsNullOrWhiteSpace(doubanId))
114+
{
115+
this.Log($"Found douban [id] by attr: {doubanId}");
116+
return doubanId;
117+
}
110118
var parseResult = NameParser.Parse(fileName);
111119
var searchName = !string.IsNullOrEmpty(parseResult.ChineseName) ? parseResult.ChineseName : parseResult.Name;
112120
info.Year = parseResult.Year; // 默认parser对anime年份会解析出错,以anitomy为准
113121

114-
115122
this.Log($"GuessByDouban of [name]: {info.Name} [file_name]: {fileName} [year]: {info.Year} [search name]: {searchName}");
116123
List<DoubanSubject> result;
117124
DoubanSubject? item;

0 commit comments

Comments
 (0)