roaku 797 Posted December 10, 2020 Share Posted December 10, 2020 I'm trying to get a plugin going so I can add small letter icons to my Movie covers to indicate which ones have Commentaries or Isolated Score tracks. Implementing IImageEnhancer seemed like a viable route, so I'm trying to do that. I've got the plugin part working in that it shows up in the plugins page. But I'm not able to get anything to show up in the log when I retrieve a movie image through the API. Not even a NotImplementedException. This is the endpoint I'm hitting for the image: /Items/{ItemId}/Images/Primary?maxHeight=1200&maxWidth=800&quality=90 If anyone has any insights on this, I'd appreciate it. Also, I'm not a C# guy, so feel free to berate me about coding conventions or best practices. using System; using System.Threading.Tasks; using ImageMagick; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; namespace ImageAudioEnhancer { class ImageEnhancer : IImageEnhancer { private readonly ILogger logger; MetadataProviderPriority IImageEnhancer.Priority => MetadataProviderPriority.First; ImageEnhancer (ILogger logger) { this.logger = logger; } Task IImageEnhancer.EnhanceImageAsync(BaseItem item, string inputFile, string outputFile, ImageType imageType, int imageIndex) { return Task.Run(action: () => { WriteImage(item, inputFile, outputFile, imageType, imageIndex); }); } private void WriteImage(BaseItem item, string inputFile, string outputFile, ImageType imageType, int imageIndex) { using (var originalImage = new MagickImage(inputFile)) { //just do something random to see a change in the image originalImage.Charcoal(); originalImage.Write(outputFile); } } string IImageEnhancer.GetConfigurationCacheKey(BaseItem item, ImageType imageType) { //what is expected for this method? Can I just base64 encode some item properties or something? throw new NotImplementedException(); } EnhancedImageInfo IImageEnhancer.GetEnhancedImageInfo(BaseItem item, string inputFile, ImageType imageType, int imageIndex) { return new EnhancedImageInfo { RequiresTransparency = true }; } ImageSize IImageEnhancer.GetEnhancedImageSize(BaseItem item, ImageType imageType, int imageIndex, ImageSize originalImageSize) { return originalImageSize; } bool IImageEnhancer.Supports(BaseItem item, ImageType imageType) { //I'd really like to see some output in the emby log for this logger.Info("************ TEST ENHANCER"); logger.Info("type: "+ item.GetType()); logger.Info("internalid: " + item.InternalId); logger.Info("count: " + item.GetMediaSources(false, false, null).Count); return item.GetType().Equals("Movie") && item.GetMediaSources(false, false, null).Count > 2; } } } Link to comment Share on other sites More sharing options...
roaku 797 Posted December 10, 2020 Author Share Posted December 10, 2020 Feel free to move this to the Plugins forum I forgot was there if it makes more sense. Link to comment Share on other sites More sharing options...
Luke 37166 Posted December 11, 2020 Share Posted December 11, 2020 Hi, I'm not sure this will matter, but try marking your class public. 1 Link to comment Share on other sites More sharing options...
roaku 797 Posted December 11, 2020 Author Share Posted December 11, 2020 (edited) 11 hours ago, Luke said: Hi, I'm not sure this will matter, but try marking your class public. The *constructor* needed to be marked as public. I left it on the class too, so they could both be required. Thanks for steering me in the right direction. Still have more to figure out, but that's a big hurdle cleared now that the class is in the pipeline and I can write to the log. Edited December 11, 2020 by roaku Link to comment Share on other sites More sharing options...
Luke 37166 Posted December 11, 2020 Share Posted December 11, 2020 Thanks for the feedback. Link to comment Share on other sites More sharing options...
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