Jump to content

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


Recommended Posts

Posted

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.

Posted

What have you tried?

Posted (edited)

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
Posted

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

Posted

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.

Posted

once you have the series object, try calling GetEpisodes()

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