Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 忽略小于五分钟的文件 #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Mrs4s
Copy link

@Mrs4s Mrs4s commented Jul 29, 2023

#33 (comment)

因为我也比较需要, 所以用一种比较魔法的方式实现了这个功能. (jellyfin 的api文档也太少了, 我实在找不到在 IgnoreRule 获取文件时长的方法, 只能用这种比较魔法的方式实现)
缺点是需要刷新两次媒体库才会生效.

@kookxiang
Copy link
Owner

我试试直接用 IResolverIgnoreRule 能不能解决,尽量不走魔改吧

@Mrs4s
Copy link
Author

Mrs4s commented Jul 30, 2023

我试试直接用 IResolverIgnoreRule 能不能解决,尽量不走魔改吧

如果要直接在 IResolverIgnoreRule 获取媒体时长的话, 只能直接调用 ffmpeg 获取了 , 这样的话整个刷新操作会调用两次 ffmpeg 可能会比较耗时?我观察到刷新一次 MediaInfo 需要一两秒左右.

jellyfin 调用刷新逻辑应该是

首先文件系统解析在 ILibraryManager.ResolvePaths 调用 IResolverIgnoreRule 处理忽略规则.
然后刷新Metadata调用 MediaBrowser.Providers.MediaInfo.FFProbeVideoInfo.GetMediaInfo

参考
https://github.com/jellyfin/jellyfin/blob/d3c7af0d5c3709e18eac71fdb0279e985b6a9113/MediaBrowser.Controller/Entities/Folder.cs#L347 解析文件系统

https://github.com/jellyfin/jellyfin/blob/d3c7af0d5c3709e18eac71fdb0279e985b6a9113/MediaBrowser.Controller/Entities/Folder.cs#L480 刷新Metadata

https://github.com/jellyfin/jellyfin/blob/d3c7af0d5c3709e18eac71fdb0279e985b6a9113/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs#L150 获取MediaInfo

也就是说在调用 IResolverIgnoreRule 的时刻 jellyfin 并不知道媒体时长.
不过应该可以在第一次刷新后调用 LibraryManager 获取已知的时长.. 但是得研究如何通过文件系统获取到 BaseItem

@chu-shen
Copy link
Contributor

没发现时长+1

我这采用文件大小来辅助判断:

var fileInfo = _fileSystem.GetFileSystemInfo(_info.Path);
……
else if (fileInfo is not null && fileInfo.Length > 100000000)
{
                // 大于 100MB 的可能是 Movie 等类型
                // 存在误判的可能性,导致被识别为第一集。配合 SP 文件夹判断可降低误判的副作用
                episodeIndex = 1;
                _log.LogDebug("Use episode number: {episodeIndex} for {fileName}, because file size is {size} GB", episodeIndex, fileName,fileInfo.Length/1000000000);
}

https://github.com/chu-shen/jellyfin-plugin-bangumi/blob/354b6e9d5c8cc6e2f975de87c0f0916a6e71f2cb/Jellyfin.Plugin.Bangumi/Parser/Anitomy/AnitomyEpisodeParser.cs#L137-L143C14


如果是为了解决特典的问题,可以看下这个PR

能帮忙测试下就更好了🤣
https://ci.appveyor.com/project/kookxiang/jellyfin-plugin-bangumi/builds/47669962/artifacts

chu-shen added a commit to chu-shen/jellyfin-plugin-bangumi that referenced this pull request Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants