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!

Bug in the album part of the metadata API

There's quite a serious bug right now in the API when searching for album matches. It's not a bug of the agent, but the API itself.
When Plex/Web does a match, it sends the full title taken from the Scanner, and gives the agent this name through media.album. This far is correct.
When doing a custom search however, media.album is now None. Now, while http://dev.plexapp.com/docs/agents/search.html#Media does not even show this media object to even HAVE a .title attrib, it does. However .title, does not respect the search field in the custom search dialog and instead always contains the name given by the scanner.

So the conclusion, is that .album is bugged, as it isnt getting filled with the contents of the search box. This means that custom search for albums, are currently broken and cannot be used, at all.

With some "bright" plex dev's idea that security is somehow gained by obscurity, functions like dir() cannot be used to diagnose anything so basicly, the only thing to do, is pass it off to others, who will be highly unlikely to fix it within this decade... So, does anyone have any feasable workarounds?


  • mattfhmattfh Posts: 35Members, Plex Pass Plex Pass
    Why is it that no one connected to Plex seems to acknowledge the posts? Not the first one I've read whe someone is asking questions of the code (and providing feedback) and then radio silence. Is there another way/forum for this sort of critical feedback? Where the product I paid $80 for (lifetime membership) makes every effort to reduce the bugs in the software you would expect devs to be jumping on these posts. Or am I being unreasonable?
  • EtherManEtherMan Posts: 64Members ✭✭

    Seriously... It's now been four YEARS since this bug was introduced... And it's STILL not fixed... Or even acknowledged.

    media.title always has the scanner's name.
    media.album has either the scanner's name... or None
    media.name has the Custom Search field... or the name of the first TRACK on the album.

    Now, media.title always being the scanner's name. That's fine and normal behavior of an API. It's consistent.
    media.album, always having the scanner's name or None for custom searches. Not common or normal behavior, but always has the same data when it has data at least.
    media.name having DIFFERENT data, from COMPLETELY DIFFERENT CONTEXTS depending on what mode of search is used... Yea that's completely non standard and goes against every coding guideline in existence about making APIs... Even Plex own Last.FM agent is making hacky workarounds for this, AND FAILS AT IT since even with that workaround, it doesn't fix the quick search, just the auto.

    Come on now. You're even expecting people to pay for your premium music library service but can't even get the basic one working?

  • GittalonglildoggiesGittalonglildoggies Posts: 75Members, Plex Pass Plex Pass
    edited October 2017


    I'm considering writing my own music agent but I'm concerned that until this issue is addressed it would be a kluge at best.

    Is this issue with the API on the radar to be fixed? Any ETA?

    My rig:
    OpenPHT - HTPC - Intel NUC6i5SYH - Windows 10 Pro Anniversary Edition, 16 GB ECC memory, Dual core 1.9 GHz, 500 GB PCIE SSD, 1 GB Ethernet.
    PMS - HTMac Server - MacPro (late 2013) - OSX 10.12.3, 12GB ECC memory, Quad core 3.7 GHz, 1 TB PCIE SSD, 1 GB Ethernet. All media stored on NAS, mounted via smb.
    NAS - Iomega StorCenter ix4-200d: firmware v3.2.14.30167, 4 - 1 TB Western Digital Black (enterprise 1.5 million hrs MTtF), all services disabled except for CIFS. Dual homed 1 GB nics.

  • EtherManEtherMan Posts: 64Members ✭✭

    You're in for a bumpy ride if you plan on making your own agent. This issue is minor compared to the rest of the issues plaguing the metadata API and the whole thing has been intentionally crippled to the point where they're overriding python functions to make them do non standard things when being used from the API, as well as making it impossible to load most third party libraries, such as any libs for parsing a content tree... If you despite knowing this, still want to go ahead, I'll give you this:

            # Basic fix for Plex absurdly broken API that they apparantly have no intention of fixing.
                if manual == False:                             # Automatic matching. Use Scanner Hint.
                    search_name = urllib.quote_plus(media.title.decode('iso-8859-1'))
                elif manual == True and media.album == None:    # Custom Search. Use Custom Search Field.
                    search_name = urllib.quote_plus(media.name)
                else:                                           # Quick Search. Use Scanner Hint.
                    search_name = urllib.quote_plus(media.title.decode('iso-8859-1'))
                Log.Error('Error during Plex API fix')

    But know that that code, will ONLY work if your client is using the iso-8859-1 codepage... Because in their glorious wisdom, they made media.title to be whatever local codepage the client is using... while media.name is ofc unicode. Basically, you need a way to either guess the codepage yourself because Plex doesn't allow loading the libs that do that, only use services that guess the codepage for you (in which case you can skip the .decode() part entirely), or use magic I guess...

Sign In or Register to comment.