Python question

Hey guys,

sorry to bother you. I know that I am a little late to the party, but since no official way is known to add custom metadata to Plex movie objects in Libraries is known (other than local metadata) programmatically, I am still bound / stuck to the legacy Plex agents.

With the “legacy” way of adding metadata, you have agents and scanners… and possibly supporting metadata scrapers, too.

In python, a supporting scraper could be defined by using the following code:

class MyAgent(Agent.Movies):
  name = 'MyAgent'
  languages = ['en']
  primary_provider = False
  contributes_to = ['com.plexapp.agents.imdb']
  ...

The primary_provider and the contributes_to statements would define, that the classic IMDB agent was used with MyAgent potentially adding metadata to this.

The special thing here: If the supporting agent did not add a certain metadata (let’s say the title of a movie), then the metadata from the IMDB agent was used.

The same is true - for example - for trailers and other extras.

My question is:

Is there a working way of accessing metadata provided by the “main” agent from within the supporting agent?

I found the following code in another 3rd party agent, but it did not work in mine:

def update(self, metadata, media, lang):
	freebase_metadata = metadata.contribution('com.plexapp.agents.imdb')

I want to check all given extras of a movie and only keep those if the spoken language is the library language.

I though I could access the metadata.extras … but it seems to be empty (even if extras were found).

How can I read-access extras found by another agent from Python?

Been too long ago, but when said, take a peak at another 3rd. Party bundle

1 Like

Thank you, @dane22
I am not fully understanding how this all works.

This is not active code, but it says that the metadata in Update() is empty.

How exactly do I get to access the extras of a movie inside an update(…) function of MyAgent?

In the code, there is two objects passed, namely the metadata and the media objects

In an update, the first will be empty, so you need to look in the media object for the key, and then ask PMS itself, which is what the code I showed you does.

When said, I really would not put that much work into it, since it’s unsupported, and will go away some day!

1 Like