Jump to content

C# Impliment a boxset provider?


mickle026

Recommended Posts

mickle026

Im having trouble finding the correct syntax for implimenting a boxset provider interface.  Can anyone help or shed light onto  what I am doing wrong?

I am probably doing it wrong!

If I add the remoteMetadata provider like this

public partial class CustomProvider : IRemoteMetadataProvider<BoxSet, BoxSetInfo>
{

}

Then the VisualStudio adds the rest of the code, like this

    public partial class CustomProvider : IRemoteMetadataProvider<BoxSet, BoxSetInfo>
    {
        public Task<MetadataResult<BoxSet>> GetMetadata(BoxSetInfo info, CancellationToken cancellationToken)
        {
            throw new NotImplementedException();
        }

        public Task<IEnumerable<RemoteSearchResult>> GetSearchResults(BoxSetInfo searchInfo, CancellationToken cancellationToken)
        {
            throw new NotImplementedException();
        }

    }

However compiling this with nothing added throws an error

Quote

Severity    Code    Description    Project    File    Line    Suppression State
Error    CS0311    The type 'MediaBrowser.Controller.Entities.BoxSet' cannot be used as type parameter 'TItemType' in the generic type or method 'IRemoteMetadataProvider<TItemType, TLookupInfoType>'. There is no implicit reference conversion from 'MediaBrowser.Controller.Entities.BoxSet' to 'MediaBrowser.Controller.Providers.IHasLookupInfo<MediaBrowser.Controller.Providers.BoxSetInfo>'

 

I really have no idea what this means other than its not inheriting something that it needs to use the adapter.

 

What I do understand is this is the part Emby uses to find and fill the metadata information when a box set is added

public Task<MetadataResult<BoxSet>> GetMetadata(BoxSetInfo info, CancellationToken cancellationToken)
        {
            throw new NotImplementedException();
        }

 

adn this is the identify or search/lookup part of the code

        public Task<IEnumerable<RemoteSearchResult>> GetSearchResults(BoxSetInfo searchInfo, CancellationToken cancellationToken)
        {
            throw new NotImplementedException();
        }

I also understand how to create a new boxset and add it

var newCollection = new BoxSet
{
     Name = CollectionName,
     Overview = ThisItemsOverview
};

metadataResult.HasMetadata = true;
metadataResult.Item = newCollection;

return metadataResult;

I have added it to the supported providers, so its not missing there

public bool Supports(BaseItem item)
{
	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;
}

 

When I click the popup dialog in the IDE, that takes me to the code below so I can see that is no different other than its boxsets than the others

namespace MediaBrowser.Controller.Providers
{
    public sealed class BoxSetInfo : ItemLookupInfo
    {
        public BoxSetInfo();
    }
}

Just like all the other interfaces, I cannot work out what I am doing wrong, so I am wondering if I am missing a nuget or something for this ?

Link to comment
Share on other sites

mickle026

@Luke What is the actual trigger that makes the boxset provider activate?

Ie, what do need to put in the movie metadata item/or trigger to set to get Emby to check for a boxset?  (it is also enabled in the collections library)

 

I already tried  adding the collection name to the moveinfo

private async Task<MetadataResult<Movie>> GetMovieMetadata(MovieInfo info, CancellationToken cancellationToken)
{
var metadataResult = new MetadataResult<Movie>();
.
.
  Code to Add the movie
  
  Code to Add the Cast members

	metadataResult.Item.AddCollection(CollectionName);
.
.
	return metadataResult;
}
  

Many thanks

Edited by mickle026
Link to comment
Share on other sites

mickle026

That will refresh and trigger it for items that already have a boxset.  I can do that and get images and overview for ones that exist already.

I want to add a new box set in the first place when I add a new movie. ie create the BoxSet and add items to it.  I understand how to do the refresh, its adding a new collection in the first place I cannot seem to fathom.

