Skip to content

Commit f931341

Browse files
committed
Optimize identity
1 parent 8ccf56b commit f931341

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

Jellyfin.Plugin.MetaShark.Test/ParseNameTest.cs

+24
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,30 @@ public void TestCheckExtra()
264264
Assert.IsTrue(parseResult.IsExtra);
265265

266266

267+
fileName = "Evangelion 3.0+1.11 Thrice Upon a Time - Voice Message01 In Shin Evangelion No All Night Nippo (BDRIP 1920x1080 x265 10bit ac3)";
268+
parseResult = NameParser.Parse(fileName);
269+
Assert.IsTrue(parseResult.IsExtra);
270+
271+
fileName = "Evangelion 3.0+1.11 Thrice Upon a Time - Message1 In Kinyoubi Roadshow (BDRIP 1920x1080 x265 10bit ac3)";
272+
parseResult = NameParser.Parse(fileName);
273+
Assert.IsTrue(parseResult.IsExtra);
274+
275+
// fileName = "Evangelion 3.0+1.11 Thrice Upon a Time - CM (BDRIP 1920x1080 x265 10bit ac3)";
276+
// parseResult = NameParser.Parse(fileName);
277+
// Assert.IsTrue(parseResult.IsExtra);
278+
279+
// fileName = "Evangelion 3.0+1.11 Thrice Upon a Time - Logo (BDRIP 1920x1080 x265 10bit ac3)";
280+
// parseResult = NameParser.Parse(fileName);
281+
// Assert.IsTrue(parseResult.IsExtra);
282+
283+
// fileName = "Evangelion 3.0+1.11 Thrice Upon a Time - Audio Guide (BDRIP 1920x1080 x265 10bit ac3)";
284+
// parseResult = NameParser.Parse(fileName);
285+
// Assert.IsTrue(parseResult.IsExtra);
286+
287+
// fileName = "Evangelion 3.0+1.11 Thrice Upon a Time - BD&DVD PV (BDRIP 1920x1080 x265 10bit ac3).mkv";
288+
// parseResult = NameParser.Parse(fileName);
289+
// Assert.IsTrue(parseResult.IsExtra);
290+
267291
}
268292

269293
}

Jellyfin.Plugin.MetaShark/Core/NameParser.cs

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public static class NameParser
2525

2626
private static readonly Regex specialIndexNumberReg = new Regex(@"ep(\d{1,2})", RegexOptions.Compiled | RegexOptions.IgnoreCase);
2727

28+
private static readonly Regex resolutionReg = new Regex(@"\d{3,4}x\d{3,4}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
29+
2830
public static ParseNameResult Parse(string fileName, bool isEpisode = false)
2931
{
3032
fileName = NormalizeFileName(fileName);
@@ -144,6 +146,9 @@ private static string CleanName(string name)
144146
// emby原始电影解析
145147
public static ParseNameResult ParseMovie(string fileName)
146148
{
149+
// 默认解析器会错误把分辨率当年份,先删除
150+
fileName = resolutionReg.Replace(fileName, "");
151+
147152
var parseResult = new ParseNameResult();
148153
var nameOptions = new Emby.Naming.Common.NamingOptions();
149154
var result = Emby.Naming.Video.VideoResolver.CleanDateTime(fileName, nameOptions);

Jellyfin.Plugin.MetaShark/Providers/MovieProvider.cs

+24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Globalization;
4+
using System.IO;
45
using System.Linq;
56
using System.Net.Http;
67
using System.Security.Cryptography;
@@ -92,6 +93,13 @@ public async Task<MetadataResult<Movie>> GetMetadata(MovieInfo info, Cancellatio
9293
this.Log($"GetMovieMetadata of [name]: {info.Name}");
9394
var result = new MetadataResult<Movie>();
9495

96+
// 处理extras影片
97+
var extraResult = this.HandleExtraType(info);
98+
if (extraResult != null)
99+
{
100+
return extraResult;
101+
}
102+
95103
// 使用刷新元数据时,providerIds会保留旧有值,只有识别/新增才会没值
96104
var sid = info.GetProviderId(DoubanProviderId);
97105
var tmdbId = info.GetProviderId(MetadataProvider.Tmdb);
@@ -245,6 +253,22 @@ public async Task<MetadataResult<Movie>> GetMetadata(MovieInfo info, Cancellatio
245253
}
246254

247255

256+
private MetadataResult<Movie>? HandleExtraType(MovieInfo info)
257+
{
258+
// 特典或extra视频可能和正片放在同一目录
259+
// TODO:插件暂时不支持设置影片为extra类型,只能直接忽略处理(最好放extras目录)
260+
var fileName = Path.GetFileNameWithoutExtension(info.Path) ?? info.Name;
261+
var parseResult = NameParser.Parse(fileName);
262+
if (parseResult.IsExtra)
263+
{
264+
this.Log($"Found extra of [name]: {fileName}");
265+
return new MetadataResult<Movie>();
266+
}
267+
268+
return null;
269+
}
270+
271+
248272
private IEnumerable<PersonInfo> GetPersons(TMDbLib.Objects.Movies.Movie item)
249273
{
250274
// 演员

Jellyfin.Plugin.MetaShark/Vendor/AnitomySharp/Keyword.cs

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ static KeywordManager()
8989
"MENU",
9090
// 广告 Commercial Message 电视放送广告,时长一般在 7s/15s/30s/45s/... 左右
9191
"CM","SPOT",
92+
// 语音信息
93+
"MESSAGE",
9294
// 宣传片/预告片 Promotion Video / Trailer 一般时长在 1~2min 命名参考原盘和 jsum
9395
"PV", "Teaser","TRAILER", "DRAMA",
9496
// 真人特典 Interview/Talk/Stage... 目前我们对于节目、采访、舞台活动、制作等三次元画面的长视频,一概怼成 IV。

0 commit comments

Comments
 (0)