Skip to content

Library section lookup clobbered when multiple libraries have the same title #1324

@JonnyWong16

Description

@JonnyWong16

Describe the Bug

_sectionByTitle gets clobbered when there are multiple libraries with the same title. The returned library could be unexpected to the user.

https://github.com/pkkid/python-plexapi/blob/4780026a73af06af8801dada01f249ef6f8bb8db/plexapi/library.py#L51

Code Snippets

# Library 1: title = Movies, sectionID = 1
# Library 2: title = Movies, sectionID = 2
# Library 3: title = TV Shows, sectionID = 3

# ambiguous library name, returns library 2
plex.library.section("Movies")

# unambiguous library name, returns library 3
plex.library.section("TV Shows")

# The only way to return library 1 is by ID
plex.library.sectionByID(1)

Expected Behavior

Maybe raise a warning (non-breaking change) or exception (breaking change) indicating at the library title is ambiguous and directing the user to use sectionByID() instead.

Additional Context

The current behaviour returns the last library (highest sectionID) with the same title.

Operating System and Version

N/A

Plex Media Server Version

1.40.0.7775

Python Version

3.11.7

PlexAPI Version

4.15.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions