Protected 86 Posted August 5, 2024 Posted August 5, 2024 (edited) I'm trying to learn how to add more stuff from my filesystem to my library. According to the wiki, I should be able to "create my own media types" by implementing IItemResolver, so I created a very simple experimental resolver with an associated type GenericItem which is just an unmodified BaseItem. The resolver currently does something like this: public class GenericItemResolver : BaseItemResolver<GenericItem>, IItemResolver { public GenericItemResolver(ILibraryManager libraryManager, ILogger logger) : base(libraryManager, logger) { } public override ResolverPriority Priority => ResolverPriority.Last; protected override bool IsSupportedFile(FileSystemMetadata file, LibraryOptions libraryOptions) { return !file.IsDirectory; } protected override GenericItem Resolve(ItemResolveArgs args) { return this.ResolveItem(args, false); } } This loads and instantiates well, and hits every non-directory while scanning the library as intended. However, at the end of the scan, it throws the following exception: Quote System.Collections.Generic.KeyNotFoundException: System.Collections.Generic.KeyNotFoundException: The given key 'EmbyGenericItemResolver.GenericItem' was not present in the dictionary. at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Emby.Server.Implementations.Data.SqliteItemRepository.SaveItem(IDatabaseConnection db, BaseItem item, Int64 userDataKeyId, IStatement insertItemStatement, IStatement updateItemStatement) I tried fiddling around with the item but I'm not entirely sure what to do here and was unsuccessful. What do I need to change for the results to be persisted? Is the concept of custom media types currently broken, and do I need to pretend the results are something known to the base application? Edited August 5, 2024 by Protected
Protected 86 Posted August 5, 2024 Author Posted August 5, 2024 Hm, runs successfully if I return Books instead...
Luke 42077 Posted August 6, 2024 Posted August 6, 2024 Hi, this part of the wiki is out of date and custom types are no longer possible.
Protected 86 Posted August 6, 2024 Author Posted August 6, 2024 Yes, I spotted the hardcoded type map in the repository class. This seems like an unnecessary restriction! For now I'm using Books for non-playable types, since I don't plan on having books in this server. Even if you keep hardcoded types only, you could add a generic type for people to use in custom plugins! I was able to make audio playable in home video type libraries by adding a custom copy of the audio resolver without the library type restriction (other things being equal). I'm looking forward to using a similar strategy to make TV shows function on top of the home video type without filename shenanigans. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now