Skip to content

Commit 48213a0

Browse files
committed
update
1 parent 45e2ec7 commit 48213a0

File tree

6 files changed

+39
-46
lines changed

6 files changed

+39
-46
lines changed

Configuration/MainPageOptions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ public class MainPageOptions : EditableOptionsBase
5757
public string ScheduledTaskLibraries { get; set; } = string.Empty;
5858

5959
[DisplayName("最近入库时间窗口(天)")]
60-
[Description("用于“刷新媒体元数据(最近入库)、扫描片头(最近入库)”计划任务,仅处理指定天数内入库的条目,0 表示不限制。")]
60+
[Description("用于“刷新媒体元数据”计划任务,仅处理指定天数内入库的条目,0 表示不限制。")]
6161
[MinValue(0)]
6262
[MaxValue(3650)]
6363
public int RecentItemsDays { get; set; } = 3;
6464

6565
[DisplayName("最近入库媒体筛选数量")]
66-
[Description("用于“提取媒体信息(最近入库)”计划任务,默认 100。")]
66+
[Description("用于“提取媒体信息、扫描片头”计划任务,默认 100。")]
6767
[MinValue(1)]
6868
[MaxValue(1000)]
6969
public int RecentItemsLimit { get; set; } = 100;
@@ -142,7 +142,7 @@ void AddGroup(string title, params string[] propertyNames)
142142
groupedItems.Add(new EditorGroup(title, items.ToArray(), $"group{groupIndex}", root.Id, null));
143143
}
144144

145-
AddGroup("全局开关",
145+
AddGroup("插件启停",
146146
nameof(PersistMediaInfoEnabled));
147147

148148
AddGroup("基本设置",

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.5.6.0</AssemblyVersion>
8-
<FileVersion>1.5.6.0</FileVersion>
9-
<Version>1.5.6</Version>
7+
<AssemblyVersion>1.5.7.0</AssemblyVersion>
8+
<FileVersion>1.5.7.0</FileVersion>
9+
<Version>1.5.7</Version>
1010
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
1111
</PropertyGroup>
1212
<ItemGroup>

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ MediaInfoKeeper
1919
--------
2020

2121
- 刷新媒体元数据(最近入库):刷新后从 JSON 导入 MediaInfo(可选覆盖或补全)。
22+
- 扫描片头(最近入库):按入库时间倒序取最近 N 条(最近入库媒体筛选数量)执行片头检测。
2223
- 提取媒体信息(最近入库):对最近入库条目执行提取或恢复并写入 JSON。
2324
- 提取媒体信息:对范围内存量条目执行提取或恢复并写入 JSON。
2425
- 导出媒体信息:对已有 MediaInfo 的条目导出 JSON。

ScheduledTask/ExtractRecentMediaInfoTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public ExtractRecentMediaInfoTask(ILogManager logManager, ILibraryManager librar
2626

2727
public string Key => "MediaInfoKeeperExtractRecentMediaInfoTask";
2828

29-
public string Name => "2.提取媒体信息";
29+
public string Name => "3.提取媒体信息";
3030

3131
public string Description => "计划任务媒体库范围内,按入库时间倒序取最近 N 条(“最近入库媒体筛选数量”)恢复/提取媒体信息并写入 JSON。(已存在则恢复)";
3232

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using System.Threading;
45
using System.Threading.Tasks;
6+
using MediaBrowser.Controller.Entities;
7+
using MediaBrowser.Controller.Entities.TV;
58
using MediaBrowser.Controller.Library;
9+
using MediaBrowser.Model.Entities;
610
using MediaBrowser.Model.Logging;
11+
using MediaBrowser.Model.Querying;
712
using MediaBrowser.Model.Tasks;
8-
using MediaInfoKeeper.Services;
913

1014
namespace MediaInfoKeeper.ScheduledTask
1115
{
1216
public class ScanRecentIntroTask : IScheduledTask
1317
{
1418
private readonly ILogger logger;
19+
private readonly ILibraryManager libraryManager;
1520
public ScanRecentIntroTask(ILogManager logManager, ILibraryManager libraryManager)
1621
{
1722
this.logger = logManager.GetLogger(Plugin.PluginName);
18-
_ = libraryManager;
23+
this.libraryManager = libraryManager;
1924
}
2025

2126
public string Key => "MediaInfoKeeperScanRecentIntroTask";
2227

23-
public string Name => "3.扫描片头";
28+
public string Name => "2.扫描片头";
2429

25-
public string Description => "全局媒体库范围内,按“最近入库时间窗口(天)”筛选(0=不限制)的剧集执行片头检测。";
30+
public string Description => "全局媒体库范围内,按入库时间倒序取最近 N 条(“最近入库媒体筛选数量”)的剧集执行片头检测。";
2631

2732
public string Category => Plugin.TaskCategoryName;
2833

@@ -34,10 +39,31 @@ public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
3439
public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
3540
{
3641
this.logger.Info("最近入库片头扫描计划任务开始");
42+
var episodes = FetchRecentEpisodes();
3743
await Plugin.IntroScanService
38-
.ScanRecentIntroAsync(cancellationToken, progress)
44+
.ScanEpisodesAsync(episodes, cancellationToken, progress)
3945
.ConfigureAwait(false);
4046
this.logger.Info("最近入库片头扫描计划任务完成");
4147
}
48+
49+
private List<Episode> FetchRecentEpisodes()
50+
{
51+
var query = new InternalItemsQuery
52+
{
53+
Recursive = true,
54+
HasPath = true,
55+
MediaTypes = new[] { MediaType.Video }
56+
};
57+
58+
var episodes = this.libraryManager.GetItemList(query)
59+
.OfType<Episode>()
60+
.Where(i => i.ExtraType is null)
61+
.OrderByDescending(i => i.DateCreated)
62+
.Take(Math.Max(1, Plugin.Instance.Options.MainPage.RecentItemsLimit))
63+
.ToList();
64+
65+
this.logger.Info($"扫描条目数 {episodes.Count}");
66+
return episodes;
67+
}
4268
}
4369
}

Services/IntroScanService.cs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@ public IntroScanService(ILogManager logManager, ILibraryManager libraryManager)
2727
this.libraryManager = libraryManager;
2828
}
2929

30-
public async Task ScanRecentIntroAsync(CancellationToken cancellationToken, IProgress<double> progress)
31-
{
32-
this.logger.Info("最近入库片头扫描开始");
33-
34-
var episodes = FetchRecentEpisodes();
35-
await ScanEpisodesAsync(episodes, cancellationToken, progress).ConfigureAwait(false);
36-
37-
this.logger.Info("最近入库片头扫描完成");
38-
}
39-
4030
public async Task ScanEpisodesAsync(
4131
IReadOnlyList<Episode> episodes,
4232
CancellationToken cancellationToken,
@@ -105,30 +95,6 @@ public async Task ScanEpisodesAsync(
10595
this.logger.Info($"扫描完成,条目数 {total}");
10696
}
10797

108-
public List<Episode> FetchRecentEpisodes()
109-
{
110-
var query = new InternalItemsQuery
111-
{
112-
Recursive = true,
113-
HasPath = true,
114-
MediaTypes = new[] { MediaType.Video }
115-
};
116-
117-
var cutoff = Plugin.Instance.Options.MainPage.RecentItemsDays > 0
118-
? DateTime.UtcNow.AddDays(-Plugin.Instance.Options.MainPage.RecentItemsDays)
119-
: (DateTime?)null;
120-
121-
var episodes = this.libraryManager.GetItemList(query)
122-
.OfType<Episode>()
123-
.Where(i => i.ExtraType is null)
124-
.Where(i => cutoff == null || i.DateCreated >= cutoff)
125-
.OrderByDescending(i => i.DateCreated)
126-
.ToList();
127-
128-
this.logger.Info($"扫描条目数 {episodes.Count}");
129-
return episodes;
130-
}
131-
13298
public bool HasIntroMarkers(BaseItem item)
13399
{
134100
return Plugin.IntroSkipChapterApi.GetIntroStart(item).HasValue ||

0 commit comments

Comments
 (0)