Skip to content

Commit 3d00ef2

Browse files
committed
Add: 添加 MetadataProvidersGuard 日志开关并更新配置说明
1 parent ce12e4f commit 3d00ef2

File tree

5 files changed

+30
-9
lines changed

5 files changed

+30
-9
lines changed

Configuration/GeneralOptions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public class GeneralOptions : EditableOptionsBase
2424
[Description("开启后阻止 Emby 默认的 CanRefresh 通过,仅插件内部允许调用。")]
2525
public bool DisableSystemMetadataRefresh { get; set; } = true;
2626

27+
[DisplayName("显示 MetadataProvidersGuard 日志")]
28+
[Description("开启后记录 CanRefresh 拦截/放行日志,默认关闭。")]
29+
public bool EnableMetadataProvidersGuardLog { get; set; } = false;
30+
2731
[DisplayName("MediaInfo JSON 存储根目录")]
2832
[Description("为空时,JSON 保存到媒体文件同目录。填写后会用这个值,拼接媒体路径存储Json。")]
2933
[Editor(typeof(EditorFolderPicker), typeof(EditorBase))]

MediaInfoKeeper.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<Description>MediaInfoKeeper Emby plugin</Description>
55
<PackageTags>emby;plugin;pms;media;server;</PackageTags>
66
<BaseOutputPath>Build\bin\</BaseOutputPath>
7-
<AssemblyVersion>1.3.5.0</AssemblyVersion>
8-
<FileVersion>1.3.5.0</FileVersion>
9-
<Version>1.3.5</Version>
7+
<AssemblyVersion>1.3.6.0</AssemblyVersion>
8+
<FileVersion>1.3.6.0</FileVersion>
9+
<Version>1.3.6</Version>
1010
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
1111
</PropertyGroup>
1212
<ItemGroup>

Plugin.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ public Plugin(
6666
FileSystem = fileSystem;
6767

6868
FfprobeGuard.Initialize(this.logger, this.Options.General.DisableSystemFfprobe);
69-
MetadataProvidersGuard.Initialize(this.logger, this.Options.General.DisableSystemMetadataRefresh);
69+
MetadataProvidersGuard.Initialize(this.logger,
70+
this.Options.General.DisableSystemMetadataRefresh,
71+
this.Options.General.EnableMetadataProvidersGuardLog);
7072

7173
this.currentPersistMediaInfo = this.Options.General.PersistMediaInfoEnabled;
7274

@@ -149,6 +151,8 @@ protected override void OnOptionsSaved(PluginConfiguration options)
149151
this.logger.Info($"ScheduledTaskLibraries 设置为 {(string.IsNullOrEmpty(options.LibraryScope.ScheduledTaskLibraries) ? "EMPTY" : options.LibraryScope.ScheduledTaskLibraries)}");
150152

151153
FfprobeGuard.Configure(options.General.DisableSystemFfprobe);
154+
MetadataProvidersGuard.Configure(options.General.DisableSystemMetadataRefresh,
155+
options.General.EnableMetadataProvidersGuardLog);
152156
}
153157

154158
private string NormalizeScopedLibraries(string raw)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ MediaInfoKeeper 的目标是把媒体信息保存为 JSON,在需要时快速
6262
- 条目移除时删除 JSON:删除条目时移除对应 JSON。
6363
- 禁用 Emby 系统 ffprobe:仅插件内部允许调用。
6464
- 禁用 Emby 系统元数据刷新:仅插件内部允许调用。
65+
- 显示 MetadataProvidersGuard 日志:记录 CanRefresh 拦截/放行日志,默认关闭。
6566
- 追更媒体库:用于入库触发与删除 JSON 逻辑;留空表示全部。支持多选。
6667
- 计划任务媒体库:用于计划任务范围;留空表示全部。支持多选。
6768
- 最近入库条目数量:用于“最近入库”相关计划任务,默认 100。

Services/MetadataProvidersGuard.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ public static class MetadataProvidersGuard
2222
private static MethodInfo instanceCanRefresh;
2323
private static ILogger logger;
2424
private static bool isEnabled;
25+
private static bool logEnabled;
2526

26-
public static void Initialize(ILogger pluginLogger, bool disableSystemMetadata)
27+
public static void Initialize(ILogger pluginLogger, bool disableSystemMetadata, bool enableLog)
2728
{
2829
if (harmony != null) return;
2930

3031
logger = pluginLogger;
3132
isEnabled = disableSystemMetadata;
33+
logEnabled = enableLog;
3234

3335
try
3436
{
@@ -89,10 +91,14 @@ public static void Initialize(ILogger pluginLogger, bool disableSystemMetadata)
8991
}
9092
}
9193

92-
public static void Configure(bool disableSystemMetadata)
94+
public static void Configure(bool disableSystemMetadata, bool enableLog)
9395
{
9496
isEnabled = disableSystemMetadata;
95-
logger?.Info("MetadataProvidersGuard " + (isEnabled ? "enabled" : "disabled"));
97+
logEnabled = enableLog;
98+
if (logEnabled)
99+
{
100+
logger?.Info("MetadataProvidersGuard " + (isEnabled ? "enabled" : "disabled"));
101+
}
96102
}
97103

98104
public static IDisposable Allow()
@@ -111,11 +117,17 @@ private static bool CanRefreshPrefix(ref bool __result)
111117
if (GuardCount.Value == 0)
112118
{
113119
__result = false;
114-
logger?.Info($"MetadataProvidersGuard 拦截 CanRefresh");
120+
if (logEnabled)
121+
{
122+
logger?.Info($"MetadataProvidersGuard 拦截 CanRefresh");
123+
}
115124
return false;
116125
}
117126

118-
logger?.Info($"MetadataProvidersGuard 放行 CanRefresh");
127+
if (logEnabled)
128+
{
129+
logger?.Info($"MetadataProvidersGuard 放行 CanRefresh");
130+
}
119131
return true;
120132
}
121133

0 commit comments

Comments
 (0)