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!

Can I pass a custom value from search() to update()?

BrigoNortenssonBrigoNortensson Members, Plex Pass Posts: 62 Plex Pass

I am not the strongest Python programmer, but I usually manage. I know that these are sandboxed out the wazoo as well, and accept that this is only prudent, given the potential for all sorts of chicanery.

But I can't for the life of me figure out how to pass a value from search to update. Is this possible given the constraints imposed by the api? Is it obvious and I'm just a dufus?

I'd like to do something similar to the following:

    def search(self, results, media, lang, manual):
        ...
        results.Append(MetadataSearchResult(id=media.id, name=c.lower().title(), score=100, lang=lang))
        custom-value = 'x'
        return

    def update(self, metadata, media, lang, force):
        if custom-vakue == 'x':
            Log ('success')

In update(), media is a MediaTree object, but in search() it's a Media Container? And no other objects are common to both (not to mention I can't attach new attributes to any of these any way I can figure). What's the trick?

Thanks in advance.

Best Answer

  • BrigoNortenssonBrigoNortensson Members, Plex Pass Posts: 62 Plex Pass
    Accepted Answer

    The correct answer seems to be to include it with the id. If there is no external id assigned by your agent it's using the internal Plex db id, just a sqlite integer. Assigning a different number doesn't mess with that. Add some separator character (dot works fine, comma or whatever). You'll have to substring or split out the values within update().

    Nothing else seems possible.

    Leaving this here in case anyone else can benefit.

Answers

  • BrigoNortenssonBrigoNortensson Members, Plex Pass Posts: 62 Plex Pass
    Accepted Answer

    The correct answer seems to be to include it with the id. If there is no external id assigned by your agent it's using the internal Plex db id, just a sqlite integer. Assigning a different number doesn't mess with that. Add some separator character (dot works fine, comma or whatever). You'll have to substring or split out the values within update().

    Nothing else seems possible.

    Leaving this here in case anyone else can benefit.

Sign In or Register to comment.