I have added 3 movies in the same series and added them all to the same collection name with the code below but that doesnt create a visible BoxSet.

metadataResult.Item.AddCollection(AllSameName);

I can create a new boxset, but how does it link to the movie? I assumed I added Children to the parent.  BoxSet being the parent, and the movie baseitems being the children.

BoxSets doesnt seem to work like this, and this doesn't seem to do anything visible either

	metadataResult.HasMetadata = true;
    metadataResult.QueriedById = true;

	BoxSet newSet = new BoxSet
	{
		Name = CollectionName,  // Collection Name is a string
	};
                                                
    newSet.AddChild(MovieID); // Where MovieID is the Movie Baseitem
    metadataResult.Item.AddCollection(newSet); // NewSet is the Box Set with Added MovieItem as Child

Pointers or examples would be cool :), surely im either doing it wrong or still missing something?

 

 

Link to comment
Share on other sites

To create new boxsets then you'd need a movie or series provider that fills them in with the Collections property. Or if the only data you have is collections then you could also do a scheduled task and create them using ICollectionManager.

Link to comment
Share on other sites

mickle026
22 minutes ago, Luke said:

To create new boxsets then you'd need a movie or series provider that fills them in with the Collections property. Or if the only data you have is collections then you could also do a scheduled task and create them using ICollectionManager.

Thats what I am trying to do.

 

 private async Task<MetadataResult<Movie>> GetMovieMetadata(MovieInfo info, CancellationToken cancellationToken)
{
    var metadataResult = new MetadataResult<Movie>();

//Code here
   
     metadataResult.Item = new Movie
     {
      	   OfficialRating = Rating,
	       Name = info.Name,
		   Overview = overview,
           ProductionYear = info.Year,
           SortName = info.Name,
           ExternalId = info.Name
	 };
   
   //Code here
   
   // Add people
   
   PersonInfo person = new PersonInfo
     {
            Name = aName,
           Type = PersonType.Actor, 
      };
   
   // more code that adds other person types
   
   string CollectionName = getCollectionNameIfThereisOne(aName);
   
   metadataResult.Item.AddCollection(CollectionName);
   
   // more code that add other items such as genres etc
   
   
   return metadataResult;
 }
   

Everything is working except for adding collections / Boxsets

My Movies are adding, my Cast members are adding, My Genres are adding, My Year, Release Date, Plot etc is all adding properly.

I cannot for the life of me get Collections/ BoxSets to add.

 

I tried just simply this

metadataResult.Item.AddCollection(CollectionName); // where name is a string

 

and tried creating a boxset item and adding children to it, then adding it like shown in my post above

metadataResult.Item.AddCollection(newSet); // where newSet is a boxSet item with children added.

so I am still doing something wrong??

Link to comment
Share on other sites

Looks OK from a glance. Make sure it's enabled in library options and that the min collection items option is set to 1.

Link to comment
Share on other sites

mickle026

Its enabled and everything else is dissabled, with setting to 1 in both the movie library and the collections library.  They are still not adding

 

With all other fetchers dissabled, its still fetching collections from tmdb though...not sure if you are aware of this..

Link to comment
Share on other sites

  • 2 weeks later...
mickle026
23 hours ago, Luke said:

Did you figure this out?

Not really.

I can add collection names to the movie, etc.

But cannot fathom other than adding new media what triggers the boxset provider interface in the first instance.  Metadata refresh doesnt appear to if they exist as movie items, Scan Library doesnt appear to..

Link to comment
Share on other sites

  • 3 weeks later...
On 6/17/2022 at 2:03 PM, mickle026 said:

Not really.

I can add collection names to the movie, etc.

But cannot fathom other than adding new media what triggers the boxset provider interface in the first instance.  Metadata refresh doesnt appear to if they exist as movie items, Scan Library doesnt appear to..

It would be when the boxset is first created as well as whenever you refresh metadata on the boxset manually.

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...