If you have not already, we suggest setting your Plex username to something else rather than email which is displayed on your posts in forum. You can change the username at https://app.plex.tv/desktop#!/account
Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

Update function not called after search

mcmuttonsmcmuttons Posts: 5Members, Plex Pass
I've done some searching in the forums, but haven't been able to find anything that addressed this directly. Perhaps my search fu is weak.

I'm trying to build a custom metadata agent and to start I'm just trying to log some of the values to get an understanding of the object structures.

So I've made a simple search that always returns a matching result with a score 100, and an update that just logs a little data. However, while search is called when I refresh, update isn't. I see that my bundle is initialized, and since the search function is producing log output, I'm guessing the plumbing to get to my code is correctly in place.

Is there some special criteria that is needed to trigger a call to update? From the logs, I don't think anything is broken, but I don't know the messages well enough to be sure.

I'll put the code below for reference. If anyone has anything enlightening here (sure it's just a noob mistake), that would be awesome.

class LFAgent(Agent.TV_Shows):
	name = 'Local Files Agent'
	languages = [Locale.Language.NoLanguage]
	primary_provider = True

	def search(self, results, media, lang, manual):
		Log('booyah search')
		results.Append(MetadataSearchResult(id = 'null', score = 100))

	def update(self, metadata, media, lang, force):
		Log('booyah update')
		Log('title: %s', media.title)

Comments

  • sander1sander1 Channel Developer/Admin Posts: 3,724Members, Plex Pass, Plex Ninja Plex Ninja
    Hi!
    I think the update method is called only when adding new items to your library or when doing a Force Refresh or a Fix Incorrect Match. When writing/debugging/testing Agents, I usually use the "Fix Incorrect Match" (selecting the same/correct title works) to test the Agent's update method.

  • mcmuttonsmcmuttons Posts: 5Members, Plex Pass
    sander1 wrote:

    Hi!
    I think the update method is called only when adding new items to your library or when doing a Force Refresh or a Fix Incorrect Match. When writing/debugging/testing Agents, I usually use the "Fix Incorrect Match" (selecting the same/correct title works) to test the Agent's update method.


    Thanks for the tip, but it doesn't seem to work. I've tried force refresh, regular refresh, adding content, recreating the section, even reinstalling Plex. It will consistently hit the search function, but never touches the update function. Since I return 100 for the score in the search, I would think it'd be good to go on to try to update the metadata automatically, but doesn't seem to happen.

    I'm really confused, since I could swear it was working a few days ago, but I have no idea what I've done to break it. At one point I deleted a bunch of stuff from the Cache folder (assuming that it should just get rewritten if necessary anyway) when I was trying to make it forget and rebuild the names from just folder structure and such.

    So now Plex figures out show, season and date from folder and filenames, then hits my plugin for a search match. In theory it gets 100 returned which I understood as being the go-ahead to move on to update. But that's where I'm stuck.

    I did notice in the settings under Agents, that when I select TV Shows > Local Files Agent (my plugin), there is no check in the checkbox for it and no way of setting it. Not sure if that's standard behavior when there is only one plugin available for the category or if that is something else. In the other categories, the primary seems to be uneditable as well, but there the checkboxes are checked.

    I'm stumped. :)
  • djwhytedjwhyte Posts: 18Members, Plex Pass Plex Pass

    Did you ever resolve this? I am also seeing that the update () function on my Agent isn't being called. Pulling my hair out!

  • djwhytedjwhyte Posts: 18Members, Plex Pass Plex Pass

    Cancel that! I just realised that the 'id' specified in the search method can't contain special chars, particularly '://' since this ID is concatenated to a GUID of a format:

    {agent id}://{id}?lang={language}

    ...such as...

    com.plexapp.agents.mythtv://1001 20150515112700?lang=en

  • abusimbelyabusimbely Posts: 1Members

    hey guys,

    Any update for this issue? I face the same problem as well.
    The search method was hit every time I make a "fix incorrect match", the the update method won't be called after search method..

    So frustrating after searching all the internet for this problem and not get an answer..

Sign In or Register to comment.