mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-04 18:09:12 +03:00
Plugin cannot change Episode metadata like ParentIndexNumber with some files #6994
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @wsgh0202 on GitHub (May 8, 2025).
Description of the bug
The following issue involves the plugin not working properly, I debugged the code on both sides and think the problem is on Jellyfin's side
I'm using the jellyfin-plugin-bangumi plugin to grab the metadata for the animation, but it always recognizes the special episode content (ParentIndexNumber should be 0) as the main episode content (ParentIndexNumber>0)
The plugin implements the
IRemoteMetadataProvider<Episode, EpisodeInfo>interface, and refreshing the metadata during debugging confirms thatItem.ParentIndexNumberofMetadataResult<Episode>returned byGetMetadatamethod is 0, but the SeasonNumber of the Episode is always 1.Plugins can be replaced with your plugin for debugging purposes, e.g. a blank plugin that implements only the
IRemoteMetadataProvider<Episode, EpisodeInfo>interface, modifying the parent directory (seeReproduction stepsfor the directory structure) with a SeasonNumber of1, modifying the SP subdirectory to0ornull.Reproduction steps
For adding Series for the first time:
Install the plugin
Modify the media library, enable the plugin only in any type of metadata downloaders that the plugin has implemented
Add the following directory structure to the media library and create a blank file.
Scan the library(Refresh mode: Scan for new and updated files)
Enter the Series and see the Season 1 content.
For repeated debugging:
SP\Macross Delta_SP01 [AV1-10bit Opus].mkv) tonullor0using theEdit Metadatamenu.Refresh Metadatamenu, select the Refresh mode toReplace all metadata.What is the current bug behavior?
Season 1 has an Episode count of 37 because it incorrectly contains the contents of the subdirectory SP
What is the expected correct behavior?
Season 1 should only contain the 27 Episodes of the main directory
Jellyfin Server version
10.10.0+
Specify commit id
aefb9b2cffSpecify unstable release number
No response
Specify version number
No response
Specify the build version
10.10.7
Environment
Jellyfin logs
FFmpeg logs
Client / Browser logs
No response
Relevant screenshots or videos
Library Setting
Season 1 contains the special editions incorrectly
Season Number of special editions should be 0 or null
Additional information
Code Analysis
I actually troubleshot the cause, but I'm new to the project and not sure if it's intentional or not
I'm using the
v10.10.7version of the code with the tag, but the link below is to the master branch, as the relevant part remains unchanged.before calling IRemoteMetadataProvider<Episode, EpisodeInfo>::GetMetadata method, Jellyfin will call LibraryManager::FillMissingEpisodeNumbersFromPath method to initialize the incoming Episode info.
During initialization, the EpisodePathParser::Parse method uses the built-in regular expression to retrieve the Season Number.
if the Season Number is obtained, it will be used as the ParentIndexNumber of the incoming EpisodeInfo.
in MetadataService<Episode, EpisodeInfo>::ExecuteRemoteProviders method, call IRemoteMetadataProvider<Episode, EpisodeInfo>::GetMetadata method to get metadata
call the MetadataService::MergeData method to merge the metadata
Save the final merged metadata
There are a number of reasons for the problem in the steps above:
In step 2, there is a regular expression
([0-9]+)-([0-9]+)that happens to match theAV1-10bitpart of the fileSP\Macross Delta_SP01 [AV1-10bit Opus].mkv, resulting in SeasonNumber always being 1. EpisodeNumber is always 10In step 5, the
replaceDataparameter passed into theMergeDatamethod wasfalsebecause it was passed in as a fixed valueThe
MergeDatamethod always hastarget.ParentIndexNumberas 1 when mergingParentIndexNumber(targetis temp.Item), resulting in the value not being updatedAs a comparison, although the EpisodeNumber in step 2 is always 10, the
temp.Item.IndexNumberdoes not use this value, thetarget.IndexNumberis always null, so the merge can be successful, the initialization code for temp is referenced: https://github.com/jellyfin/jellyfin/blob/master/MediaBrowser.Providers/Manager/MetadataService.cs#L743-L751Trying to fix
I implemented such a class in the plugin and modified the ParentIndexNumber successfully
Doubt
I can't find much reference documentation or specification about the development of the plugin, here are what confuse me:
Is it reasonable to modify the ParentIndexNumber of Episode in
IRemoteMetadataProvider<Episode, EpisodeInfo>, if not, where should I change it?Although the attempt to fix the problem was successful, I doubt this is what a plugin should be doing
There are only two packages mentioned in the plugin documentation, however inheriting
MetadataServicerequiresMediaBrowser.Providers, which I can only introduce via a project reference, as I can't find the corresponding nuget packageMetadataServicedoesn't work likeIRemoteMetadataProviderwhich can be enabled, disabled and sorted in the webui, as it may change the way other plugins work@wsgh0202 commented on GitHub (May 10, 2025):
For others who encounter the same issue: