Jump to content

Latest Episode (not user defined and "UnPlayed" doesn't matter)


chef

Recommended Posts

chef

In my plugin I need to get the Latest Episode added to the library for a Series.

 

Weather it's been played by a user or not. (Strange I know...)

 

Is there an easy way, I might be missing,  to get it without using Date Created, with the InternalItemQuery?

 

 

 

Thanks guys, it's holding me up, and I'm confused... again.

Link to comment
Share on other sites

chef

This is what I've just come up with.

Not completely tested yet.

                       logger.Info("TV TITLE " + " Big Bang Theory");

                        var result = libraryManager.GetItemIds(new InternalItemsQuery
                        {
                            Name = " Big Bang Theory",
                            IncludeItemTypes = new[] { "Series" },

                        });

                        if (!result.Any())
                        {
                            logger.Info("Inital search for " + " Big Bang Theory" + " had no results.");
                            logger.Info("Starting result search for closest comparison: " + "Big Bang Theory");
                            result = libraryManager.GetItemIds(new InternalItemsQuery
                            {
                                NameContains = "Big Bang Theory"
                                IncludeItemTypes = new[] { "Series" },

                            });
                        }

                        // Hard coding User Name for now until it works.
                        var episodes = new MediaBrowser.Model.Querying.LatestItemsQuery
                            {
                                UserId = userManager.GetUserByName("Admin").Id,
                                IncludeItemTypes = new [] {"Episodes"},
                                ParentId = result.FirstOrDefault().ToString()
                            };

                        // Client is the IApiClient Interface object
                        var test = Client.GetLatestItems(episodes);
                        
                        var thisShouldBeTheItemIWant = libraryManager.GetItemById(test.Result.FirstOrDefault().Id);
This might work. I haven't used the IApiClient object in a plugin before. Plus it becomes user defined once the Recent items are requested.

Ah....

Edited by chef
Link to comment
Share on other sites

chef

In the first query why do you have the leading space?

Not on purpose. I had cut and pasted the series name throughout the code for testing.

 

It originally had been a variable string which is passed into the function.

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