Jump to content

Registering IDynamicImageProvider impl as a Movie Image Fetcher


roaku
Go to solution Solved by mickle026,

Recommended Posts

Is it possible for a plugin to register an IDynamicImageProvider so that it appears in the Movie Image Fetchers section of a Movie Library's edit screen?

I've dug in pretty deep trying to figure this one out but can't seem to find the magic interface or whatever it might be.

I'd appreciate any clues or links to examples. Thanks.

Link to comment
Share on other sites

GrimReaper
5 minutes ago, roaku said:

I'd appreciate any clues or links to examples. Thanks.

@mickle026 might have a hint or two as he did exactly that with his Custom Provider plugin. 

  • Thanks 1
Link to comment
Share on other sites

  • Solution
mickle026
10 hours ago, GrimReaper said:

@mickle026 might have a hint or two as he did exactly that with his Custom Provider plugin. 

I didn't use IDynamicImageProvider, I used these to give me the interfaces in the library setttings.

IRemoteMetadataProvider<Movie, MovieInfo> 
IRemoteImageProvider, IService

etc for each adapter/interface I built, there is also ILocalImageProvider and ILocalImageFileProvider

 

However I imagine you probably looking for something like this, because you mentioned dynamic

using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;
using System.Threading;
using System.Threading.Tasks;

namespace CustomProvider
{
    public partial class MyImageProvider : IDynamicImageProvider
    {
        private readonly IMediaEncoder _mediaEncoder;
        private readonly IServerConfigurationManager _config;
        private readonly IFileSystem _fileSystem;

        public MyImageProvider(IMediaEncoder mediaEncoder, IServerConfigurationManager config, IFileSystem fileSystem)
        {
            _mediaEncoder = mediaEncoder;
            _config = config;
            _fileSystem = fileSystem;
        }

        public bool Supports(BaseItem item)
        {
          
          // just use whichever you need
            return item is Person || item is MusicArtist || item is MusicAlbum || item is Movie || item is Series || item is Season || item is Episode || item is Audio || item is BoxSet || item is Trailer;
        }

        ImageType[] IDynamicImageProvider.GetSupportedImages(BaseItem item)
        {
            return new[] //whatever you want to support here
            {
                ImageType.Primary,
                ImageType.Backdrop,
                ImageType.Logo,
                ImageType.Banner,
                ImageType.Disc,
                ImageType.Thumb,
                ImageType.Art
            };
        }

        public string Name => "My Dynamic Image Provider";

        public Task<DynamicImageResponse> GetImage(BaseItem item, ImageType type, CancellationToken cancellationToken)
        {
            var imageStreams = new DynamicImageResponse();

            

            return GetImage(item, cancellationToken);

        }

        public async Task<DynamicImageResponse> GetImage(BaseItem item, CancellationToken cancellationToken)
        {

            // Do whatever to find or save images
            // where you result in getting a path

            return new DynamicImageResponse
            {
                Format = MediaBrowser.Model.Drawing.ImageFormat.Jpg,
                IsFallbackImage = true,
                Path = "Your_Path",
                Protocol = MediaBrowser.Model.MediaInfo.MediaProtocol.File,
                // Stream = 

            };

        }

    }
}

I have not used the Dynamic Interface so I dont know if what I put above is correct or if it shows up where you want it, but the magic is the supports and return item type.

I hope it helps put you back on track :)

Edited by mickle026
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

And of course, while checking up on what you shared, I've now come across IDynamicImageProviderWithLibraryOptions, which does exactly what it sounds like. 😅

Link to comment
Share on other sites

The real source of my issue seems to be that I want to act on items that are extras, not movie items directly.

When I return 'item is Movie' in the Supports method for IDynamicImageProvider, it shows up in the Movie library settings. Of course, I'm not actually supporting movies directly with my provider.

Oh well. I do have the configuration working purely through my plugin UI. I just thought it would be cleaner to expose some of it through the Movie Library settings.

Link to comment
Share on other sites

mickle026
11 hours ago, roaku said:

The real source of my issue seems to be that I want to act on items that are extras, not movie items directly.

When I return 'item is Movie' in the Supports method for IDynamicImageProvider, it shows up in the Movie library settings. Of course, I'm not actually supporting movies directly with my provider.

Oh well. I do have the configuration working purely through my plugin UI. I just thought it would be cleaner to expose some of it through the Movie Library settings.

I think you can cast Movie on to Video to get the extras similar to Album onto Audio to get Artists or use ( item is Video || item is Movie ) via BaseItem.DisplayExtraTypes ??

So (if you can cast it like that) in the movie provider you would be able to just work with the extras of whichever movie triggered it,

 

This is not something I have tried, its just an assumption.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...