# Python question

**URL:** <https://forums.plex.tv/t/python-question/869905>\
**Category:** Dev/API Corner\
**Tags:** scanner-agent-dev\
**Created:** [February 20, 2024, 1:03pm UTC](https://forums.plex.tv/t/python-question/869905 "2024-02-20T13:03:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rossinior](https://avatars.discourse-cdn.com/v4/letter/r/5f8ce5/32.png) [@rossinior](https://forums.plex.tv/u/rossinior)\
**Post date:** [February 20, 2024, 1:03pm UTC](https://forums.plex.tv/t/python-question/869905/1 "2024-02-20T13:03:26Z")

</div>

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:

```auto
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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [February 20, 2024, 1:42pm UTC](https://forums.plex.tv/t/python-question/869905/2 "2024-02-20T13:42:59Z")

</div>

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

> <https://github.com/ZeroQI/Lambda.bundle/blob/master/Contents/Code/ __init__.py#L294>

---

<div class="post-metadata">

**Author:** ![rossinior](https://avatars.discourse-cdn.com/v4/letter/r/5f8ce5/32.png) [@rossinior](https://forums.plex.tv/u/rossinior)\
**Post date:** [February 20, 2024, 8:00pm UTC](https://forums.plex.tv/t/python-question/869905/3 "2024-02-20T20:00:02Z")

</div>

> [@dane22](#):
>
> Been too long ago, but when said, take a peak at another 3rd. Party bundle

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

> [@dane22](#):
>
> ```auto
> #metadata = media.primary_metadata #full metadata object from here with all data, whereas in Update() metadata will be empty...
>           
> 
> ```

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?

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [February 20, 2024, 8:32pm UTC](https://forums.plex.tv/t/python-question/869905/4 "2024-02-20T20:32:25Z")

</div>

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!
