Skip to content

Conversation

@othyn
Copy link

@othyn othyn commented Mar 14, 2025

PR: Support Multiple Music Libraries in PlexService

Problem

The current implementation of PlexService assumes there's a single music library named "Music" in the Plex server. This causes the application to fail when a user has multiple music libraries or has named their music library something other than "Music".

I've also taken the opportunity to add some sections to the README, mainly;

  • Removing the unused make start command.
  • Adding usage instructions for the pre-built Docker image.
  • Amends the CI/CD pipeline to generate images on all branches, just not tag them as latest unless its master, as its handy for running pre-release images on forked repos that are pending PR approval/merge.

Solution

This PR modifies the PlexService class to handle multiple music libraries by:

  1. Searching for all music libraries (sections with type "artist") instead of assuming a single one named "Music"
  2. Caching artists from all music libraries while avoiding duplicates
  3. Searching across all music libraries when looking for artists and tracks
  4. Providing better logging about the number of libraries found

Changes

  • Changed self._music_library to self._music_libraries (a list instead of a single library)
  • Modified the initialize method to find all music libraries by checking for sections with type 'artist'
  • Updated the get_artists_albums_bulk method to search for artists across all music libraries
  • Updated the create_curated_playlist method to search for artists and tracks across all music libraries
  • Updated tests to work with the new implementation that uses multiple music libraries

Testing

  • Updated unit tests to work with the new implementation
  • Manually tested with a Plex server that has multiple music libraries
  • All tests pass with the new implementation

Benefits

  • The application now works with multiple music libraries instead of failing when it can't find a single library named "Music"
  • Users can organize their music into multiple libraries and the application will still work correctly
  • Better logging provides more information about the libraries found on the server

…ot tagged as `latest` unless its master, as its useful for generating builds on PR pending items
)

logger.info("Cached %d artists", len(self._artists_cache))
# Find all music libraries instead of assuming one called "Music"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably drop the comment or rephrase, PR resolves the assumption

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants