python-plexapi icon indicating copy to clipboard operation
python-plexapi copied to clipboard

`LibrarySection.get()` Returning the wrong series for titles with commas

Open CollinHeist opened this issue 2 years ago • 4 comments

Describe the Bug

When searching for a series within a Library, if the series name has a comma, then the plexapi.library.LibrarySection.get() method returns the incorrect series.

This has happened for multiple series:

  • Love, Victor returns a match for Ainsley's Food We Love
  • Sabrina, The Teenage Witch returns Chilling Adventures of Sabrina
  • Alex, Inc. returns Alex Rider

If the comma is removed from the string, the correct match is returned. My guess is that the comma is causing the URL encoding to perhaps split the search into multiple queries (or something else entirely).

Code Snippets

from plexapi.server import PlexServer

PLEX_URL = 'YOUR URL HERE'
PLEX_TOKEN = 'YOUR TOKEN HERE'
LIBRARY_NAME = 'LIBRARY NAME HERE'

server = PlexServer(PLEX_URL, PLEX_TOKEN)
library = server.library.section(LIBRARY_NAME)

# If Love, Victor and Ainsley's Food We Love are both present
print(library.get('Love, Victor').guids)
# Prints [<Guid:imdb://tt13428252>, <Guid:tmdb://112847>, <Guid:tvdb://387981>]
# which corresponds to the wrong show

print(library.get('Love Victor').guids)
# Prints [<Guid:imdb://tt10166602>, <Guid:tmdb://97186>, <Guid:tvdb://368188>]
# which is correct

Expected Behavior

I expect the API to return the correct show. In particular the show titles within Plex include the commas, so searching with a comma should not be an issue.

Additional Context

No response

Operating System and Version

Windows 10 22H2

Plex Media Server Version

1.31.3.6819

Python Version

3.10.11

PlexAPI Version

4.13.4

CollinHeist avatar Apr 17 '23 01:04 CollinHeist

It seems to be a problem in Plex itself and not this Python library.

Go to the Advanced Filters in your library and try to do a filter for Title contains Love, Victor. Let me know if it works as expected. Also try Title is Love, Victor.

When I try it myself, Plex splits the filter into two filters Title contains Love and Title contains Victor.

JonnyWong16 avatar Apr 17 '23 07:04 JonnyWong16

Good catch - I see that as well. Perhaps this should be documented in the get method docs so that users can either manually remove the comma from their search or use the search method (and just filter the results manually)

CollinHeist avatar Apr 17 '23 15:04 CollinHeist

No, this should be reported to Plex so they can fix it.

JonnyWong16 avatar Apr 17 '23 16:04 JonnyWong16

Posted on the forum here.

CollinHeist avatar Apr 17 '23 17:04 CollinHeist