Jump to content

Reading and Writing to Emby Library Metadata in plugin environment


Recommended Posts

ginjaninja
Posted

Does anyone have a sample project which does any of the following they would be happy to share or point to on github.

  • Reads items from the library (as admin), based on a search filter (like with the rest api itemsservice)
  • Enumerates and filters the results.
  • Amends their metadata
  • Updates the library (as admin) with the changes

 

or perhaps do you know what  methods and dependencies i should be looking at?

 

Im trying to build on plugin development experience, and am struggling to identify which Emby methods i should be using, let alone inject their dependency. (and yes i dont really know what im talking about)

thanks

 

 

Posted

Hi, if Bulky plugin source is open that is probably a good example. if not then try sending a PM to the developer. maybe he'll grant you private access.

ginjaninja
Posted (edited)
async function getCollectionsItemIsIn(item_ids_str, callback) {
    let url = (type) ? "Users/" + currentUserId + "/Items?Fields=MediaStreams,UserData&IncludeItemTypes=BoxSet&Recursive=true&ListItemIds="   + item_ids_str :
                       "Users/" + currentUserId + "/Items?Fields=MediaStreams,UserData&IncludeItemTypes=Playlist&Recursive=true&ListItemIds=" + item_ids_str;
    console.log("=== url = ",url);
    let item_data = await ApiClient.getJSON(ApiClient.getUrl(url));
    callback(item_data);
};

.

All of the 'work' in bulky https://github.com/Cheesegeezer/bulky is done in the javascript js files it seems....

And it seems to use a method? 'Apiclient' that looks like its using the restapi to do the work (getting and posting to the emby rest api endpoints)

i dont seem to be able to do my usual visual studio tricks to work out what 'apiclient' is and where it comes from (maybe cos its in js)

is that apiclient https://dev.emby.media/reference/pluginapi/MediaBrowser.Model.ApiClient.html? would you know?

and if so mediabrowser.model.apiclient doesnt seem to be explained on the reference documentation... is that right?

 

And is using 'apiclient' the intended way to do library metadata reading and writing in the plugin environment in c#, for someone starting a new plugin today?

So many questions, maybe this is beyond me 🙂

 

 

edit ..

ah so if ai can be trusted and i know it always can be 🙂

 

✔️ Summary

  • ApiClient is not defined in Bulky.

  • It is injected automatically by Emby’s dashboard environment.

  • It comes from Emby’s built‑in JS client (emby-apiclient.js).

  • Plugin pages always run after Emby loads these core scripts.

 

so i guess the question remains...is apiclient in js the recommended way to do metadata reading and writing in a plugin.

Edited by ginjaninja
Posted

What are you trying to do?

ginjaninja
Posted

Thanks i am trying to read in baseitems from the library (eg shows and episodes), enumerate and manipulate the properties of items (eg parental rating, customrating,network) and write them back.

Posted

Did you get any further?

ginjaninja
Posted

Thanks for asking, no i was assuming/hoping using the rest api like bulky wasnt the 'optimum' way* and was  hoping someone might be able to point me in the direction of what the building block constructors, interfaces, methods** in the core c# sdk were for "read in baseitems from the library (eg shows and episodes), enumerate and manipulate the properties of items (eg parental rating, customrating,network) and write them back."

I think i can work out from the templates and previous plugins how to add c# config pages and add code to schduled tasks.

*Seeing the new UI method which doesnt rely on html/js to present UI i thought i could avoid having to learn another language and just concentrate on c#.

** 'guessing' on the right terminology.

I am having fun with using copilot in browser and in VS to see how much help it can be...spoiler not very much. Whereas copilot can write fully functional powershell using the rest api in a couple of prompts.

  • Thanks 1

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