Jump to content

List<PersonInfo> getting (internal server) id of person


ginjaninja

Recommended Posts

ginjaninja

I am finding

seriespeople = LibraryManager.GetItemPeople(baseitem);

does not yield .Id on the members of the list (they are all 0)

but

var seriesquery = new InternalPeopleQuery
                {
                    
                    ItemIds = new[] { item.InternalId },
                    EnableIds = true,
                };

seriespeople = LibraryManager.GetItemPeople(seriesquery);

does  yield .Id on the members of the list

is that intentional? as a point of learning is there a structure in namespace MediaBrowser.Controller.Library that should clue me into this (i am new to c#)

thanks for any advice.

image.png.0905c2188e698ea18000d947fdfe16c8.png

Link to comment
Share on other sites

mickle026

I'll explain how I do it, it can probably be done easier, but this works.

 

Not sure but when you do the 1st query you get an Array of PersonTypes which have to be re-read an the InternalId is inside each element

var People = libraryManager.GetInternalItemIds(new InternalItemsQuery
{
      IncludeItemTypes = new[] { "Person" }
});


foreach (var xPerson in People)
{

      var ActorInfo = libraryManager.GetItemById(xPerson);
      var ActorInternalId = ActorInfo.Id;

}

So

var seriespeople = LibraryManager.GetItemPeople(baseitem);

Returns an Array so the for loop below for the example above would iterate over each entry and pull out th Internal Id's

foreach (var xPerson in SeriesPeople)
{
      var ActorInfo = libraryManager.GetItemById(xPerson);
      var ActorInternalId = ActorInfo.Id;
}

If you want series people only this example would get the all Series in the library first then get the people in each series only, then process whatever you wanted to do

var xSeries = libraryManager.GetInternalItemIds(new InternalItemsQuery
            {
                IncludeItemTypes = new[] { "Series", "Episode" }
            });

foreach (var eachShow in xSeries)
{
  var Actorlist = libraryManager.GetInternalItemIds(new InternalItemsQuery
  {
      AppearsInItemIds = new[] { eachShow }
  });
  foreach (var xPerson in Actorlist)
  {
      var ActorName = libraryManager.GetItemById(xPerson).Name;
      var ActorID = libraryManager.GetItemById(xPerson);
      var ImagePath = ActorID.PrimaryImagePath;
    
    // more code
    
  }
  
 
  
}

So the above will get all series and Episodes (because episodes often contain extra people than the series level only)
 

Then for each series (one by one) get the cast (people)

The you get the items you need.  Here ActorID provides all the info
Type ActorID then after you type the dot "." - the options will show in visual studio editor popup

All you have to remember is that you have an array of Person Types, so each Person type you have to query library manager again for the Id.

So for each PersonType in the SeriesPeople, iterate and get each PersonInfo Id, then get the InternalId.

foreach (var xPerson in SeriesPeople)
{
      var ActorInfo = libraryManager.GetItemById(xPerson);
      var ActorInternalId = ActorInfo.Id;
}

I would query the actual series and Episode of the BaseItem rather than the people, then query the people of that otherwise you probably wont get all the people that are in episode level but only those shown at series level as Series and Episodes are treated differently.

 

I hope there is something here that helps and doesn't confuse ......

  • Like 2
Link to comment
Share on other sites

Cheesegeezer

This sounds like a short coming (bug) in the query to get the PersonInfo. Surely the Id should be populated, all other fields are populated in class.

 

Link to comment
Share on other sites

ginjaninja
1 hour ago, Cheesegeezer said:

This sounds like a short coming (bug) in the query to get the PersonInfo. Surely the Id should be populated, all other fields are populated in class.

 

On my 3rd day of c# it probably a bit rich for me to call "bug" (Even if i have had an excellent mentor ;-)); but its seems odd to me too. These are the package versions im using.

image.png.edbd9c71d8dc97b0c4e781999aafd6a7.png

Edited by ginjaninja
Link to comment
Share on other sites

Cheesegeezer

I have also noticed that the other fields are not populated.  

The below is output to the log and using the PersonInfo Class

Which has the following properties available.

image.png.3f2e7b01e388237255576cc6e635142a.png

Guy Bee with RoleType: Director & Id = 0 & ItemId = 431 
 ImageUrl =  
 Guid = 00000000-0000-0000-0000-000000000000

 

@mickle026  has shown some great work arounds but there is alot of double handling and i know you have done amazing with your Anime Persons plugin so thanks so much for your help with this.

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