Agent Metadata Confusion and questions

Hi All

I am starting to put together an agent partially for my own python learning and mainly to give something back to the plex community.

I am having some confusion over the update method and the metadata object that is passed to it.

According to the 2.1.1 docs this object should contain existing data that is attributed to the item or a new empty object if this is the first access.

Ok so Scenario is

  1. My agent is Primary (Movies) with local media as the only secondary provider
  2. Agent order is local media first, my agent second in the agent settings screen
  3. Local media agent populates the metadata section for an item (Reading the github source for videohelper) from the tags if any.
  4. Metadata from local media agent then passed to my agent should then contain the contributed data from local media as described in the docs
  5. Metadata provided to my agent is completely empty (was expecting data from localmedia agent including title, roles, etc)
  6. I have found that if I set metadata items in my agent they do persist but are only visible if the primary agent is the first in the agent order list. This is aside from 5. and just an observation that the data set in an agent is ONLY available to that agent. which is in conflict with the docs.

So my question is how does the primary agent vet the additional metadata provided by all the agents it accepts data from?
ie if a particular piece of data is deemed unnecessary or needs to be altered by the primary agent and is updated this should then be saved as the primary agent specifes shouldnt it?.
Is this a bug?

Additionally some data set by the local media agent does not exist to edit in the web interface.
Example
When adding a movie (mp4) if the arttist tag is set, the artists get added to the roles attrib of the metadata object (this is undocumented and I only found it by reading the source)
This is then shown on the items details page as “Cast”
There is no details in any of the edit tabs for the “Cast” or roles.

Is current documentation for the Plex agent and associated API available (post 2.1.1)?
The 2.1.1 Docs are incomplete and dont match the source for what metadata objects are available on github so is there any newer versions out there?

Please let me know if this needs more clarification?

Any help or pointers or “yes this is a bug” greatly appreciated

Thanks

I did a table of all field in a metadata.txt file at the root of my agent code on github, link in my signature. In releawe i have a blank agent template also if it helps…
If the main agent doesn’t update the serie title nothing is saved, check blank agent template source for confirmation.
The primary agent choose the id.
Secondary agent reuse the id and add or update metadata

@ZeroQI

Thanks for that and your doc is a great reference but it shows the same content as the plex 2.1.1 docs ie there is no “roles” in your doc.
see here for what I was saying about the “roles” attribute missing.
Search for “cast” or “roles” to see what I mean.

You noted that the data is only shown if the main agent saves it.
My question was that the data from the additional agent is already added / saved to the item but is NOT passed to the main agent so it does not know what it has to save /change.
I am using force refresh on a small library for testing. I am also doing the “plex dance” regularly with the same results
Should I put a small test project on bitbucket so we can nut this out?

I am testing this in PMS 1.1.3 ATM on OS X . I would like to try a previous 1.x version but cannot seem to find any archives of previous releases ;(

Thanks for your help

Your main agent need to modify the series title at least or it won’t save anything.
Start from the template below if you have nothing to get a head start
https://github.com/ZeroQI/Hama.bundle/releases/download/v1.0/Empty_Agent_template.bundle.7z

Have a look at PlexThemeMusic.bundle [github.com/plexinc-agents/PlexThemeMusic.bundle/blob/master/Contents/Code/init.py]
It contributes to: ‘com.plexapp.agents.thetvdb’, ‘com.plexapp.agents.themoviedb’
it basically run as second agent and just update the theme for example…
it still need to check the primary agent is supported and use tvdbid as metadata.id.

You need to give the source, because explanations without code is just confusing at least for me.

Don’t know bit-bucket but know github. I would use github as it allows unsupported appstore support for your agent afterwards… Also plex agents are on github…