# Writing a Metadata Agent

**URL:** <https://forums.plex.tv/t/writing-a-metadata-agent/18924>\
**Category:** Dev/API Corner\
**Tags:** scanner-agent-dev\
**Created:** [July 2, 2012, 9:10pm UTC](https://forums.plex.tv/t/writing-a-metadata-agent/18924 "2012-07-02T21:10:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrPhil](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@MrPhil](https://forums.plex.tv/u/MrPhil)\
**Post date:** [July 2, 2012, 9:10pm UTC](https://forums.plex.tv/t/writing-a-metadata-agent/18924/1 "2012-07-02T21:10:06Z")

</div>

Is this possible or even a good idea?
After hitting a zero with finding something that allows the UK Content Ratings to be extracted instead of the US ones, I wonder if a new plug-in could be written?  
  
The thought is not to duplicate any of the other agents, but simply have an Agent called, say, UK\_Content\_Ratings, which had one job to do and that would be take the movie returned by another Agent and look up the UK Rating from the web, replacing what was returned by the previous agent.  
  
Not knowing Plug-ins, is this a reasonable approach (and an easy one to write) and if so, has anyone done anything similar to this or can offer any getting started pointers?  
  
Thanks  
  
Phil

---

<div class="post-metadata">

**Author:** ![elan](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/elan/32/5_2.png) [@elan](https://forums.plex.tv/u/elan)\
**Post date:** [July 5, 2012, 10:09am UTC](https://forums.plex.tv/t/writing-a-metadata-agent/18924/2 "2012-07-05T10:09:04Z")

</div>

This is actually a fully legitimate use of an agent. They are allowed to provide just a single field, and as long as it’s the highest priority, that field will “win” when the metadata is combined.

---

<div class="post-metadata">

**Author:** ![MrPhil](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@MrPhil](https://forums.plex.tv/u/MrPhil)\
**Post date:** [July 5, 2012, 5:38pm UTC](https://forums.plex.tv/t/writing-a-metadata-agent/18924/3 "2012-07-05T17:38:44Z")

</div>

Does anyone have an example code to get me going with writing an agent - or is there some resources on the wiki on writing agents (as opposed to writing channels)?  
  
  
  
Thanks  
  
  
  
Phil

---

<div class="post-metadata">

**Author:** ![zhenya](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/zhenya/32/2025_2.png) [@zhenya](https://forums.plex.tv/u/zhenya)\
**Post date:** [July 13, 2012, 6:57am UTC](https://forums.plex.tv/t/writing-a-metadata-agent/18924/4 "2012-07-13T06:57:14Z")

</div>

> [@](#):
>
> Does anyone have an example code to get me going with writing an agent - or is there some resources on the wiki on writing agents (as opposed to writing channels)?  
>   
> Thanks  
>   
> Phil

  
  
Take a look at the default metadata plug-ins. If you are on Mac, they may be in ~/Library/Application Resources/Plex Media Server/Plug-ins. I guess, MoviePosterDB.bundle could be a good example since it provides only two fields (poster and background art) to results found by another plugin (IMDB.plugin). Look through unsupported plugins, you may find other useful examples there: http://wiki.plexapp.com/index.php/Unsupported\_plugins  
  
Also, check for more info on the Plex dev center: http://dev.plexapp.com/  
  
Good luck.

---

<div class="post-metadata">

**Author:** ![jmjf](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jmjf](https://forums.plex.tv/u/jmjf)\
**Post date:** [August 27, 2012, 3:56am UTC](https://forums.plex.tv/t/writing-a-metadata-agent/18924/5 "2012-08-27T03:56:36Z")

</div>

> [@](#):
>
> Does anyone have an example code to get me going with writing an agent - or is there some resources on the wiki on writing agents (as opposed to writing channels)?  
>   
> Thanks  
>   
> Phil

  
  
Phil,  
  
What movie agent do you use by default? You'll probably want to start with that agent and find where it retrieves the content rating. For example, the IMDB agent retrieves a metadata element called content\_rating (though it's using Freebase, not IMDB, I think). You'll then need to find API documentation for the agent's metadata source and determine the name of the UK rating element (if any) and retrieve it. UK ratings exist for \*\*some\*\* but not all movies, so you'd probably want to write code for fallbacks if the UK rating is not available.  
  
Hope that helps. Good luck.  
  
UPDATE: This thread might help: http://forums.plexapp.com/index.php/topic/23875-uk-film-ratings-pg-12-15-etc/

---

<div class="post-metadata">

**Author:** ![MrPhil](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@MrPhil](https://forums.plex.tv/u/MrPhil)\
**Post date:** [September 16, 2012, 9:50am UTC](https://forums.plex.tv/t/writing-a-metadata-agent/18924/6 "2012-09-16T09:50:52Z")

</div>

Thanks for that - will have a look when I get some time (been too too busy recently to get time to reverse engineer this).

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 20, 2019, 10:02pm UTC](https://forums.plex.tv/t/writing-a-metadata-agent/18924/7 "2019-12-20T22:02:35Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
