Problems writing an independent contributing agent

I’ve been implementing a meta data agent for the DVD Profiler movie collection manager and managed to get it working very nicely as a standalone primary agent. However it would be even better if I could combine the meta data with other existing sources. Especially what are lacking in the DVD Profiler data are the fanarts/backdrops.



I thought that the “contributes to”/“accepts from” mechanism would be perfect for the job. But I discovered two major problems:



1. The search method of a contributing (non-primary) agent is NOT called if the primary agent fails to find a match

In my case I have a collection of ~1000 movies of which about half are children’s movies with localised title names. So the IMDB/Freebase agent does not find a match for these and thus my contributing agent’s search method is never called. Since I have all my movies in the DVD Profiler database, a match would always be found.



It seems that the mechanism has been written with an assumption that the contributing agents are dependent on the primary agent’s matching. Taking a look on the Freebase agent chain, you can easily see that the contributing agents (eg. TheMovieDB) use the IMDB ID to derive their own search ID. Nothing wrong with this but it would even better if the contributing agents could make their own shot on getting a match.



I know that there is the fallback_agent attribute which can be set in case the agent is unable to find a match. But this is now hardcoded in the agent’s source code and should at least be made configurable in similar way to the agent chain itself.



So what if I made my agent the primary one? Well, this fails because all the existing contributing agents assume that the primary metadata id is an IMDB id. And the IMDB/Freebase cannot be used as the first contributing, non-primary, agent due to problem number 2 (see below).



2. Media object is not populated in contributing agents search method

When the search method of a contributing agent is called the media object does not contain media information like the filename of the media (media.items[0].parts[0].file). This seems like a bug to me since the media information is provided correctly in the update method. This problem effectively prevents using primary agents as contributing ones.



It would be perfect if three changes could be made to contributing agent framework:

  1. Call search functions of contributing agents also when there is no match with the primary agent
  2. Provide correctly populated media object to contributing agent’s search method
  3. Add fallback_agent as a configuration item for an agent. This is optional in case number 1 cannot be implemented.

I tried to work around the problem by using the fallback_agent mechanism. But I hit a brick wall quite soon; first off the search method of the defined search agent is called but the whole process jams after that. None of the update methods are called and the movie loses somehow even it’s original frame capture poster. Since there is basicly no description or implementations of the fallback_agent concept there seems to be no way of solving this without devs stepping in.



The second hit on the brick wall is the fact that the Plex seems to have some kind of self check on file integrity (or it’s some kind of autoupdate based on file checksums) and replaces the modified imdb script file after some time (the fallback_agent has to be defined in the imdb agents code).



Found these threads/issue reports related to this issue:

http://forums.plexapp.com/index.php/topic/33121-fallback-agent-not-working/

https://plexapp.lighthouseapp.com/projects/14382/tickets/1070-scanner-metadata-agent-bug

Just realised that there is also a totally different way to solve my use case. I’m mainly looking for meta data which enhances my existing DVD Profiler provided meta data. So using my agent as the primary one and the others as contributing (non-primary) ones would seem to be the logical way. But the problem was that my agent did not have the IMDB id available which the other agents need. I did some digging and there is existing functionality in DVD Profiler for storing links to other sites (including IMDB) called My Links. And this data is included in the XML export. IMDB id itself cannot be directly stored as is but a web link is almost the same since the id can be easily parsed. Once I have the IMDB id available I can set it as the id for the primary-metadata and I assume the non-primary agents start to work.



So now I have something like 1000 movies to add an IMDB-link within DVD Profiler to make this work… The only downside of this approach is that the IMDB/Freebase agent itself cannot be used. Still the original request/question remains regarding the whole contribution chain logic.

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