chef 3744 Posted January 24, 2019 Share Posted January 24, 2019 (edited) I can't believe I'm asking this... I should know this already but stumped.... I'm finding it hard to find how to get a list top tier library names and Ids. ex. "Movies" "TV Series", "Collections" etc. I can see it in the LibraryService in the Swagger, but unsure what to request in the core plugin module. I think it is ILibraryManager, but then I'm stuck. Edited January 24, 2019 by chef Link to comment Share on other sites More sharing options...
chef 3744 Posted January 24, 2019 Author Share Posted January 24, 2019 (edited) Might be GetVirtualFolders EDIT: Yep! something like this... geesh! public string GetMovieLibraryId() { var results = LibraryManager.GetVirtualFolders(); foreach(var item in results) { if(item.Name == "Movies") { return item.ItemId; } } return string.Empty; } Edited January 24, 2019 by chef Link to comment Share on other sites More sharing options...
pünktchen 1241 Posted February 8, 2019 Share Posted February 8, 2019 Any idea how to get those library names as a checkbox list within a plugin configuration page and then return their ids as a string list to the plugin? Link to comment Share on other sites More sharing options...
Luke 36887 Posted February 9, 2019 Share Posted February 9, 2019 Doesn't the trakt plugin config screen have something similar? Link to comment Share on other sites More sharing options...
pünktchen 1241 Posted February 10, 2019 Share Posted February 10, 2019 Doesn't the trakt plugin config screen have something similar? Thanks! Not exactly what i've asked but a good starting point. Link to comment Share on other sites More sharing options...
bakes82 86 Posted March 25, 2022 Share Posted March 25, 2022 @pünktchen Do you have example of this on github some place? I need show a list of libraries on the config page too, and dont want to reinvent the wheel. Link to comment Share on other sites More sharing options...
pünktchen 1241 Posted March 25, 2022 Share Posted March 25, 2022 No, not publicy visible. I'll paste some code here later. Link to comment Share on other sites More sharing options...
roaku 791 Posted March 25, 2022 Share Posted March 25, 2022 49 minutes ago, bakes82 said: @pünktchen Do you have example of this on github some place? I need show a list of libraries on the config page too, and dont want to reinvent the wheel. Not sure how close it is to what you're looking for, but here's how I generate the library dropdown in Iconic: define( async function () { return { displayLibrarySelector: async function(librarySelectorElement) { const libraries = await getLibraries(); let availableLibraries = []; Object.keys(libraries.Items).forEach(function(key) { let library = libraries.Items[key]; if (library.CollectionType == 'movies' || library.CollectionType == 'boxsets'|| library.CollectionType == 'tvshows') { availableLibraries.push(library); } }); let librarySelectHtml = '<select id="librarySelector" class="library-selector" name="librarySelector" label="Select a Library" is="emby-select">'; availableLibraries.forEach(function (library) { librarySelectHtml += '<option data-type="'+library.CollectionType+'" value="'+library.Id+'">'+library.Name+'</option>'; }); librarySelectHtml += '</select>'; librarySelectorElement.innerHTML = librarySelectHtml; } } async function getLibraries() { return ApiClient.getVirtualFolders(); }; }); This is loaded as a separate module by my main javascript file, but you can skip that and just grab the guts if they fit your needs. 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