python-plexapi
python-plexapi copied to clipboard
`LibrarySection.get()` Returning the wrong series for titles with commas
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, Victorreturns a match forAinsley's Food We LoveSabrina, The Teenage WitchreturnsChilling Adventures of SabrinaAlex, Inc.returnsAlex 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
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.
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)
No, this should be reported to Plex so they can fix it.
Posted on the forum here.