Jump to content

Implementing an IImageProvider for Extras


roaku

Recommended Posts

Let me ask a feasibility question up front in case what I want can't currently be done...

@Luke Is it possible for a plugin to offer an ImageProvider for Movie Extras?

 

I'd like to create an image provider for Movie Extras that utilizes the parent Movie's art as a base but am new to creating Providers.

ILocalImageProvider or IDynamicImageProvider seem like candidates for what I'm trying to do.

I've managed to get the Provider implementation registered as a provider an can get log output when Emby calls the supports method as I open an Extras image modal.

But, I can't seem to figure out how to get Emby to call the GetImage method, so I can actually try to provide an image.

Can anyone provide some insight into how this is supposed to work?

 

Link to comment
Share on other sites

I just had some luck with ILocalImageFileProvider. It appears to fire GetImages() when refreshing metadata.

  • Thanks 1
Link to comment
Share on other sites

Well, I just managed to clone the Primary image from the Extra's owner over as a primary image for the Extra on metadata refresh.

The next, hopefully successful, step is to modify the parent image in fun, interesting, and useful ways before saving it with the Extra.

Link to comment
Share on other sites

Please note that in GetImages() you should not do anything else than return a list of images.

You should not perform any library operations like loading or saving items there. Generally, a metadata provider must not make changes to any other item than the one it's called for.
That means, when you want to make changes to the Extra's owner item, it should be done when the metadata provider is called for that item.

The images you return in an image provider might be merged or overwritten by results from other image providers (depending on the configured order).

For the provider types:

ILocalImageProvider 

For cases where the images exist on disk already

IRemoteImageProvider

When images are retrieved from a remote service

IDynamicImageProvider

When you are building the image in code in some way.
You can return the image as stream and Emby will handle the saving.

 

If you want images to be refreshed based on other conditions than a change to the item itself, you can implement IHasItemChangeMonitor on the provider. 

For maximum control, you can create an ICustomProvider. It's not an image provider and you cannot configure its use in the library options, but you can modify all item properties and it runs after all other providers (and image providers).

  • Thanks 1
Link to comment
Share on other sites

Thanks for the insights @softworkz

Taking your advice, I switched over to IDynamicImageProvider.

It took some banging of head against wall to get the Task/stream pipeline all worked out, but I'm now able to generate derivative images on metadata refresh for an Extra by overlaying its Name and Type onto its parent's image(s):

 

Primary.webp.0b1f2f86b814d35f7d8330a4eb6d1cfb.webp

 

Lots more to do now. :)

Edited by roaku
  • Like 1
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...