rechigo 293 Posted June 4, 2020 Share Posted June 4, 2020 I am working on my application and I need to be able to get the containing library of an item via the HTTP API I could go through every single library and check all items in said libraries against the item ID to get the containing library, but that has its own issues @@chef Link to comment Share on other sites More sharing options...
PenkethBoy 2063 Posted June 4, 2020 Share Posted June 4, 2020 dont think there is a single/simple way to do this and may vary by item type but if you pull back the path and/or parentid via API fields property Then for a movie the parent id will be the movie folder - then another call to get the parent of the folder's parentid - etc till you hit the parentid that matches the ID of the library - the number of times you need to do that depends on how nested your movie structure is similar for an episode basically walk back up the parentid tree till you match a library id or you could use the item path and "match" this against the library path - which might have more than one path if multiple folders added to library or if you only have single library types - i.e. only one tv library, one movie library - then item type would be enough to tell Those are a few thoughts of the top of my head - might be another way - but should give you a few options to try Link to comment Share on other sites More sharing options...
chef 3745 Posted June 4, 2020 Share Posted June 4, 2020 Doesn't the type give you the library? Sort of... Link to comment Share on other sites More sharing options...
Luke 37056 Posted June 5, 2020 Share Posted June 5, 2020 try ILibraryManager.GetCollectionFolders(item); Link to comment Share on other sites More sharing options...
Solution PenkethBoy 2063 Posted June 5, 2020 Solution Share Posted June 5, 2020 ah ../item/{id}/Ancestors gets all parents of an item 1 Link to comment Share on other sites More sharing options...
PenkethBoy 2063 Posted June 5, 2020 Share Posted June 5, 2020 Doesn't the type give you the library? Sort of... only if you only have one library per item type Link to comment Share on other sites More sharing options...
rechigo 293 Posted June 5, 2020 Author Share Posted June 5, 2020 (edited) Yeah, the Parent ID move up the tree method was the only thing I had in mind at the time of writing the original post, was hoping there was an easier way.. Couldn't use the second one because the only way to get the library media path would be to use the VirtualFolders endpoint, which is only available to admins (I'm restricted to endpoints that regular users can access) 3rd one wouldn't work because I can't guarantee other users wouldn't have multiple libraries of the same type basically, for each physical library returned by the /Views endpoint, I have to reach out to /Items, select the first item, take the parent ID and continue moving up the tree until I get to the top level. I'll probably cache this since it'll be extremely inefficient to do this every single time Luke- Via HTTP request not from a Plugin @@PenkethBoy THANK YOU! Now I used that endpoint and all I had to do was get the Parent item that is second from the bottom which is the library item Saved me a lot of time by not having to write out a system to go up the tree to find the top parent Edited June 5, 2020 by rechigo 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now