# Need help with metadata agent development

**URL:** <https://forums.plex.tv/t/need-help-with-metadata-agent-development/619057>\
**Category:** Dev/API Corner\
**Tags:** scanner-agent-dev\
**Created:** [July 31, 2020, 1:20pm UTC](https://forums.plex.tv/t/need-help-with-metadata-agent-development/619057 "2020-07-31T13:20:36Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ReenigneArcher](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/reenignearcher/32/276300_2.png) [@ReenigneArcher](https://forums.plex.tv/u/ReenigneArcher)\
**Post date:** [July 31, 2020, 1:20pm UTC](https://forums.plex.tv/t/need-help-with-metadata-agent-development/619057/1 "2020-07-31T13:20:36Z")

</div>

I’m writing my first metadata agent. It’s a conversion from a javascript code I have that writes an xml file.

So I have the code in python to collect information from a url such as:

- Title
- Description/Summary
- Rating (MPAA)
- Rating (Critic)
- Poster url
- Fanart url
- Duration
- Director
- Studio
- Collection

Arrays:

- Genre
- Actor name
- Actor image url
- Actor role

So here are my initial questions.

1. What information is passed to the python script from Plex when refreshing metadata? I’m hoping the path of the video file as I would like to parse the path for some info. I need the FolderName and VideoKey to build the url to scrape from.

L:\Movies\FolderName\My Video (VideoKey) - Resolution.ext

1. Do I need my own scanner agent or can I use a built in one, assuming I name the files like above?

2. Once I have the data; how do I pass it back to Plex? Do I have to write the xml myself or just set a variable that Plex with intercept automatically?

Something like this is what I imagine, but not sure.

plex\_title = scraped\_title

1. Is there any documentation on developing metadata agents?

---

<div class="post-metadata">

**Author:** ![ReenigneArcher](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/reenignearcher/32/276300_2.png) [@ReenigneArcher](https://forums.plex.tv/u/ReenigneArcher)\
**Post date:** [August 30, 2020, 12:06am UTC](https://forums.plex.tv/t/need-help-with-metadata-agent-development/619057/2 "2020-08-30T00:06:34Z")

</div>

Got most of this figured out. Some new questions though.

Is it possible to use custom images for these? I’m able to populate them with a URL; however it doesn’t change what is displayed. Only the default star is shown (at least on Android clients).

metadata.reviews.image  
metadata.audience\_rating\_image  
metadata.rating\_image

Also if I have the url of a video to use as a trailer, how would I add that?

---

<div class="post-metadata">

**Author:** ![JP.HUDSON](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@JP.HUDSON](https://forums.plex.tv/u/JP.HUDSON)\
**Post date:** [December 26, 2020, 5:03pm UTC](https://forums.plex.tv/t/need-help-with-metadata-agent-development/619057/3 "2020-12-26T17:03:10Z")

</div>

Did you get any information in regards to these rating images?  
Kind Regards

---

<div class="post-metadata">

**Author:** ![ReenigneArcher](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/reenignearcher/32/276300_2.png) [@ReenigneArcher](https://forums.plex.tv/u/ReenigneArcher)\
**Post date:** [December 26, 2020, 5:27pm UTC](https://forums.plex.tv/t/need-help-with-metadata-agent-development/619057/4 "2020-12-26T17:27:59Z")

</div>

No, that was the one thing I couldn’t figure out.

---

<div class="post-metadata">

**Author:** ![JP.HUDSON](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@JP.HUDSON](https://forums.plex.tv/u/JP.HUDSON)\
**Post date:** [August 1, 2022, 1:27am UTC](https://forums.plex.tv/t/need-help-with-metadata-agent-development/619057/5 "2022-08-01T01:27:04Z")

</div>

Currently, I am trying to figure how to put custom pictures in collections… as collections show up as a mashup of film posters… Any idea???

---

<div class="post-metadata">

**Author:** ![ReenigneArcher](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/reenignearcher/32/276300_2.png) [@ReenigneArcher](https://forums.plex.tv/u/ReenigneArcher)\
**Post date:** [August 1, 2022, 2:37am UTC](https://forums.plex.tv/t/need-help-with-metadata-agent-development/619057/6 "2022-08-01T02:37:03Z")

</div>

As far as I know you can’t update collection posters with a metadata agent. I think you can use [python-plexapi](https://python-plexapi.readthedocs.io/en/latest/modules/collection.html) though.

It’s not super easy to integrate python-plexapi into a metadata agent, due to Plex still being on Python 2.7. Even though the differences are minimal to have it work in 2.7, the maintainers are not interested in keeping compatibility. I have a python 2.7 version, [here](https://github.com/ReenigneArcher/python-plexapi), but I don’t know how long I plan on maintaining it.

---

<div class="post-metadata">

**Author:** ![JP.HUDSON](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@JP.HUDSON](https://forums.plex.tv/u/JP.HUDSON)\
**Post date:** [August 1, 2022, 1:29pm UTC](https://forums.plex.tv/t/need-help-with-metadata-agent-development/619057/7 "2022-08-01T13:29:58Z")

</div>

Many thanks for helping out. I really appreciate it.  
Do you have any idea, where the information for collections is stored.  
I can see that one can vie the XML files for a film.  
Is this info stored on disk?

---

<div class="post-metadata">

**Author:** ![ReenigneArcher](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/reenignearcher/32/276300_2.png) [@ReenigneArcher](https://forums.plex.tv/u/ReenigneArcher)\
**Post date:** [August 1, 2022, 2:59pm UTC](https://forums.plex.tv/t/need-help-with-metadata-agent-development/619057/8 "2022-08-01T14:59:09Z")

</div>

The entire database is stored in the sql database file.

---

<div class="post-metadata">

**Author:** ![JP.HUDSON](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@JP.HUDSON](https://forums.plex.tv/u/JP.HUDSON)\
**Post date:** [August 2, 2022, 1:39am UTC](https://forums.plex.tv/t/need-help-with-metadata-agent-development/619057/9 "2022-08-02T01:39:26Z")

</div>

I looked through the sql file andcould see no traces of the collections…

---

<div class="post-metadata">

**Author:** ![ReenigneArcher](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/reenignearcher/32/276300_2.png) [@ReenigneArcher](https://forums.plex.tv/u/ReenigneArcher)\
**Post date:** [September 7, 2022, 3:55am UTC](https://forums.plex.tv/t/need-help-with-metadata-agent-development/619057/10 "2022-09-07T03:55:50Z")

</div>

So, this was my final attempt at having custom rating images.

```nohighlight
if metadata.audience_rating >= 5.0:
    rating_image = 'rating_up.png'
else:
    rating_image = 'rating_down.png'
metadata.audience_rating_image = Resource.ExternalPath(rating_image) # can also use `R` instead of `Resource.ExternalPath`

```

The image is exposed at: `https://<plex_server>:32400/:/plugins/<plugin_identifier>/resources/rating_up.png?t=<timestamp>&X-Plex-Token=<plex_token>`

or shorter version without timestamp: `https://<plex_server>:32400/:/plugins/<plugin_identifier>/resources/rating_up.png?X-Plex-Token=<plex_token>`

It still doesn’t show in the clients. I’m guessing the rating images are hard coded into the clients instead of them downloading them from the server. The web client has SVG images here and doesn’t appear to load these resources from the web server at all.

Since Plex simply doesn’t care about plugins or third party development anymore, this is unlikely to ever get fixed up.

---

<div class="post-metadata">

**Author:** ![ReenigneArcher](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/reenignearcher/32/276300_2.png) [@ReenigneArcher](https://forums.plex.tv/u/ReenigneArcher)\
**Post date:** [September 7, 2022, 3:57am UTC](https://forums.plex.tv/t/need-help-with-metadata-agent-development/619057/11 "2022-09-07T03:57:49Z")

</div>

> [@ReenigneArcher](#):
>
> Also if I have the url of a video to use as a trailer, how would I add that?

I also now have a working YouTube URL service. I will publish the code soon so other plugins can utilize it.

---

<div class="post-metadata">

**Author:** ![TscReiji](https://avatars.discourse-cdn.com/v4/letter/t/c0e974/32.png) [@TscReiji](https://forums.plex.tv/u/TscReiji)\
**Post date:** [November 26, 2022, 3:47pm UTC](https://forums.plex.tv/t/need-help-with-metadata-agent-development/619057/12 "2022-11-26T15:47:42Z")

</div>

metadata.reviews.image can only accept 2 enum string: ‘fresh’, ‘rotten’.  
I just test on my server with the value ‘fresh’, and the tomato logo just apear.

As for documentation, there is only a outdated one released in 2011.  
Yeah, 11 years ago.
